Fix prettier, eslint and stylelint config and also enable automatic execution #530
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes
Description
Runs prettier automatically for consistency. Also fixes eslint and stylelint config.
NB: these changes might be problematic with the new docker setup of this project (#517). If git commits are made on the host machine and git hooks don't execute within the container, then node, npm and packages may not have been installed so the hooks will fail.
Technical details
Add and configure husky to run lint-staged (latest v8.x, since v9 drops node v14 support):
npm install --save-dev [email protected]
npx husky add .husky/pre-commit npx lint-staged
Upgrade Prettier and add
npm run format
scripts:npm update prettier
Downgrade
eslint-config-prettier
to be compatible with eslint v6 (current v7.2.0 requires eslint upgrade):npm install --save-dev [email protected]
Ignores
coverage
anddist
directories when running PrettierUpdate
lint-staged
to run prettierRemove git-hooks config from
package.json
(this project uses Husky not Yorkie)Check eslint <-> prettier conflicts and remove problematic rules:
Set
lint-staged
to runstylelint
on the same file patterns as the npm script is configured to. This potentially needs further work as a separate PR because currently onmain
, if you runnpx stylelint **/*.{css,vue} --fix
(the equivalent of whatlint-staged
runs it against), there's a bunch of things flagged in thestatic
directory.Tests
npm run lint
andnpm run format
and check that tests and builds still work OKChecklist
Update index.md
).main
ormaster
).visible errors.
Developer Certificate of Origin
For the purposes of this DCO, "license" is equivalent to "license or public domain dedication," and "open source license" is equivalent to "open content license or public domain dedication."
Developer Certificate of Origin