-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
#1870 fix pre commit errors #1884
Conversation
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.
Thanks for working on this!
I have some doubts regarding the ESLint configuration. The old config file states that it extends eslint:recommended
but the new one does not.
This may help: https://eslint.org/docs/latest/use/configure/configuration-files-new#using-predefined-configurations but it's an additional dependency and that also means that we always have to keep additional_dependencies
updated in the pre-commit configuration (at least I don't know a better way)
A different approach might be to copy the configuration from https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js into our config, but that would have to be kept up-to-date manually as well.
Thanks for the feedback. I agree there's something missing in the new config I actually faced some challenges adding the dependencies This is how the config file looks like with the const js = require("@eslint/js");
module.exports = [
js.configs.recommended,
{
languageOptions:{
ecmaVersion: 6,
sourceType: "module",
}
},
{
rules: {
"curly": ["error", "all"],
"dot-notation": "error",
"eqeqeq": "error",
"no-eval": "error",
"no-var": "error",
"prefer-const": "error",
"semi": "error"
}
}
]; The issue I get though is that I can't seem to find a way to add the dependency I tried doing so via This is what I added to the hooks:
- id: eslint
additional_dependencies:
- eslint@v9.0.0-beta.0 But when I tried to run the ESLint: 9.0.0-beta.0
Error: Cannot find module '@eslint/js'
Require stack:
- /Users/macbook/Desktop/code/djangonautspace/django-debug-toolbar/eslint.config.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1149:15)
at Module._load (node:internal/modules/cjs/loader:990:27)
at Module.require (node:internal/modules/cjs/loader:1237:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/Users/macbook/Desktop/code/djangonautspace/django-debug-toolbar/eslint.config.js:1:12)
at Module._compile (node:internal/modules/cjs/loader:1378:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
at Module.load (node:internal/modules/cjs/loader:1212:32)
at Module._load (node:internal/modules/cjs/loader:1028:12)
at cjsLoader (node:internal/modules/esm/translators:359:17)
I'd appreciate any advise rendered. |
I'm not sure but I think you have to add additional
This may work but it also does suck a bit since now dependabot will not update all those entries; it only updates the top-level version/tag. |
I have tried that but pre-commit doesn't accept the @ infront of an entry in the |
Adding string quotes should work: |
Thanks. This worked. Now I am going to fix the globals. That's something else that is not catered for in the current config |
@matthiask I noticed something I think you should know. When I changed the 12:17 error Parsing error: Unexpected token ..
✖ 1 problem (1 error, 0 warnings)
It supposedly doesn't recognise the spread operator |
Yeah. |
I have set the |
Thanks! I'm very happy with this update. I'm not totally happy that we have to spell out the ESLint dependency versions now, but there's not much you can do about it. |
Description
Migrated current
.eslintrc.js
to flat config i.eeslint.config.js
to fix the errors that were faced during running the eslint pre-commit hook.Fixes #1870
Checklist:
docs/changes.rst
.