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.
Enabling linting on a large codebase such as Frame which has never really been linted is always going to be a slow process, especially where we have a mixture of JS and TS and have to rely on a lot of substandard typing to make things work.
With this PR we are enabling linting but not fixing all the issues which arise. The bare config with recommended settings for all plugins produced over 4000 issues. After a fair bit of configuration and some exemptions this is in the low 2000s and fixing all the test issues should get us significantly under 2000. Fixing all the issues in one go is risky -- linting fixes often result in refactoring which comes with its own risks (would like to avoid refactoring or making large changes the closer we get to the omni release) so this PR focusses on the obvious, low-hanging fruit in
app
/main
/resources
and everything intest
.Once all issues are handled in some way we can enable a linting check on CI and git pre-push. In the meantime we get the benefit of linting inside VS Code using the Eslint plugin, which can help to influence the development of new code before we arrive at the magical zero issues. It may also help with debugging, I have already identified a few issues which are likely to cause bugs.
Plan for Fixing Issues
This PR mainly deals with issues which arise in the tests (separated out into a few sub-PRs for ease of review)
I expect a large number of issues will be fixed with the signers refactor, additionally a lot of typescript related errors will be fixed when we have types for the store, nebula, etc.
Config
Recommended settings for eslint itself and all plugins below
eslint-config-prettier
- configures eslint to play nicely with prettierWe have two overrides sections, one for TS and one for tests. As we move more code over to TS the base config should get smaller.
Plugins
@typescript-eslint/eslint-plugin
- flags TS issues, especially around type safetyeslint-plugin-import
- flags issues with imports and requireseslint-plugin-jest
- flags antipatterns in our testseslint-plugin-jsx-a11y
- required as part of the react plugin for effective JSX linting. Includes a lot of accessibility rules which we might want to turn off for noweslint-plugin-n
- community takeover of the hugely popular but abandonedeslint-plugin-node
, will eventually move to the eslint-community org. Reports issues with nodeJS usageeslint-plugin-promise
- flags potential misuse of promises and antipatterns around their usageeslint-plugin-react
- flags antipatterns in React usageeslint-plugin-react-hooks
- prevents against misuse of hooks in Reacteslint-plugin-testing-library
- Helpful tips on how to get the most out oftesting-library
Note we are not running
eslint-plugin-prettier
-- running prettier as an eslint plugin is unperformant and not recommended. Additionally, having separate formatting and linting commands makes for a more stable and debuggable toolchain.Switching off Rules
Where possible we should switch off rules only as a last resort. Many rules can be configured to work around common usecases which can be considered exceptions.
You can turn off rules for a given file using
/* eslint-disable rule1,rule2,rule3 */
at the top of the file - this is better than disabling eslint entirely for a given line or whole file. Any rules turned off in this manner should have an accompanying comment to explain why, and under what circumstances the rules can be re-enabled. If there are no likely near future circumstances under which rules will be re-enabled, the rule(s) should be disabled in the.eslintrc
config file.