| | |
| | |
| | |
| | const config = { |
| | extends: [ |
| | 'algolia', |
| | 'algolia/jest', |
| | 'algolia/react', |
| | 'algolia/typescript', |
| | 'plugin:react-hooks/recommended', |
| | ], |
| | globals: { |
| | __DEV__: false, |
| | }, |
| | settings: { |
| | react: { |
| | version: 'detect', |
| | }, |
| | 'import/resolver': { |
| | node: { |
| | |
| | |
| | |
| | extensions: ['.js', '.ts', '.tsx'], |
| | }, |
| | }, |
| | }, |
| | rules: { |
| | 'no-param-reassign': 'off', |
| | |
| | 'no-use-before-define': 'off', |
| | |
| | 'valid-jsdoc': 'off', |
| | |
| | '@typescript-eslint/explicit-member-accessibility': 'off', |
| | |
| | '@typescript-eslint/consistent-type-assertions': 'off', |
| | '@typescript-eslint/consistent-type-imports': 'error', |
| | |
| | |
| | |
| | 'import/no-extraneous-dependencies': 'off', |
| | '@typescript-eslint/explicit-member-accessibility': ['off'], |
| | '@typescript-eslint/naming-convention': [ |
| | 'error', |
| | { |
| | selector: 'variable', |
| | modifiers: ['destructured'], |
| | format: null, |
| | }, |
| | { |
| | selector: 'variable', |
| | format: ['camelCase', 'PascalCase', 'UPPER_CASE'], |
| | leadingUnderscore: 'allow', |
| | filter: { |
| | regex: |
| | '^EXPERIMENTAL_|__DEV__|__APP_INITIAL_STATE__|__SERVER_STATE__|free_shipping', |
| | match: false, |
| | }, |
| | }, |
| | { |
| | selector: 'typeParameter', |
| | format: ['PascalCase'], |
| | prefix: ['T', 'K'], |
| | }, |
| | { |
| | selector: 'interface', |
| | format: ['PascalCase'], |
| | custom: { |
| | regex: '^I[A-Z]', |
| | match: false, |
| | }, |
| | }, |
| | ], |
| | 'import/extensions': 'off', |
| | 'eslint-comments/disable-enable-pair': 'off', |
| | 'react/jsx-no-bind': 'off', |
| | |
| | |
| | 'no-restricted-imports': [ |
| | 'error', |
| | { |
| | |
| | |
| | patterns: ['instantsearch.js/cjs/*'], |
| | |
| | |
| | |
| | paths: ['instantsearch.js/es'], |
| | }, |
| | ], |
| | 'react-hooks/exhaustive-deps': [ |
| | 'warn', |
| | { |
| | additionalHooks: '(useIsomorphicLayoutEffect)', |
| | }, |
| | ], |
| | }, |
| | overrides: [ |
| | { |
| | files: ['*.ts', '*.tsx'], |
| | rules: { |
| | |
| | |
| | |
| | 'no-undef': 'off', |
| | }, |
| | }, |
| | { |
| | files: ['stories/**/*'], |
| | rules: { |
| | 'react/prop-types': 'off', |
| | '@typescript-eslint/no-use-before-define': ['off'], |
| | }, |
| | }, |
| | { |
| | files: ['scripts/**/*', '*.config.js', '*.conf.js'], |
| | rules: { |
| | 'import/no-commonjs': 'off', |
| | }, |
| | }, |
| | { |
| | files: [ |
| | 'packages/react-instantsearch-hooks/**/*', |
| | 'packages/react-instantsearch-hooks-*/**/*', |
| | ], |
| | rules: { |
| | |
| | 'react/prop-types': 'off', |
| | 'import/order': [ |
| | 'error', |
| | { |
| | alphabetize: { |
| | order: 'asc', |
| | caseInsensitive: true, |
| | }, |
| | 'newlines-between': 'always', |
| | groups: [ |
| | 'builtin', |
| | 'external', |
| | 'parent', |
| | 'sibling', |
| | 'index', |
| | 'type', |
| | ], |
| | pathGroups: [ |
| | { |
| | pattern: '@/**/*', |
| | group: 'parent', |
| | position: 'before', |
| | }, |
| | ], |
| | pathGroupsExcludedImportTypes: ['builtin'], |
| | }, |
| | ], |
| | 'import/extensions': ['error', 'never'], |
| | }, |
| | settings: { |
| | 'import/parsers': { |
| | '@typescript-eslint/parser': ['.ts', '.tsx'], |
| | }, |
| | }, |
| | }, |
| | { |
| | files: 'packages/**/*', |
| | excludedFiles: ['*.test.*', '**/__tests__/**'], |
| | rules: { |
| | 'no-restricted-syntax': [ |
| | 'error', |
| | { |
| | selector: '[async=true]', |
| | message: |
| | 'The polyfill for async/await is very large, which is why we use promise chains', |
| | }, |
| | { |
| | selector: 'ForInStatement', |
| | message: |
| | 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.', |
| | }, |
| | { |
| | selector: 'ForOfStatement', |
| | message: |
| | 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.', |
| | }, |
| | { |
| | selector: 'LabeledStatement', |
| | message: |
| | 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.', |
| | }, |
| | { |
| | selector: 'WithStatement', |
| | message: |
| | '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.', |
| | }, |
| | ], |
| | }, |
| | }, |
| | |
| | { |
| | files: [ |
| | 'packages/react-instantsearch-core/**/*', |
| | 'packages/react-instantsearch-dom/**/*', |
| | ], |
| | rules: { |
| | '@typescript-eslint/ban-types': 'off', |
| | }, |
| | }, |
| | ], |
| | }; |
| |
|
| | module.exports = config; |
| |
|