-
Notifications
You must be signed in to change notification settings - Fork 3
T98: Configure ESLint #135
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2c5c1b5
Configure eslint
Dennull 70e106d
Merge branch 'T132-Update-Packages' into T98-Configure-ESLint
Dennull 50c3fb3
Merge branch 'main' into T98-Configure-ESLint
Dennull de35029
Install eslint-plugin-prettier
Dennull 9496f11
Install and configure eslint-plugin-import-x
Dennull 1ed6271
Sort imports
Dennull 1ebdda0
Sort props
Dennull 5c20945
Update settings.json
Dennull d70af18
Also sort imports alphabetically
Dennull e126ba8
Remove some input ids that we don't need
Dennull a1b76fc
Merge branch 'main' into T98-Configure-ESLint
Dennull 4d36acf
Run formatter
Dennull 9fba6e4
Update tsconfig.json
Dennull 9774346
Run npm audit fix
Dennull cee0582
ESlint PR comments
Dennull 686641a
Revert "Run formatter"
Dennull 22a5b26
Revert "Also sort imports alphabetically"
Dennull 28e9371
Revert "Sort imports"
Dennull f50d0fa
Merge branch 'main' into T98-ESLint-Fix-Merge-Conflicts
Dennull 1e9ce3b
Run linter and formattter
Dennull 33bd931
Have linter ignore build dir
Dennull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"endOfLine": "auto" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"editor.formatOnSave": true | ||
} | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": "explicit" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable import-x/no-named-as-default-member */ | ||
import pluginJs from "@eslint/js"; | ||
import tsParser from "@typescript-eslint/parser"; | ||
import eslintPluginImportX from "eslint-plugin-import-x"; | ||
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; | ||
import pluginReact from "eslint-plugin-react"; | ||
import globals from "globals"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
export default [ | ||
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] }, | ||
{ languageOptions: { globals: globals.browser } }, | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
pluginReact.configs.flat.recommended, | ||
pluginReact.configs.flat["jsx-runtime"], | ||
eslintPluginPrettierRecommended, | ||
eslintPluginImportX.flatConfigs.recommended, | ||
eslintPluginImportX.flatConfigs.typescript, | ||
{ | ||
languageOptions: { | ||
parser: tsParser, | ||
ecmaVersion: "latest", | ||
sourceType: "module", | ||
}, | ||
Dennull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
rules: { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"import-x/default": "off", | ||
"import-x/order": [ | ||
"error", | ||
{ | ||
alphabetize: { | ||
order: "asc", | ||
caseInsensitive: true, | ||
}, | ||
}, | ||
], | ||
"react/jsx-sort-props": ["error", { ignoreCase: true }], | ||
"react/sort-prop-types": "error", | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
When I tried running the command with the provided solution (settings object), I noticed that the command took quite some time, so I chat gpt'd reasons as to why it may be, and I guess I concluded with the idea that when I run the command in the root directory, it goes through all folders and files. I'm not sure if that's the reason why it takes so long, but I tested it by forcing the linting to only work on the src folder and it wound up being alot quicker
npx eslint --fix src/
Do you find a similar issue on your end or is this isolated to my computer?
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 do find it kind of slow (like 10 seconds slow), but when I run
npx eslint --fix src/
the time is about the same for me. I suspected that maybe it was linting node modules but by default eslint ignores node modules. I also rannpx eslint --debug
and confirmed so that node modules wasn't being lintedI guess
eslint-plugin-prettier
adds some overhead, but when I tried removing the it the time was still was >5 seconds, so I think it's alsoeslint-plugin-import-x
. Some files just take a while to lint with the plugins. You can try runningnpx eslint --debug
yourself to see how long stuff takes to run, I'm open to any suggestions. Given that we're probably only running this once in a while I'm inclined to move forward and work on continue working on improving the performance later though, let me know if you agreeUh oh!
There was an error while loading. Please reload this page.
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.
Okay, as discussed offline, it turns out the issue was that the linter was looking through your build folder. I managed to find out why my config to ignore the build directory wasn't working and fixed it. Give it a shot and see if that stops the linter from going forever 👍