UNPKG

5.25 kBJavaScriptView Raw
1module.exports = {
2 ignorePatterns: ['!.storybook', 'prettier.config.js'],
3 root: true,
4 extends: [
5 'airbnb',
6 'airbnb/hooks',
7 'plugin:prettier/recommended',
8 'prettier/react',
9 'plugin:cypress/recommended',
10 ],
11 parser: 'babel-eslint',
12 parserOptions: {
13 ecmaVersion: 2018,
14 sourceType: 'module',
15 ecmaFeatures: {
16 jsx: true,
17 },
18 },
19 settings: {
20 react: {
21 version: 'detect',
22 },
23 'import/resolver': {
24 node: {
25 extensions: ['.js', '.jsx', '.ts', '.tsx'],
26 },
27 },
28 },
29 env: {
30 browser: true,
31 commonjs: true,
32 es6: true,
33 jest: true,
34 node: true,
35 },
36 overrides: [
37 {
38 files: ['**/*.ts?(x)'],
39 plugins: ['@typescript-eslint'],
40 extends: [
41 'plugin:@typescript-eslint/eslint-recommended',
42 'prettier/@typescript-eslint',
43 'plugin:import/typescript',
44 ],
45 parser: '@typescript-eslint/parser',
46 parserOptions: {
47 warnOnUnsupportedTypeScriptVersion: true,
48 },
49 rules: {
50 // APIs are not camelCase
51 '@typescript-eslint/camelcase': 'off',
52 camelcase: 'off',
53 // Use TypeScript types instead
54 'react/prop-types': 'off',
55 // Fixes definition files imports
56 'spaced-comment': ['error', 'always', { markers: ['/'] }],
57 'react/jsx-filename-extension': ['error', { extensions: ['.tsx'] }],
58 // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
59 'no-unused-vars': 'off',
60 '@typescript-eslint/no-unused-vars': ['warn'],
61 // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
62 'no-unused-expressions': 'off',
63 '@typescript-eslint/no-unused-expressions': [
64 'error',
65 { allowShortCircuit: true },
66 ],
67 'react/destructuring-assignment': ['error', 'never'],
68 },
69 },
70 {
71 files: ['**/*.{spec,test}.{js,jsx,ts,tsx}'],
72 rules: {
73 'max-lines-per-function': 'off',
74 complexity: 'off',
75 'react/jsx-no-literals': 'off',
76 },
77 },
78 {
79 files: ['**/*.stories.{js,jsx,ts,tsx,mdx}'],
80 rules: {
81 'max-lines-per-function': 'off',
82 'react/jsx-no-literals': 'off',
83 },
84 },
85 ],
86 rules: {
87 // START :: DO NOT TOUCH THESE, these need to be in sync with `core-prettier`
88 'prettier/prettier': 'error',
89 curly: ['error', 'all'],
90 'lines-around-comment': [
91 'error',
92 {
93 // https://github.com/typescript-eslint/typescript-eslint/issues/1150
94 beforeBlockComment: false,
95 afterBlockComment: false,
96 // https://github.com/typescript-eslint/typescript-eslint/issues/1150
97 beforeLineComment: false,
98 afterLineComment: false,
99 allowBlockStart: true,
100 allowBlockEnd: false,
101 allowObjectStart: true,
102 allowObjectEnd: false,
103 allowArrayStart: true,
104 allowArrayEnd: false,
105 allowClassStart: true,
106 allowClassEnd: false,
107 },
108 ],
109 'max-len': [
110 'warn',
111 {
112 code: 80,
113 ignoreUrls: true,
114 ignoreStrings: true,
115 ignoreTemplateLiterals: true,
116 ignoreTrailingComments: true,
117 },
118 ],
119 'no-confusing-arrow': ['error', { allowParens: true }],
120 'no-mixed-operators': 'error',
121 'no-tabs': 'error',
122 'no-unexpected-multiline': 'error',
123 quotes: [
124 'error',
125 'single',
126 { avoidEscape: true, allowTemplateLiterals: false },
127 ],
128 // END :: DO NOT TOUCH THESE, these need to be in sync with `core-prettier`
129 'import/prefer-default-export': 'off',
130 'react/destructuring-assignment': ['warn', 'always'],
131 'react/require-default-props': 'off',
132 'react/jsx-no-literals': [
133 'error',
134 { noStrings: true, allowedStrings: [], ignoreProps: true },
135 ],
136 'import/no-extraneous-dependencies': [
137 'error',
138 {
139 devDependencies: [
140 '**/*.@(spec|test|story|stories).@(js|jsx|ts|tsx)',
141 '**/__tests__/**',
142 '**/.storybook/**',
143 '**/e2e/**',
144 ],
145 peerDependencies: true,
146 },
147 ],
148 'no-param-reassign': [
149 'error',
150 { props: true, ignorePropertyModificationsFor: ['self'] },
151 ],
152 'react/jsx-props-no-spreading': 'off',
153 'react/jsx-fragments': ['error', 'syntax'],
154 'import/no-unresolved': ['error', { ignore: ['^@'] }], // webpack alias for 'src' - from core-scripts
155 'import/extensions': [
156 'error',
157 'ignorePackages',
158 {
159 js: 'never',
160 mjs: 'never',
161 jsx: 'never',
162 tsx: 'never',
163 ts: 'never',
164 },
165 ],
166 'react-hooks/exhaustive-deps': 'warn',
167 'no-use-before-define': ['error', { functions: false }],
168 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
169 'no-unused-expressions': ['error', { allowShortCircuit: true }],
170 'max-lines-per-function': ['error', { max: 150, skipBlankLines: true }],
171 complexity: ['error', { max: 10 }],
172 'lines-between-class-members': [
173 'error',
174 'always',
175 {
176 exceptAfterSingleLine: true,
177 },
178 ],
179 },
180}