Skip to content

Commit

Permalink
added lint rules and bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
gatanaso committed Jul 3, 2019
1 parent 637d7e9 commit 43f504f
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 39 deletions.
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": "vaadin",
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": [
"html"
],
"globals": {
"Polymer": false,
"Vaadin": false
},
"rules": {
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
]
},
"parserOptions": {
"sourceType": "module"
}
}
3 changes: 3 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-vaadin"
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

# \<time-field\>

A simple time field Web Component based on Polymer 3.
A time field Web Component based on Polymer 3.

[Live Demo ↗](https://time-field.web.app/demo/)
[Live Demo ↗](https://time-field.firebaseapp.com/demo/)

### Getting started
The `time-field` component is distributed as an npm package.
To start using it, first install it from the command line:
```
npm install --save gatanaso/time-field
npm install --save time-field
```
Once installed, import it into your application:
```
Expand All @@ -31,5 +31,5 @@ import 'time-field/time-field.js'
When in the `time-field` directory, run:

```
$ wct test --npm -module-resolution=node
$ wct --npm
```
41 changes: 28 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{
"name": "time-field",
"description": "A simple time field Web Component based on Polymer 3",
"version": "0.0.5",
"description": "A time field Web Component based on Polymer 3",
"version": "1.0.0",
"main": "time-field.js",
"scripts": {
"test": "wct test --npm -module-resolution=node"
},
"repository": {
"type": "git",
"url": "https://github.com/gatanaso/time-field.git"
Expand All @@ -19,21 +16,39 @@
],
"author": "Goran",
"license": "Apache-2.0",
"homepage": "https://github.com/gatanaso/time-field",
"bugs": {
"url": "https://github.com/gatanaso/time-field/issues"
},
"homepage": "https://github.com/gatanaso/time-field",
"files": [
"time-field-*.js"
],
"scripts": {
"test": "npm run lint && wct --npm",
"lint": "npm-run-all --parallel lint:*",
"lint:css": "stylelint --syntax html *.js demo test",
"lint:html": "eslint *.html demo test --ext .html",
"lint:js": "eslint *.js",
"lint:polymer": "polymer lint --input *.js",
"start": "npm run lint && wct --npm && polymer serve --npm --open"
},
"dependencies": {
"@polymer/iron-icons": "^3.0.0-pre.21",
"@polymer/polymer": "^3.0.0",
"@vaadin/vaadin-button": "^2.1.0-alpha3",
"@vaadin/vaadin-text-field": "^2.1.0-alpha3"
"@vaadin/vaadin-button": "^2.2.0",
"@vaadin/vaadin-text-field": "^2.4.7",
"@polymer/iron-icons": "^3.0.1"
},
"devDependencies": {
"@polymer/iron-demo-helpers": "^3.0.0-pre.19",
"@polymer/iron-demo-helpers": "^3.0.0",
"@webcomponents/webcomponentsjs": "^2.0.0",
"wct-browser-legacy": "^1.0.0",
"web-component-tester": "^6.7.1",
"wct-istanbul": "^0.14.3"
"eslint": "^6.0.1",
"eslint-config-vaadin": "^0.2.7",
"eslint-plugin-html": "^6.0.0",
"npm-run-all": "^4.1.5",
"stylelint": "^10.1.0",
"stylelint-config-vaadin": "^0.1.4",
"wct-browser-legacy": "^1.0.2",
"wct-istanbul": "^0.14.3",
"web-component-tester": "^6.9.2"
}
}
13 changes: 13 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"rules": {
"no-unused-vars": 0
},
"globals": {
"WCT": false,
"fixture": false,
"describe": false,
"it": false,
"beforeEach": false,
"expect": false
}
}
4 changes: 2 additions & 2 deletions test/time-field-input_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
const value = timeFieldInput._zeroPadValue(intValue);

// then
expect(value).to.be.eq('07')
expect(value).to.be.eq('07');
});

it('should not zero pad number it\'s greater than 10', () => {
Expand All @@ -173,7 +173,7 @@
const value = timeFieldInput._zeroPadValue(intValue);

// then
expect(value).to.be.eq('25')
expect(value).to.be.eq('25');
});
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/time-field_test.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
Expand Down Expand Up @@ -42,7 +42,7 @@

it('should return and keep old value when new value is empty', () => {
// given
timeField.value = '01:49'
timeField.value = '01:49';
const newValue = '';

// when
Expand Down Expand Up @@ -115,7 +115,7 @@
expect(timeField.value).to.be.eq('11:23');
});
});
});
});
</script>

</body>
Expand Down
6 changes: 3 additions & 3 deletions time-field-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import './time-field-styles.js';
/**
* `time-field-input`
*
* A very simple number input based on the `vaadin-text-field`.
* A number input based on the `vaadin-text-field`.
*/
class TimeNumberInput extends PolymerElement {
static get template() {
Expand Down Expand Up @@ -93,7 +93,7 @@ class TimeNumberInput extends PolymerElement {
}

_checkValue() {
if(!this.value) {
if (!this.value) {
return;
}

Expand All @@ -105,7 +105,7 @@ class TimeNumberInput extends PolymerElement {

if (intValue < this.min) {
intValue = this.min;
} else if(intValue > this.max) {
} else if (intValue > this.max) {
intValue = this.max;
}

Expand Down
2 changes: 1 addition & 1 deletion time-field-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ styleMod.innerHTML = `
</template>
`;

styleMod.register("time-field-styles");
styleMod.register('time-field-styles');
11 changes: 5 additions & 6 deletions time-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import './time-field-input.js';

/**
* `time-field`
* A simple time field input element
* A time field input element
*
* @customElement
* @polymer
Expand All @@ -15,11 +15,10 @@ class TimeField extends PolymerElement {
return html`
<style>
* {
--time-field-default-color: hsla(214, 40%, 16%, 0.94);;
--time-field-input-default-color: var(--time-field-default-color);
--time-field-controls-default-color: var(--time-field-default-color);
--time-field-separator-default-color: var(--time-field-default-color);
--time-field-default-color: hsla(214, 40%, 16%, 0.94);
--time-field-input-default-color: var(--time-field-default-color);
--time-field-controls-default-color: var(--time-field-default-color);
--time-field-separator-default-color: var(--time-field-default-color);
--time-field-disabled-default-color: hsla(214, 50%, 22%, 0.26);
}
Expand Down
14 changes: 7 additions & 7 deletions wct.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module.exports = {
verbose: false,
plugins: {
istanbul: {
dir: "./coverage",
reporters: ["text-summary", "lcov"],
include: ["**/time-field*.js"],
dir: './coverage',
reporters: ['text-summary', 'lcov'],
include: ['**/time-field*.js'],
exclude: [],
thresholds: {
global: {
Expand All @@ -13,12 +13,12 @@ module.exports = {
}
},
local: {
browsers: ["chrome"],
browsers: ['chrome'],
browserOptions: {
chrome: [
"headless",
"disable-gpu",
"no-sandbox"
'headless',
'disable-gpu',
'no-sandbox'
],
}
}
Expand Down

0 comments on commit 43f504f

Please sign in to comment.