Skip to content

Commit

Permalink
Eslint config migration (#756)
Browse files Browse the repository at this point in the history
* init eslint config

* fix common problems and remove rules requiring React to be in scope (we're React version > 17)

* relax use of explicit any for eslint for migration purposes

* fix additional miscelaneous errors

* add prettier and jsxA11y eslint plugins to our new config

* remove old eslint configs from package.json

* remove old unused dev dependencies include ts-jest (we don't use jest anymore)

* migrate vitest to version > 2

* enable strict and stylistic typescript-eslint configs
  • Loading branch information
dpgraham4401 authored Jul 31, 2024
1 parent 810e59c commit 1990dc0
Show file tree
Hide file tree
Showing 81 changed files with 1,485 additions and 4,300 deletions.
15 changes: 0 additions & 15 deletions .idea/runConfigurations/enviroPro.xml

This file was deleted.

5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ repos:
- python
pass_filenames: false
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v8.56.0'
rev: 'v9.8.0'
hooks:
- id: eslint
files: \.[jt]sx?$
files: ^client/.*\.[jt]sx?$
args: [-c=client/eslint.config.js]
types: [file]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v3.1.0'
Expand Down
2 changes: 2 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
tsconfig.tsbuildinfo
.next
next-env.d.ts
62 changes: 62 additions & 0 deletions client/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import reactPlugin from 'eslint-plugin-react'; // https://github.com/jsx-eslint/eslint-plugin-react?tab=readme-ov-file#configuration
import globals from 'globals';
import pluginJs from '@eslint/js';
import tsEslint from 'typescript-eslint';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default [
// ToDo: eslint-plugin-react-hooks does not yet support eslint > 9 and this config
pluginJs.configs.recommended,
jsxA11y.flatConfigs.recommended,
// ...tseslint.configs.recommended, // recommended config is overridden by strict/stylistic
...tsEslint.configs.strict,
...tsEslint.configs.stylistic,
eslintPluginPrettierRecommended,
{
name: 'ignore-outputs',
ignores: ['**/build/', '**/dist/', '**/node_modules/', '**/.next/'],
},
{
name: 'react',
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
...reactPlugin.configs.flat.recommended,
languageOptions: {
...reactPlugin.configs.flat.recommended.languageOptions,
globals: globals.browser,
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
rules: {
'react/react-in-jsx-scope': 0,
'react/jsx-uses-react': 0,
},
},
{
name: 'ts-migration-relax',
files: ['**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
{
name: 'ts-unused-vars',
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
// ignoreRestSiblings: true, - if you want to ignore unused rest siblings
},
],
},
},
];
Loading

0 comments on commit 1990dc0

Please sign in to comment.