Skip to content

Commit 4505339

Browse files
Update ESLint, migrate configuration file
1 parent 0577ffd commit 4505339

File tree

84 files changed

+1498
-1420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1498
-1420
lines changed

β€Ž.eslintignoreβ€Ž

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

β€Ž.eslintrc.jsonβ€Ž

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

β€Že2e/fixtures/data/attachment.mjsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable sort-keys */
1+
22
const smallImageAttachment = [
33
{
44
type: 'image',

β€Žeslint.config.mjsβ€Ž

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import tseslint from 'typescript-eslint';
4+
5+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
6+
import reactPlugin from 'eslint-plugin-react';
7+
import importPlugin from 'eslint-plugin-import';
8+
import jestPlugin from 'eslint-plugin-jest';
9+
import jestDOMPlugin from 'eslint-plugin-jest-dom';
10+
11+
export default tseslint.config(
12+
{
13+
ignores: ['dist', 'src/@types', '*.{js,ts}'],
14+
},
15+
{
16+
name: 'default',
17+
extends: [
18+
js.configs.recommended,
19+
...tseslint.configs.recommended,
20+
reactPlugin.configs.flat.recommended,
21+
],
22+
files: ['src/**/*.{js,ts,jsx,tsx}'],
23+
languageOptions: {
24+
ecmaVersion: 2020,
25+
globals: globals.browser,
26+
},
27+
plugins: {
28+
'react-hooks': reactHooksPlugin,
29+
import: importPlugin,
30+
},
31+
settings: {
32+
react: {
33+
version: 'detect',
34+
},
35+
},
36+
rules: {
37+
'array-callback-return': 'error',
38+
'arrow-body-style': 'error',
39+
'comma-dangle': 'off',
40+
'default-case': 'error',
41+
eqeqeq: ['error', 'smart'],
42+
'jsx-quotes': ['error', 'prefer-single'],
43+
'linebreak-style': ['error', 'unix'],
44+
'no-console': 'off',
45+
'no-mixed-spaces-and-tabs': 'warn',
46+
'no-self-compare': 'error',
47+
'no-underscore-dangle': ['error', { allowAfterThis: true }],
48+
'no-unused-vars': 'off',
49+
'@typescript-eslint/no-unused-vars': [
50+
'warn',
51+
{ ignoreRestSiblings: true, caughtErrors: 'none' },
52+
],
53+
'no-use-before-define': 'off',
54+
'no-useless-concat': 'error',
55+
'no-var': 'error',
56+
'object-shorthand': 'warn',
57+
'prefer-const': 'warn',
58+
'react/jsx-sort-props': [
59+
'error',
60+
{
61+
callbacksLast: false,
62+
ignoreCase: true,
63+
noSortAlphabetically: false,
64+
reservedFirst: false,
65+
shorthandFirst: false,
66+
shorthandLast: false,
67+
},
68+
],
69+
'react/prop-types': 'off',
70+
'require-await': 'error',
71+
semi: ['warn', 'always'],
72+
// TODO: find appropriate plugin for this rule
73+
// "sort-destructure-keys/sort-destructure-keys": [
74+
// "error",
75+
// { caseSensitive: false },
76+
// ],
77+
'sort-imports': [
78+
'error',
79+
{
80+
allowSeparatedGroups: true,
81+
ignoreCase: true,
82+
ignoreDeclarationSort: true,
83+
ignoreMemberSort: false,
84+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
85+
},
86+
],
87+
'sort-keys': ['error', 'asc', { caseSensitive: false, minKeys: 2, natural: false }],
88+
'valid-typeof': 'error',
89+
'import/prefer-default-export': 'off',
90+
'import/extensions': 'off',
91+
'import/no-extraneous-dependencies': [
92+
'error',
93+
{
94+
devDependencies: true, // TODO: set to false once React is in the dependencies (not devDependencies)
95+
optionalDependencies: false,
96+
peerDependencies: false,
97+
},
98+
],
99+
'max-classes-per-file': 'off',
100+
camelcase: 'off',
101+
'react-hooks/rules-of-hooks': 'warn',
102+
'react-hooks/exhaustive-deps': 'error',
103+
'no-unused-expressions': 'off',
104+
'@typescript-eslint/no-non-null-assertion': 'error',
105+
// TODO: remove this rule once all files are .mjs (and require is not used)
106+
'@typescript-eslint/no-require-imports': 'off',
107+
'react/react-in-jsx-scope': 'off',
108+
},
109+
},
110+
{
111+
name: 'jest',
112+
files: ['src/**/__tests__/**'],
113+
plugins: { jest: jestPlugin, 'jest-dom': jestDOMPlugin },
114+
languageOptions: {
115+
globals: jestPlugin.environments.globals.globals,
116+
},
117+
rules: {
118+
'jest/expect-expect': 'off',
119+
'jest/no-conditional-expect': 'off',
120+
'jest/prefer-inline-snapshots': 'off',
121+
'jest/lowercase-name': 'off',
122+
'jest/prefer-expect-assertions': 'off',
123+
'jest/no-hooks': 'off',
124+
'jest/no-if': 'off',
125+
'jest-dom/prefer-in-document': 'error',
126+
},
127+
},
128+
);

0 commit comments

Comments
Β (0)