feat: setup lint-staged when making a commit
This commit is contained in:
parent
70b220400c
commit
4d60c63f84
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
yarn lint-staged
|
|
@ -0,0 +1,23 @@
|
|||
const ignoredFiles = ['package.json', 'yarn.lock', 'tsconfig.json', '.lintstagedrc.js'];
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const buildFormatCommand = filenames => {
|
||||
const results = filenames
|
||||
.map(f => path.relative(process.cwd(), f))
|
||||
.filter(f => !ignoredFiles.includes(f));
|
||||
|
||||
return results.length ? `prettier --list-different --write ${results.join(' ')}` : '';
|
||||
};
|
||||
|
||||
const buildLintCommand = filenames => {
|
||||
const results = filenames
|
||||
.map(f => path.relative(process.cwd(), f))
|
||||
.filter(f => !ignoredFiles.includes(f));
|
||||
|
||||
return results.length ? `eslint ${results.join(' ')}`: '';
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
'*.{css,js,json,scss,ts,tsx}': [buildFormatCommand, buildLintCommand],
|
||||
};
|
|
@ -37,3 +37,7 @@ Gruntfile.js
|
|||
|
||||
!istanbul-reports/lib/html/assets
|
||||
!istanbul-api/node_modules/istanbul-reports/lib/html/assets
|
||||
|
||||
# lint-staged fix
|
||||
# https://github.com/eemeli/yaml/issues/384#issuecomment-1368496106
|
||||
!**/yaml/dist/**/doc
|
||||
|
|
|
@ -64,7 +64,8 @@
|
|||
"postinstall": "yarn patch-package && yarn electron-builder install-app-deps",
|
||||
"update-git-info": "node ./build/updateLocalConfig.js",
|
||||
"worker:utils": "webpack --config=./utils.worker.config.js",
|
||||
"worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js"
|
||||
"worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emoji-mart/data": "^1.1.2",
|
||||
|
@ -182,8 +183,10 @@
|
|||
"eslint-plugin-react": "^7.33.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"events": "^3.3.0",
|
||||
"husky": "^8.0.0",
|
||||
"jsdom": "^22.1.0",
|
||||
"jsdom-global": "^3.0.2",
|
||||
"lint-staged": "^14.0.1",
|
||||
"mini-css-extract-plugin": "^2.7.5",
|
||||
"mocha": "10.0.0",
|
||||
"node-loader": "^2.0.0",
|
||||
|
|
Loading…
Reference in New Issue