Suggested improvements for version 2 #31
filiptammergard
started this conversation in
Ideas
Replies: 2 comments
-
Comments and additions:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Amazing job compiling this list! Agree with almost every suggestion here, and glad to see many of these rules being enabled again. Will take a closer look next week! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suggested improvements for version 2
Currently extended configs and plugins
Suggested rule changes
We are disabling several rules. Some of them are disabled for good reasons and should remain disabled. Others are good rules that probably should be enabled, but are disabled for legacy reasons, to not have to do too many fixes when the eslint-config-airbnb was extended for example. Some of these rules should be enabled to ensure we're following good practices in our new projects.
A general suggestion is to avoid using warnings. Either error or disabled, to prevent warnings from piling up.
prefer-template
Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.
@typescript-eslint/no-explicit-any
Currently disabled. Is a warning in @typescript-eslint/eslint-plugin/recommended. Suggestion is to make it an error.
@typescript-eslint/no-non-null-assertion
Currently disabled. Suggestion is to remove disable, which will make it an error as in @typescript-eslint/eslint-plugin/recommended.
jsx-a11y/anchor-is-valid
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb.
no-else-return
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.
no-restricted-globals
Currently disabled.
isNaN
andisFinite
are broken but remain for legacy reasons.Number.isNaN
andNumber.isFinite
should be used instead. Some browser globals commonly cause confusion and are not recommended to use without an explicitwindow-
qualifier. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.no-shadow
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.
object-shorthand
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.
prefer-destructuring
Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.
react/no-array-index-key
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb.
react/jsx-boolean-value
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb.
react/jsx-key
Currently warning. Suggestion is to make it an error.
react/jsx-filename-extension
Currently warning and
.js
,.jsx
and.tsx
are allowed JSX file extensions. Suggestion is to only allow.tsx
, since we're exclusively using TypeScript in our React projects. Make it an error instead of warning.@typescript-eslint/no-unused-vars
Currently disabled. Suggestion is to either remove it, which will make it a warning as in @typescript-eslint/eslint-plugin/recommended, or to make it an error. If
"noUnusedLocals": true
intsconfig.json
, unused variables will be a ts warning. But we're using the default"noUnusedLocals": false
in most projects. And better to use ESLint for linting than tsconfig IMO.consistent-return
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base.
default-case
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base, where either an empty
default:
or a// no default
comment satisfies the rule. Omittingdefault
should be done explicitly to make the developer's intention clear.no-restricted-syntax
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb/base, where for...in, for...of, loop labels and with statements are errors for these reasons.
react/jsx-curly-brace-presence
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb.
react/jsx-one-expression-per-line
Currently disabled. Suggestion is to remove disable, which will make it an error as in eslint-config-airbnb.
react/jsx-wrap-multilines
Currently disabled. Suggestion is to remove disabled, which will make it an error as in eslint-config-airbnb.
Suggested architectural improvements
React 17
With React 17, react/react-in-jsx-scope and react/jsx-uses-react should be disabled (but enabled with React 16). Possible solutions:
default
config, we could split it up in onerecommended
config (with the rules disabled and onereact16
config (with the rules enabled).Development workflow
Some of these rules impair development workflow, when the app breaks if one variable isn't currently used for example when you're trying something out. Do we want to adopt some kind of workflow where some ESLint errors are OK during development, but pushes are rejected? Other ideas?
Dependencies
prettier
be a dependency in a ESLint plugin, or rather a peerDependency? If we wantprettier
as a dependency, should we also include a default.prettierrc
that can be extended/overwritten? Use fixedprettier
version.@typescript-eslint/explicit-function-return-type and @typescript-eslint/no-use-before-define
Currently disabled (and should be IMO). But the rules are not enabled in @typescript-eslint/eslint-plugin/recommended that we're extending, so they can be removed from our plugin without any actual change.
no-undef
Currently disabled. It's an error in eslint-config-airbnb/base but disabled in @typescript-eslint/eslint-plugin/recommended which comes later in the
extends
array. Therefore, we could remove it from our plugin without any actual change.import/resolver
Currently,
.js
,.jsx
,.ts
and.tsx
will be parsed as modules and inspected for exports. Suggestion is to change to.ts
and.tsx
, since we're exclusively using TypeScript in our React projects."jest/globals": true
"jest/globals": true
is included through eslint-plugin-jest/recommended and can be removed without any actual change.Beta Was this translation helpful? Give feedback.
All reactions