-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheslint.config.mjs
100 lines (95 loc) · 3.03 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import pluginJs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import jsxA11y from 'eslint-plugin-jsx-a11y';
import pluginReact from 'eslint-plugin-react';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import vitest from 'eslint-plugin-vitest';
import globals from 'globals';
import tseslint from 'typescript-eslint';
const OFF = 0;
const WARNING = 1;
const ERROR = 2;
export default [
{
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
settings: {
react: {
version: 'detect',
},
},
plugins: {
vitest,
'simple-import-sort': simpleImportSort,
},
languageOptions: { globals: globals.browser },
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
jsxA11y.flatConfigs.recommended,
importPlugin.flatConfigs.recommended,
eslintConfigPrettier,
{
rules: {
...vitest.configs.recommended.rules,
'max-len': [ERROR, 160],
'no-console': WARNING,
'no-debugger': WARNING,
'react/function-component-definition': [
'error',
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],
'react/prop-types': OFF,
'jsx-a11y/no-autofocus': OFF,
'react/react-in-jsx-scope': OFF,
'import/no-unresolved': OFF,
'import/named': OFF,
'import/no-duplicates': ERROR,
'@typescript-eslint/no-restricted-types': [
'error',
{
types: {
'React.FC': {
message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
},
FC: {
message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
},
'React.FunctionComponent': {
message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
},
FunctionComponent: {
message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
},
},
},
],
// Note: you must disable the base rule as it can report incorrect errors
'no-use-before-define': OFF,
'@typescript-eslint/no-use-before-define': [ERROR],
'no-shadow': OFF,
'@typescript-eslint/no-shadow': [ERROR],
'no-unused-vars': OFF,
'@typescript-eslint/no-unused-vars': [ERROR],
// TODO (TOR) Ignorert inntil videre grunnet kost/nytte
'@typescript-eslint/no-explicit-any': OFF,
'@typescript-eslint/ban-ts-comment': OFF,
'simple-import-sort/imports': [
'error',
{
groups: [['^react'], ['^@?\\w'], ['^@navikt/ft-*'], ['@/(.*)'], ['^[./]'], ['./*.module.css'], ['./*.json']],
},
],
},
},
{
ignores: ['**/*.stories.tsx', 'eslint.config.mjs'],
rules: {
'import/no-default-export': ERROR,
},
},
];