Skip to content

Commit c91defe

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

File tree

84 files changed

+1497
-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

+1497
-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: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
camelcase: 'off',
38+
semi: ['warn', 'always'],
39+
eqeqeq: ['error', 'smart'],
40+
'array-callback-return': 'error',
41+
'arrow-body-style': 'error',
42+
'comma-dangle': 'off',
43+
'default-case': 'error',
44+
'jsx-quotes': ['error', 'prefer-single'],
45+
'linebreak-style': ['error', 'unix'],
46+
'no-console': 'off',
47+
'no-mixed-spaces-and-tabs': 'warn',
48+
'no-self-compare': 'error',
49+
'no-underscore-dangle': ['error', { allowAfterThis: true }],
50+
'no-use-before-define': 'off',
51+
'no-useless-concat': 'error',
52+
'no-var': 'error',
53+
'object-shorthand': 'warn',
54+
'prefer-const': 'warn',
55+
'require-await': 'error',
56+
// TODO: find appropriate plugin for this rule
57+
// "sort-destructure-keys/sort-destructure-keys": [
58+
// "error",
59+
// { caseSensitive: false },
60+
// ],
61+
'sort-imports': [
62+
'error',
63+
{
64+
allowSeparatedGroups: true,
65+
ignoreCase: true,
66+
ignoreDeclarationSort: true,
67+
ignoreMemberSort: false,
68+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
69+
},
70+
],
71+
'sort-keys': ['error', 'asc', { caseSensitive: false, minKeys: 2, natural: false }],
72+
'valid-typeof': 'error',
73+
'max-classes-per-file': 'off',
74+
'no-unused-expressions': 'off',
75+
'no-unused-vars': 'off',
76+
'import/prefer-default-export': 'off',
77+
'import/extensions': 'off',
78+
'import/no-extraneous-dependencies': [
79+
'error',
80+
{
81+
devDependencies: true, // TODO: set to false once React is in the dependencies (not devDependencies)
82+
optionalDependencies: false,
83+
peerDependencies: false,
84+
},
85+
],
86+
'@typescript-eslint/no-unused-vars': [
87+
'warn',
88+
{ ignoreRestSiblings: true, caughtErrors: 'none' },
89+
],
90+
'@typescript-eslint/no-non-null-assertion': 'error',
91+
'@typescript-eslint/no-require-imports': 'off', // TODO: remove this rule once all files are .mjs (and require is not used)
92+
'react/prop-types': 'off',
93+
'react/react-in-jsx-scope': 'off',
94+
'react/jsx-sort-props': [
95+
'error',
96+
{
97+
callbacksLast: false,
98+
ignoreCase: true,
99+
noSortAlphabetically: false,
100+
reservedFirst: false,
101+
shorthandFirst: false,
102+
shorthandLast: false,
103+
},
104+
],
105+
'react-hooks/rules-of-hooks': 'warn',
106+
'react-hooks/exhaustive-deps': 'error',
107+
},
108+
},
109+
{
110+
name: 'jest',
111+
files: ['src/**/__tests__/**'],
112+
plugins: { jest: jestPlugin, 'jest-dom': jestDOMPlugin },
113+
languageOptions: {
114+
globals: jestPlugin.environments.globals.globals,
115+
},
116+
rules: {
117+
'jest/expect-expect': 'off',
118+
'jest/no-conditional-expect': 'off',
119+
'jest/prefer-inline-snapshots': 'off',
120+
'jest/lowercase-name': 'off',
121+
'jest/prefer-expect-assertions': 'off',
122+
'jest/no-hooks': 'off',
123+
'jest/no-if': 'off',
124+
'jest-dom/prefer-in-document': 'error',
125+
},
126+
},
127+
);

0 commit comments

Comments
Β (0)