|
| 1 | +import jsLint from '@eslint/js'; |
| 2 | +import importLint from 'eslint-plugin-import'; |
| 3 | +import jestLint from 'eslint-plugin-jest'; |
| 4 | +import jsdocLint from 'eslint-plugin-jsdoc'; |
| 5 | +import reactLint from 'eslint-plugin-react'; |
| 6 | +import hooksLint from 'eslint-plugin-react-hooks'; |
| 7 | +import {globalIgnores} from 'eslint/config'; |
| 8 | +import globals from 'globals'; |
| 9 | +import tsLint from 'typescript-eslint'; |
| 10 | + |
| 11 | +export default tsLint.config( |
| 12 | + globalIgnores([ |
| 13 | + 'eslint.config.js', |
| 14 | + 'docs/**/*', |
| 15 | + 'dist/**/*', |
| 16 | + 'tmp/**/*', |
| 17 | + 'site/extras/*', |
| 18 | + '**/node_modules/**/*', |
| 19 | + ]), |
| 20 | + |
| 21 | + jsLint.configs.recommended, |
| 22 | + importLint.flatConfigs.recommended, |
| 23 | + jestLint.configs['flat/recommended'], |
| 24 | + jsdocLint.configs['flat/recommended'], |
| 25 | + reactLint.configs.flat.recommended, |
| 26 | + reactLint.configs.flat['jsx-runtime'], |
| 27 | + hooksLint.configs['recommended-latest'], |
| 28 | + tsLint.configs.recommended, |
| 29 | + |
| 30 | + { |
| 31 | + settings: { |
| 32 | + react: {version: 'detect'}, |
| 33 | + 'import/resolver': {node: {extensions: ['.js', '.jsx', '.ts', '.tsx']}}, |
| 34 | + 'import/core-modules': ['expo-sqlite'], |
| 35 | + }, |
| 36 | + |
| 37 | + languageOptions: {globals: {...globals.node, ...globals.browser}}, |
| 38 | + |
| 39 | + rules: { |
| 40 | + 'no-var': 2, |
| 41 | + 'no-console': 2, |
| 42 | + 'object-curly-spacing': [2, 'never'], |
| 43 | + indent: 0, |
| 44 | + 'no-empty': [2, {allowEmptyCatch: true}], |
| 45 | + 'linebreak-style': [2, 'unix'], |
| 46 | + 'space-infix-ops': 2, |
| 47 | + quotes: [2, 'single', {allowTemplateLiterals: true}], |
| 48 | + semi: [2, 'always'], |
| 49 | + 'sort-keys': 0, |
| 50 | + 'no-multiple-empty-lines': [2, {max: 1}], |
| 51 | + 'sort-imports': 0, |
| 52 | + 'max-len': [ |
| 53 | + 2, |
| 54 | + { |
| 55 | + code: 80, |
| 56 | + ignorePattern: |
| 57 | + '^(\\s+\\* )?(imports?|exports?|\\} from|(.+ as .+))\\W.*', |
| 58 | + ignoreUrls: true, |
| 59 | + }, |
| 60 | + ], |
| 61 | + 'comma-dangle': [ |
| 62 | + 2, |
| 63 | + { |
| 64 | + arrays: 'always-multiline', |
| 65 | + objects: 'always-multiline', |
| 66 | + imports: 'always-multiline', |
| 67 | + exports: 'always-multiline', |
| 68 | + functions: 'always-multiline', |
| 69 | + }, |
| 70 | + ], |
| 71 | + 'import/no-unresolved': [ |
| 72 | + 2, |
| 73 | + { |
| 74 | + ignore: [ |
| 75 | + '^\\./generated/client$', |
| 76 | + '^custom-remote-handlers$', |
| 77 | + '^electric-sql/(client/model|notifiers|wa-sqlite)$', |
| 78 | + '^cloudflare:workers$', |
| 79 | + 'eslint/config', |
| 80 | + 'typescript-eslint', |
| 81 | + ], |
| 82 | + }, |
| 83 | + ], |
| 84 | + |
| 85 | + // -- |
| 86 | + |
| 87 | + '@typescript-eslint/unified-signatures': 0, |
| 88 | + '@typescript-eslint/no-invalid-void-type': 0, |
| 89 | + '@typescript-eslint/no-dynamic-delete': 0, |
| 90 | + '@typescript-eslint/no-var-requires': 0, |
| 91 | + '@typescript-eslint/no-explicit-any': 0, |
| 92 | + '@typescript-eslint/no-unused-vars': [ |
| 93 | + 2, |
| 94 | + {argsIgnorePattern: '^_.*', varsIgnorePattern: '^(_.*|React)'}, |
| 95 | + ], |
| 96 | + |
| 97 | + // -- |
| 98 | + |
| 99 | + 'jsx-quotes': [2, 'prefer-double'], |
| 100 | + |
| 101 | + 'react/button-has-type': 0, |
| 102 | + 'react/destructuring-assignment': 0, |
| 103 | + 'react/display-name': 0, |
| 104 | + 'react/forbid-component-props': 0, |
| 105 | + 'react/jsx-boolean-value': 0, |
| 106 | + 'react/jsx-filename-extension': 0, |
| 107 | + 'react/jsx-first-prop-new-line': [2, 'multiline'], |
| 108 | + 'react/jsx-indent-props': [2, 2], |
| 109 | + 'react/jsx-indent': 0, |
| 110 | + 'react/jsx-max-depth': [2, {max: 5}], |
| 111 | + 'react/jsx-max-props-per-line': [2, {maximum: 1, when: 'multiline'}], |
| 112 | + 'react/jsx-newline': 0, |
| 113 | + 'react/jsx-no-literals': 0, |
| 114 | + 'react/jsx-one-expression-per-line': 0, |
| 115 | + 'react/jsx-props-no-spreading': 0, |
| 116 | + 'react/jsx-sort-props': 0, |
| 117 | + 'react/no-arrow-function-lifecycle': 2, |
| 118 | + 'react/no-find-dom-node': 0, |
| 119 | + 'react/no-multi-comp': [2, {ignoreStateless: true}], |
| 120 | + 'react/no-set-state': 0, |
| 121 | + 'react/no-unsafe': 2, |
| 122 | + 'react/prop-types': 2, |
| 123 | + 'react/require-default-props': 0, |
| 124 | + 'react/sort-comp': 0, |
| 125 | + 'react/jsx-handler-names': [ |
| 126 | + 2, |
| 127 | + {eventHandlerPrefix: '_handle', eventHandlerPropPrefix: 'on'}, |
| 128 | + ], |
| 129 | + 'react/function-component-definition': [ |
| 130 | + 2, |
| 131 | + { |
| 132 | + namedComponents: 'arrow-function', |
| 133 | + unnamedComponents: 'arrow-function', |
| 134 | + }, |
| 135 | + ], |
| 136 | + 'react/jsx-no-useless-fragment': 2, |
| 137 | + |
| 138 | + // -- |
| 139 | + |
| 140 | + 'react-hooks/exhaustive-deps': 2, |
| 141 | + 'react-hooks/rules-of-hooks': 2, |
| 142 | + |
| 143 | + // -- |
| 144 | + |
| 145 | + 'jest/expect-expect': [2, {assertFunctionNames: ['expect*']}], |
| 146 | + 'jest/no-conditional-expect': 2, |
| 147 | + }, |
| 148 | + }, |
| 149 | + |
| 150 | + { |
| 151 | + files: ['src/@types/**/*.js'], |
| 152 | + settings: {jsdoc: {mode: 'typescript', contexts: ['any']}}, |
| 153 | + rules: { |
| 154 | + 'jsdoc/check-tag-names': [ |
| 155 | + 2, |
| 156 | + {definedTags: ['category', 'packageDocumentation']}, |
| 157 | + ], |
| 158 | + 'jsdoc/no-restricted-syntax': [ |
| 159 | + 2, |
| 160 | + { |
| 161 | + contexts: [ |
| 162 | + { |
| 163 | + comment: |
| 164 | + // eslint-disable-next-line max-len |
| 165 | + 'JsdocBlock:not(:has(JsdocTag[tag=/category|packageDocumentation/]))', |
| 166 | + message: 'Every non-module block requires a @category tag', |
| 167 | + }, |
| 168 | + { |
| 169 | + comment: 'JsdocBlock:not(:has(JsdocTag[tag=since]))', |
| 170 | + message: 'Every block requires a @since tag', |
| 171 | + }, |
| 172 | + { |
| 173 | + comment: |
| 174 | + 'JsdocBlock:has(JsdocTag[tag=since] ~ JsdocTag[tag=since])', |
| 175 | + message: 'Every block must have only one @since tag', |
| 176 | + }, |
| 177 | + ], |
| 178 | + }, |
| 179 | + ], |
| 180 | + 'jsdoc/require-jsdoc': 2, |
| 181 | + 'jsdoc/require-description': 2, |
| 182 | + 'jsdoc/require-description-complete-sentence': 2, |
| 183 | + 'jsdoc/require-returns-description': 2, |
| 184 | + 'jsdoc/no-blank-blocks': 2, |
| 185 | + 'jsdoc/require-param-type': 0, |
| 186 | + 'jsdoc/require-returns-type': 0, |
| 187 | + 'jsdoc/check-param-names': 0, |
| 188 | + }, |
| 189 | + }, |
| 190 | + |
| 191 | + { |
| 192 | + files: ['eslint.config.js'], |
| 193 | + extends: [tsLint.configs.disableTypeChecked], |
| 194 | + }, |
| 195 | +); |
0 commit comments