generated from ivstudio/react-typescript-tailwindcss-webpack5-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.mjs
127 lines (126 loc) · 4.27 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import pluginJs from '@eslint/js';
import eslintConfigPrettier from 'eslint-config-prettier';
import pluginReact from 'eslint-plugin-react';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import tailwind from 'eslint-plugin-tailwindcss';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default [
{
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
ignores: [
'.config/*',
'webpack/*',
'dist/*',
'coverage/*',
'node_modules',
],
},
{
languageOptions: { globals: globals.browser },
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
...tailwind.configs['flat/recommended'],
eslintConfigPrettier,
{
plugins: {
'simple-import-sort': simpleImportSort,
},
settings: {
tailwindcss: {
// These are the default values but feel free to customize
callees: ['classnames', 'clsx', 'ctl'],
config: 'tailwind.config.js', // returned from `loadConfig()` utility if not provided
cssFiles: [
'**/*.css',
'!**/node_modules',
'!**/.*',
'!**/dist',
'!**/build',
],
cssFilesRefreshRate: 5_000,
removeDuplicates: true,
skipClassAttribute: false,
whitelist: [],
tags: [], // can be set to e.g. ['tw'] for use in tw`bg-blue`
classRegex: '^class(Name)?$', // can be modified to support custom attributes. E.g. "^tw$" for `twin.macro`
},
},
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
['^react'],
// third-party imports
['^@?\\w'],
// absolute imports
['^'],
// relative imports
['^\\.'],
// styles and types
['^(styles|types)(/.*|$)'],
// CSS imports
['^.+\\.css$'],
],
},
],
},
},
{
settings: {
react: {
version: 'detect',
},
},
rules: {
'no-duplicate-imports': 'error',
'no-redeclare': 'error',
'react/prefer-stateless-function': 'error',
'react/no-unused-prop-types': 'error',
'react/jsx-pascal-case': 'error',
'react/jsx-no-script-url': 'error',
'react/no-children-prop': 'error',
'react/no-danger': 'error',
'react/no-danger-with-children': 'error',
'react/no-unstable-nested-components': [
'error',
{ allowAsProps: true },
],
'react/jsx-fragments': 'error',
'react/destructuring-assignment': [
'error',
'always',
{ destructureInSignature: 'always' },
],
'react/jsx-no-leaked-render': [
'error',
{ validStrategies: ['ternary'] },
],
'react/jsx-max-depth': ['error', { max: 5 }],
'react/function-component-definition': [
'warn',
{ namedComponents: 'arrow-function' },
],
'react/jsx-key': [
'error',
{
checkFragmentShorthand: true,
checkKeyMustBeforeSpread: true,
warnOnDuplicates: true,
},
],
'react/jsx-no-useless-fragment': 'warn',
'react/jsx-curly-brace-presence': 'warn',
'react/no-typos': 'warn',
'react/display-name': 'warn',
'react/self-closing-comp': 'warn',
'react/jsx-sort-props': 'warn',
'react/react-in-jsx-scope': 'off',
'react/jsx-one-expression-per-line': 'off',
'react/prop-types': 'off',
},
},
];