-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consistently delegate linting concerns to pre-commit #47
Changes from all commits
99c3a5d
12cbd2f
5ec316b
0cdf907
02648fb
f346f29
cfee5e7
50beb76
bf9a708
ff8595f
724c1dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ default_language_version: | |
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
|
@@ -26,23 +26,49 @@ repos: | |
args: ['--target-version', 'py37'] | ||
- repo: https://github.com/pycqa/isort | ||
# isort config is in setup.cfg | ||
rev: 5.10.1 | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/pycqa/flake8 | ||
# flake8 config is in setup.cfg | ||
rev: 5.0.4 | ||
rev: 6.0.0 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-bugbear | ||
- flake8-comprehensions | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
# note: keep in sync with the version from package.json | ||
rev: 'v1.18.2' | ||
# prettier config is in prettier.config.js | ||
rev: 'v2.7.1' | ||
hooks: | ||
- id: prettier | ||
types_or: [css, scss, javascript, ts, tsx, json, yaml] | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
# eslint config is in .eslintrc.js | ||
rev: v8.32.0 | ||
hooks: | ||
- id: eslint | ||
additional_dependencies: | ||
- '[email protected]' | ||
- '[email protected]' | ||
- '[email protected]' | ||
- '[email protected]' | ||
- '[email protected]' | ||
- '[email protected]' | ||
- '@typescript-eslint/[email protected]' | ||
- '@typescript-eslint/[email protected]' | ||
- '@wagtail/[email protected]' | ||
files: \.(js|jsx|ts|tsx)$ | ||
types: [file] | ||
- repo: https://github.com/awebdeveloper/pre-commit-stylelint | ||
# stylelint config is in .stylelintrc.js | ||
rev: 8f63da497580898a7e0ceef6bf9e72cc0af07828 | ||
hooks: | ||
- id: stylelint | ||
files: \.(scss)$ | ||
additional_dependencies: | ||
- '[email protected]' | ||
- '@wagtail/[email protected]' | ||
- repo: https://github.com/asottile/blacken-docs | ||
rev: v1.12.1 | ||
hooks: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,7 @@ | |
"main": "{{ cookiecutter.__project_name_snake }}/static_src/main.tsx", | ||
"scripts": { | ||
"start": "webpack --config ./webpack.config.js --mode development --progress --watch", | ||
"build": "webpack --config ./webpack.config.js --mode production", | ||
"format": "prettier --write '**/?(.)*.{css,scss,js,ts,tsx,json,yaml,yml}'", | ||
"lint:js": "eslint --ext .js,.ts,.tsx --report-unused-disable-directives --max-warnings 16 ./", | ||
"lint:css": "stylelint **/*.scss", | ||
"lint:format": "prettier --check '**/?(.)*.{css,scss,js,ts,tsx,json,yaml,yml}'", | ||
"lint": "npm run lint:js && npm run lint:css && npm run lint:format" | ||
"build": "webpack --config ./webpack.config.js --mode production" | ||
}, | ||
"author": "", | ||
"license": "{% if cookiecutter.open_source_license == 'MIT license' -%}MIT{% elif cookiecutter.open_source_license == 'BSD license' %}BSD{% elif cookiecutter.open_source_license == 'ISC license' -%}ISC{% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%}Apache{% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%}{% endif %}", | ||
|
@@ -19,18 +14,11 @@ | |
"@types/react": "^16.8.19", | ||
"@types/react-dom": "^16.8.19", | ||
"@types/styled-components": "^5.1.23", | ||
"@typescript-eslint/eslint-plugin": "^5.12.1", | ||
"@typescript-eslint/parser": "^5.12.1", | ||
"@wagtail/eslint-config-wagtail": "^0.4.0", | ||
"@wagtail/stylelint-config-wagtail": "^0.5.0", | ||
"eslint": "^8.9.0", | ||
"file-loader": "^6.2.0", | ||
"postcss-loader": "^6.2.1", | ||
"postcss": "^8.4.5", | ||
"prettier": "^2.5.1", | ||
"sass-loader": "^12.4.0", | ||
"sass": "^1.45.3", | ||
"stylelint": "^14.5.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. love a good dependency tidy up! (granted this has shifted to pre-commit, but still) |
||
"ts-loader": "^9.2.6", | ||
"typescript": "^4.5.5", | ||
"webpack": "^5.65.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,8 @@ dependencies = [ | |
] | ||
[project.optional-dependencies] | ||
testing = [ | ||
"dj-database-url==1.2.0" | ||
"dj-database-url==1.2.0", | ||
"pre-commit>=2.21.0,<3.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've pinned to pre-commit 2.x because pre-commit 3 drops compatibility with python 3.7 and this project still includes 3.7 in the test matrix/classifiers. Once we drop it, we can bump this to pre-commit 3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍🏼 #50 |
||
] | ||
|
||
[project.urls] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable no-unused-vars */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put this here because if I just make a new package and run eslint on the output, I get
This is not unexpected as none of these type definitions are used by any code that exists (yet). I think if we want to be able to run eslint on this and have it pass, we do need to silence that error somehow. I am slightly unclear whether we want to render the package output with that check disabled when a user generates a new package. I think I need to understand slightly more about the rationale for including this specific selection of type definitions in the first place to make the right decision here. |
||
export {}; | ||
|
||
// Allows SVG files to be imported and used in TypeScript | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a blocker, but another pre-commit question as I continue my odyssey of trying to get on-board with it:
It seems like pre-commit requires the user to resolve their own dependency tree here. Whereas with NPM we can just specify the top-level plugins we care about (
@typescript-eslint/eslint-plugin
,@typescript-eslint/parser
,@wagtail/eslint-config-wagtail
) and leave NPM to resolve the transitive dependencies, that doesn't work with pre-commit. It seems you need to explicitly specify each plugin/config referenced in eslintrc in.pre-commit-config.yaml
(this is what we do in WTKit too for reference). I was able to work it out by npm install-ing everything into a clean project somewhere else, letting NPM resolve the constraints and then usingnpm list
to extract the packages/version numbers from the resolved tree to manually plug back in to the yaml file, but this doesn't feel like an ideal workflow to impose on package authors as they maintain/update this over time. It is not something I would ideally choose to live with on an ongoing basis. Am I doing it wrong? Is there a better solution for this that exists in pre-commit land?. This seems to be a characteristic which is mostly ESLint-specific as a typical ESLint config relies on many third-party plugins and configs, which is not the case for most other tools we use.