-
Notifications
You must be signed in to change notification settings - Fork 213
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) Extend ESLint configuration #837
Conversation
91d0cb9
to
a2ae073
Compare
Size Change: -378 kB (-12%) 👏 Total Size: 2.71 MB
ℹ️ View Unchanged
|
a2ae073
to
8bfcdd8
Compare
ccd0d39
to
9ade952
Compare
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 @denniskigen! Looks great. I'm not really sure what to do about my longer concern, so feel free to ignore that one.
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/triple-slash-reference": "off", | ||
// Use `import type` instead of `import` for type imports https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how |
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.
Personally, I'm a little iffy on this rule. Specifically, I like the idea of requiring type qualification for type imports, but the style I prefer is not one of the "consistent" options, specifically, the style I prefer is:
import type { Type1, Type2, Type3, Type4 } from "./types";
import {
type Patient,
type Visit,
saveVisit
} from "@openmrs/esm-framework";
Basically, the idea is use import type ...
if everything is a type and import {type ...}
otherwise. This is primarily for aesthetics, i.e.,
import type { Type1, Type2, Type3, Type4 } from "./types";
Is (in my view) nicer than:
import {
type Type1,
type Type2,
type Type3,
type Type4,
} from "./types";
But also because of the transformation mentioned here (import {} from "./types"
might have side-effects that tsc
cannot reason about).
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.
Fair points, well-argued. Unfortunately, it doesn't seem like the rule's configuration options give us the desired flexibility.
FWIW, looking through the ESLint configs of popular projects, most use the defaults. I think inlined type imports look better than separate type imports, e.g.
I find this:
import { loadWebpackConfig, logInfo, logWarn, type ImportMapDeclaration } from '../utils';
Preferable to:
import type { ImportmapDeclaration } from '../utils';
import { loadWebpackConfig, logInfo, logWarn } from '../utils';
It boils down to relative aesthetics. Ultimately, I don't know what the preferred compromise is.
9ade952
to
20ac8a3
Compare
20ac8a3
to
f1d8002
Compare
Requirements
For changes to apps
If applicable
Summary
This PR tweaks our ESLint configuration, adding a rule consistent type imports and other useful TypeScript-related rules.
Related Issue
None
Other
None