1const { jsExtensions } = require('./extensions');
2
3module.exports = {
4  parserOptions: {
5    sourceType: 'module',
6    ecmaVersion: 2022,
7    ecmaFeatures: { impliedStrict: true, jsx: true },
8  },
9  env: { es2022: true, jest: true },
10  globals: {
11    console: false,
12    exports: false,
13    global: false,
14    module: false,
15    require: false,
16  },
17  plugins: ['import', 'node'],
18  rules: {
19    'array-bracket-spacing': ['warn', 'never'],
20    'arrow-spacing': ['warn', { before: true, after: true }],
21    curly: ['warn', 'all'],
22    'block-spacing': ['warn', 'always'],
23    'comma-dangle': ['warn', 'always-multiline'],
24    'comma-spacing': ['warn', { before: false, after: true }],
25    'comma-style': ['warn', 'last'],
26    'computed-property-spacing': ['warn', 'never'],
27    'constructor-super': 'warn',
28    'dot-location': ['warn', 'property'],
29    'eol-last': 'warn',
30    eqeqeq: ['warn', 'smart'],
31    'func-call-spacing': ['warn', 'never'],
32    'generator-star-spacing': ['warn', 'after'],
33    'getter-return': 'warn',
34    'jsx-quotes': ['warn', 'prefer-double'],
35    'new-parens': 'warn',
36    'no-alert': 'off',
37    'no-array-constructor': 'warn',
38    'no-caller': 'warn',
39    'no-case-declarations': 'warn',
40    'no-compare-neg-zero': 'warn',
41    'no-cond-assign': 'warn',
42    'no-const-assign': 'error',
43    'no-constant-condition': ['warn', { checkLoops: false }],
44    'no-control-regex': 'off',
45    'no-debugger': 'warn',
46    'no-delete-var': 'error',
47    'no-dupe-args': 'error',
48    'no-dupe-class-members': 'error',
49    'no-dupe-keys': 'error',
50    'no-duplicate-case': 'error',
51    'no-empty-character-class': 'warn',
52    'no-empty-pattern': 'warn',
53    'no-eval': 'warn',
54    'no-ex-assign': 'warn',
55    'no-extend-native': 'warn',
56    'no-extra-bind': 'warn',
57    'no-extra-boolean-cast': 'warn',
58    'no-extra-semi': 'warn',
59    'no-fallthrough': 'warn',
60    'no-floating-decimal': 'warn',
61    'no-func-assign': 'error',
62    'no-global-assign': 'warn',
63    'no-implied-eval': 'warn',
64    'no-inner-declarations': 'warn',
65    'no-invalid-regexp': 'error',
66    'no-irregular-whitespace': 'warn',
67    'no-iterator': 'warn',
68    'no-label-var': 'warn',
69    'no-labels': ['warn', { allowLoop: true, allowSwitch: true }],
70    'no-lone-blocks': 'warn',
71    'no-multi-assign': 'warn',
72    'no-new': 'warn',
73    'no-new-func': 'warn',
74    'no-new-object': 'warn',
75    'no-new-symbol': 'error',
76    'no-obj-calls': 'warn',
77    'no-octal': 'warn',
78    'no-octal-escape': 'warn',
79    'no-mixed-spaces-and-tabs': 'warn',
80    'no-proto': 'warn',
81    'no-redeclare': 'warn',
82    'no-return-assign': 'warn',
83    'no-script-url': 'warn',
84    'no-self-assign': 'warn',
85    'no-self-compare': 'warn',
86    'no-sequences': 'warn',
87    'no-shadow-restricted-names': 'warn',
88    'no-sparse-arrays': 'warn',
89    'no-this-before-super': 'warn',
90    'no-throw-literal': 'warn',
91    'no-trailing-spaces': 'warn',
92    'no-undef': 'error',
93    'no-unexpected-multiline': 'warn',
94    'no-unneeded-ternary': 'warn',
95    'no-unreachable': 'warn',
96    'no-unsafe-negation': 'warn',
97    'no-unused-expressions': ['warn', { allowShortCircuit: true, enforceForJSX: true }],
98    'no-unused-labels': 'warn',
99    'no-unused-vars': [
100      'warn',
101      {
102        vars: 'all',
103        args: 'none',
104        ignoreRestSiblings: true,
105        caughtErrors: 'all',
106        caughtErrorsIgnorePattern: '^_',
107      },
108    ],
109    'no-useless-computed-key': 'warn',
110    'no-useless-concat': 'warn',
111    'no-useless-constructor': 'warn',
112    'no-useless-escape': 'warn',
113    'no-useless-rename': 'warn',
114    'no-useless-return': 'warn',
115    'no-var': 'warn',
116    'no-void': 'warn',
117    'no-whitespace-before-property': 'warn',
118    'no-with': 'warn',
119    'object-shorthand': 'warn',
120    'operator-linebreak': ['warn', 'after', { overrides: { '?': 'before', ':': 'before' } }],
121    'prefer-const': ['warn', { destructuring: 'all', ignoreReadBeforeAssign: true }],
122    'prefer-promise-reject-errors': 'warn',
123    'prefer-rest-params': 'warn',
124    'prefer-spread': 'warn',
125    radix: 'warn',
126    'rest-spread-spacing': ['warn', 'never'],
127    semi: 'warn',
128    'semi-spacing': ['warn', { before: false, after: true }],
129    'semi-style': ['warn', 'last'],
130    'space-before-blocks': ['warn', 'always'],
131    'space-before-function-paren': ['warn', { anonymous: 'never', named: 'never' }],
132    'space-in-parens': ['warn', 'never'],
133    'space-infix-ops': 'warn',
134    'switch-colon-spacing': ['warn', { before: false, after: true }],
135    'template-curly-spacing': ['warn', 'never'],
136    'template-tag-spacing': ['warn', 'never'],
137    'unicode-bom': ['warn', 'never'],
138    'use-isnan': 'error',
139    'valid-typeof': 'error',
140    'yield-star-spacing': ['warn', 'after'],
141    yoda: ['warn', 'never', { exceptRange: true }],
142
143    'import/default': 'off',
144    'import/export': 'error',
145    'import/first': 'warn',
146    'import/namespace': ['error', { allowComputed: true }],
147    'import/no-duplicates': 'error',
148    'import/order': [
149      'warn',
150      {
151        groups: [['builtin', 'external'], 'internal', ['parent', 'index', 'sibling']],
152        'newlines-between': 'always',
153        alphabetize: {
154          order: 'asc',
155        },
156      },
157    ],
158
159    'node/handle-callback-err': ['warn', '^(e|err|error|.+Error)$'],
160    'node/no-new-require': 'warn',
161  },
162  settings: {
163    'import/extensions': jsExtensions,
164    'import/ignore': [
165      // react-native's main module is Flow, not JavaScript, and raises parse errors. Additionally,
166      // several other react-native-related packages still publish Flow code as their main source.
167      'node_modules[\\\\/]+@?react-native',
168    ],
169    'import/resolver': {
170      node: { extensions: jsExtensions },
171    },
172  },
173  overrides: [
174    {
175      files: ['*.d.ts'],
176      rules: {
177        'import/order': 'off',
178      },
179    },
180  ],
181};
182