UNPKG

4.83 kBJavaScriptView Raw
1module.exports = {
2 ignorePatterns: ['!.storybook'],
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 },
76 },
77 ],
78 rules: {
79 // START :: DO NOT TOUCH THESE, these need to be in sync with `core-prettier`
80 'prettier/prettier': 'error',
81 curly: ['error', 'all'],
82 'lines-around-comment': [
83 'error',
84 {
85 // https://github.com/typescript-eslint/typescript-eslint/issues/1150
86 beforeBlockComment: false,
87 afterBlockComment: false,
88 // https://github.com/typescript-eslint/typescript-eslint/issues/1150
89 beforeLineComment: false,
90 afterLineComment: false,
91 allowBlockStart: true,
92 allowBlockEnd: false,
93 allowObjectStart: true,
94 allowObjectEnd: false,
95 allowArrayStart: true,
96 allowArrayEnd: false,
97 allowClassStart: true,
98 allowClassEnd: false,
99 },
100 ],
101 'max-len': [
102 'warn',
103 {
104 code: 80,
105 ignoreUrls: true,
106 ignoreStrings: true,
107 ignoreTemplateLiterals: true,
108 ignoreTrailingComments: true,
109 },
110 ],
111 'no-confusing-arrow': ['error', { allowParens: true }],
112 'no-mixed-operators': 'error',
113 'no-tabs': 'error',
114 'no-unexpected-multiline': 'error',
115 quotes: [
116 'error',
117 'single',
118 { avoidEscape: true, allowTemplateLiterals: false },
119 ],
120 // END :: DO NOT TOUCH THESE, these need to be in sync with `core-prettier`
121 'import/prefer-default-export': 'off',
122 'react/destructuring-assignment': ['error', 'always'],
123 'import/no-extraneous-dependencies': [
124 'error',
125 {
126 devDependencies: [
127 '**/*.@(spec|test|story|stories).@(js|jsx|ts|tsx)',
128 '**/__tests__/**',
129 '**/.storybook/**',
130 '**/e2e/**',
131 ],
132 peerDependencies: true,
133 },
134 ],
135 'no-param-reassign': [
136 'error',
137 { props: true, ignorePropertyModificationsFor: ['self'] },
138 ],
139 'react/jsx-props-no-spreading': 'off',
140 'react/jsx-fragments': ['error', 'syntax'],
141 'import/no-unresolved': ['error', { ignore: ['^@'] }], // webpack alias for 'src' - from core-scripts
142 'import/extensions': [
143 'error',
144 'ignorePackages',
145 {
146 js: 'never',
147 mjs: 'never',
148 jsx: 'never',
149 tsx: 'never',
150 ts: 'never',
151 },
152 ],
153 'react-hooks/exhaustive-deps': 'off',
154 'no-use-before-define': ['error', { functions: false }],
155 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
156 'no-unused-expressions': ['error', { allowShortCircuit: true }],
157 'max-lines-per-function': ['error', { max: 150 }],
158 complexity: ['error', { max: 10 }],
159 'lines-between-class-members': [
160 'error',
161 'always',
162 {
163 exceptAfterSingleLine: true,
164 },
165 ],
166 },
167}