Skip to content

Commit 2235520

Browse files
committed
eslint fixes after upgrade
1 parent 37f9bc7 commit 2235520

36 files changed

Lines changed: 198 additions & 120 deletions

.eslintrc.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import js from '@eslint/js'
2+
import parser from '@typescript-eslint/parser'
3+
import plugin from '@typescript-eslint/eslint-plugin'
4+
import react from 'eslint-plugin-react'
5+
import reactRedux from 'eslint-plugin-react-redux'
6+
import prettier from 'eslint-plugin-prettier'
7+
8+
export default [
9+
js.configs.recommended,
10+
{
11+
ignores: [
12+
'node_modules',
13+
'build',
14+
'tmp'
15+
],
16+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
17+
languageOptions: {
18+
parser,
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
sourceType: 'module',
22+
ecmaFeatures: {
23+
jsx: true,
24+
},
25+
},
26+
globals: {
27+
jest: true
28+
},
29+
},
30+
plugins: {
31+
react,
32+
'react-redux': reactRedux,
33+
'@typescript-eslint': plugin,
34+
prettier,
35+
},
36+
rules: {
37+
// ESLint core
38+
'object-shorthand': ['error', 'always'],
39+
'no-array-constructor': 'off',
40+
'no-redeclare': 'off',
41+
'no-use-before-define': 'off',
42+
'no-unused-expressions': 'off',
43+
'no-unused-vars': 'off',
44+
'no-useless-constructor': 'off',
45+
semi: ['warn', 'never'],
46+
47+
// React
48+
'react/prop-types': 'off',
49+
'react/no-unused-prop-types': 'off',
50+
51+
// React Redux
52+
'react-redux/useSelector-prefer-selectors': 'off',
53+
'react-redux/no-unused-prop-types': 'warn',
54+
'react-redux/prefer-separate-component-file': 'off',
55+
56+
// TypeScript overrides
57+
...plugin.configs.recommended.rules,
58+
...prettier.configs.recommended.rules,
59+
'@typescript-eslint/consistent-type-assertions': 'warn',
60+
'@typescript-eslint/no-array-constructor': 'warn',
61+
'@typescript-eslint/no-redeclare': 'warn',
62+
'@typescript-eslint/no-use-before-define': [
63+
'warn',
64+
{
65+
functions: false,
66+
classes: false,
67+
variables: false,
68+
typedefs: false,
69+
},
70+
],
71+
'@typescript-eslint/no-unused-expressions': [
72+
'error',
73+
{
74+
allowShortCircuit: true,
75+
allowTernary: true,
76+
allowTaggedTemplates: true,
77+
},
78+
],
79+
'@typescript-eslint/no-unused-vars': [
80+
'warn',
81+
{
82+
args: 'none',
83+
ignoreRestSiblings: true,
84+
},
85+
],
86+
'@typescript-eslint/no-useless-constructor': 'warn',
87+
88+
// Prettier
89+
'prettier/prettier': 'error',
90+
},
91+
settings: {
92+
react: {
93+
createClass: 'createReactClass',
94+
pragma: 'React',
95+
fragment: 'Fragment',
96+
version: 'detect',
97+
flowVersion: '0.53',
98+
},
99+
propWrapperFunctions: [
100+
'forbidExtraProps',
101+
{ property: 'freeze', object: 'Object' },
102+
{ property: 'myFavoriteWrapper' },
103+
{ property: 'forbidExtraProps', exact: true },
104+
],
105+
componentWrapperFunctions: [
106+
'observer',
107+
{ property: 'styled' },
108+
{ property: 'observer', object: 'Mobx' },
109+
{ property: 'observer', object: '<pragma>' },
110+
],
111+
formComponents: ['CustomForm', { name: 'Form', formAttribute: 'endpoint' }],
112+
linkComponents: ['Hyperlink', { name: 'Link', linkAttribute: 'to' }],
113+
},
114+
},
115+
{
116+
// Test files
117+
files: ['**/*.spec.js', '**/*.spec.ts', '**/*.test.ts', '**/*.spec.tsx', '**/*.test.tsx'],
118+
languageOptions: {
119+
globals: {
120+
describe: true,
121+
it: true,
122+
test: true,
123+
expect: true,
124+
beforeEach: true,
125+
afterEach: true,
126+
beforeAll: true,
127+
afterAll: true,
128+
jest: true,
129+
},
130+
},
131+
},
132+
]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
"preview": "vite preview",
8686
"deploy": "gh-pages -d build",
8787
"test": "jest",
88-
"lint": "eslint --fix --ext .js --ignore-path .gitignore src",
89-
"lint-ci": "eslint --ext .js --ignore-path .gitignore src"
88+
"lint": "eslint --fix --ext .js src",
89+
"lint-ci": "eslint --ext .js src"
9090
},
9191
"browserslist": [
9292
">0.2%",

src/common/Graph.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ export const edgeKey = (node1, node2) => {
4141
export default class Graph {
4242
constructor() {
4343
this.nodeMap = {}
44-
// eslint-disable-next-line no-undef
44+
4545
this.nodeKeys = new Set()
4646

4747
this.adjacencyList = {}
4848
this.edgeMap = {}
4949

50-
// eslint-disable-next-line no-undef
5150
this.edgeKeys = new Set()
5251
this.clearCachedPaths()
5352
}

src/common/debugging.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global console */
2+
13
import { compact } from "lodash"
24

35
// set to true to enable console logging

src/common/hooks/useKeyPress.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global window */
2+
13
import { useState, useEffect } from "react"
24

35
const useKeyPress = (targetKey, inputRef) => {

src/common/localStorage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global localStorage, console */
2+
13
// if you want to save a multiple temporary states, use these keys. The first time
24
// you save a new state, change persistSaveKey. Make a change, then change
35
// persistLoadKey to the same value. These keys are obsolete now
@@ -12,7 +14,7 @@ export const loadState = (key = persistLoadKey) => {
1214
return undefined
1315
}
1416
return JSON.parse(serializedState)
15-
} catch (err) {
17+
} catch {
1618
return undefined
1719
}
1820
}

src/common/util.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
/* global document, Blob, window, URL */
2+
13
import { keyBy, compact } from "lodash"
24

35
export const difference = (a, b) => {
4-
// eslint-disable-next-line no-undef
56
return new Set([
67
...[...a].filter((x) => !b.has(x)),
78
...[...b].filter((x) => !a.has(x)),

src/components/DropdownOption.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global document */
2+
13
import React from "react"
24
import Col from "react-bootstrap/Col"
35
import Row from "react-bootstrap/Row"

src/features/app/App.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global it, document */
2+
13
import React from "react"
24
import { createRoot } from "react-dom/client"
35
import App from "./App"

0 commit comments

Comments
 (0)