Skip to content

Commit a33a364

Browse files
committed
fix: add linting
1 parent a580250 commit a33a364

6 files changed

+34
-6
lines changed

.eslintrc.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module.exports = {
2-
extends: [
3-
'@open-wc/eslint-config',
4-
].map(require.resolve),
2+
extends: ['@open-wc/eslint-config', 'eslint-config-prettier'].map(require.resolve),
53
};

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
coverage/
3+
_site/

commitlint.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

husky.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
hooks: {
3+
'pre-commit': 'lint-staged',
4+
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
5+
},
6+
};

package.json

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lit-html": "^0.12.0"
1111
},
1212
"scripts": {
13-
"lint": "npm run lint:eslint",
13+
"lint": "npm run lint:eslint && npm run lint:prettier",
1414
"lint:eslint": "eslint --ext .js,.html .",
1515
"site:build": "npm run storybook:build",
1616
"storybook:build": "build-storybook -o _site",
@@ -19,7 +19,11 @@
1919
"test:watch": "karma start --auto-watch=true --single-run=false",
2020
"test:es5": "karma start karma.es5.config.js",
2121
"test:es5:watch": "karma start karma.es5.config.js --auto-watch=true --single-run=false",
22-
"test:es5:bs": "karma start karma.es5.bs.config.js"
22+
"test:es5:bs": "karma start karma.es5.bs.config.js",
23+
"format": "npm run format:eslint && npm run format:prettier",
24+
"format:eslint": "eslint --ext .js,.html . --fix",
25+
"lint:prettier": "prettier '**/*.js' --list-different || (echo '↑↑ these files are not prettier formatted ↑↑' && exit 1)",
26+
"format:prettier": "prettier '**/*.js' --write"
2327
},
2428
"devDependencies": {
2529
"@open-wc/eslint-config": "^0.3.0",
@@ -28,6 +32,18 @@
2832
"@open-wc/testing-karma": "^0.4.0",
2933
"@open-wc/testing-karma-bs": "^0.2.0",
3034
"@open-wc/testing-wallaby": "^0.1.3",
31-
"webpack-merge": "^4.1.5"
35+
"webpack-merge": "^4.1.5",
36+
"husky": "^1.0.0",
37+
"lint-staged": "^8.0.0",
38+
"@open-wc/prettier-config": "^0.1.0",
39+
"@commitlint/cli": "^7.0.0",
40+
"@commitlint/config-conventional": "^7.0.0"
41+
},
42+
"lint-staged": {
43+
"*.js": [
44+
"eslint --fix",
45+
"prettier --write",
46+
"git add"
47+
]
3248
}
3349
}

prettier.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
module.exports = require('@open-wc/prettier-config');

0 commit comments

Comments
 (0)