-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
chore(linting) apply a rule that fixes import vs import type when is possible #8907
Conversation
Build Stats
|
There is also an export rule but is unclear how to use it |
ok export type works in vscode but for some reason not with the lint command |
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 see there are more actionable code paths that lint didn't fix.
This is a good tool.
Since we are going in this direction how about https://eslint.org/docs/latest/rules/sort-imports?
Before, I wanted it but I thought it was part of the scope of prettier, but of course it isn't. It is the scope of lint. Do you agree?
@@ -23,6 +22,7 @@ import { | |||
TToCanvasElementOptions, | |||
TValidToObjectMethod, | |||
} from '../typedefs'; | |||
import { ImageFormat } from '../typedefs'; |
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.
did lint fix this? or did you?
this is a great tool regardless
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.
there was a merge conflict and then LINT got angry at my merge resolution. so i run it again
'@typescript-eslint/consistent-type-exports': 'error', | ||
'@typescript-eslint/consistent-type-imports': 'error', |
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.
'@typescript-eslint/consistent-type-exports': 'error', | |
'@typescript-eslint/consistent-type-imports': 'error', | |
'@typescript-eslint/consistent-type-exports': [ | |
'error', | |
{ | |
fixMixedExportsWithInlineTypeSpecifier: true, | |
}, | |
], | |
'@typescript-eslint/consistent-type-imports': [ | |
'error', | |
{ | |
fixStyle: 'inline-type-imports', | |
}, | |
], |
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.
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.
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.
aren't those catched with default values?
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.
import { XY, Point } from '../Point';
import { TClassProperties } from '../typedefs';
import type { XY } from '../Point';
import { Point } from '../Point';
import type { TClassProperties } from '../typedefs';
but this similar case was handled.
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.
even applying your config i don't get the extra changes.
i don't want to sort import. |
no i don't like the inlined, there are some situations in which that doesn't work great. i went to check and inline type import has been introduced in typescript 4.5 |
@@ -57,7 +57,7 @@ | |||
"test:coverage": "nyc --silent qunit test/node_test_setup.js test/lib test/unit", | |||
"test:visual:coverage": "nyc --silent --no-clean qunit test/node_test_setup.js test/lib test/visual", | |||
"coverage:report": "nyc report --reporter=lcov --reporter=text", | |||
"lint": "eslint --config .eslintrc.js src/**/*.ts", | |||
"lint": "eslint --config .eslintrc.js src", |
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.
this was my issue.
i was getting only files inside the first folders.
VSCode indeed was looking and eslint.rc and workin correctly.
I updated lint and tsplugins for lint to latest since i was trying to figure out why i didn't see the things |
@ShaMan123 regarding inline vs non inline. |
So that is why lint ran on my machine and produced a big diff? Because of the merge conflict and the versuons of the tool? I don't mind about the syntax. Wanted to highlight the options so we make an informed decision. |
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.
looks valid to me
I didn't check every file though
do you apply lint with vscode? or with npm run lint? that could have been the difference. |
Motivation
This adds import consistency and probably speeds up aware bundler/parsers
The changes are all made with the lint --fix command and no human intervention.
Description
Changes
import type will be enforced when possible
Gist
In Action