|
| 1 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 2 | +import preferArrow from "eslint-plugin-prefer-arrow"; |
| 3 | +import unicorn from "eslint-plugin-unicorn"; |
| 4 | +import globals from "globals"; |
| 5 | +import tsParser from "@typescript-eslint/parser"; |
| 6 | +import path from "node:path"; |
| 7 | +import {fileURLToPath} from "node:url"; |
| 8 | +import js from "@eslint/js"; |
| 9 | +import {FlatCompat} from "@eslint/eslintrc"; |
| 10 | + |
| 11 | +const __filename = fileURLToPath(import.meta.url); |
| 12 | +const __dirname = path.dirname(__filename); |
| 13 | +const compat = new FlatCompat({ |
| 14 | + baseDirectory: __dirname, |
| 15 | + recommendedConfig: js.configs.recommended, |
| 16 | + allConfig: js.configs.all, |
| 17 | +}); |
| 18 | +const staticCompat = new FlatCompat({ |
| 19 | + baseDirectory: __dirname + "/static", |
| 20 | + recommendedConfig: js.configs.recommended, |
| 21 | + allConfig: js.configs.all, |
| 22 | +}); |
| 23 | + |
| 24 | +export default [ |
| 25 | + { |
| 26 | + ignores: [ |
| 27 | + "**/coverage/", |
| 28 | + "**/generated/", |
| 29 | + "**/browser-compat-data/", |
| 30 | + "**/es-scraper/", |
| 31 | + "**/static/", |
| 32 | + ], |
| 33 | + }, |
| 34 | + ...compat.extends( |
| 35 | + "eslint:recommended", |
| 36 | + "plugin:@typescript-eslint/strict", |
| 37 | + "plugin:@typescript-eslint/stylistic", |
| 38 | + "plugin:jsdoc/recommended-typescript", |
| 39 | + ), |
| 40 | + ...staticCompat.extends("eslint:recommended", "plugin:jsdoc/recommended"), |
| 41 | + { |
| 42 | + files: ["**/*.ts", "**/eslint.config.js"], |
| 43 | + plugins: { |
| 44 | + "@typescript-eslint": typescriptEslint, |
| 45 | + "prefer-arrow": preferArrow, |
| 46 | + // jsdoc, |
| 47 | + unicorn, |
| 48 | + }, |
| 49 | + |
| 50 | + languageOptions: { |
| 51 | + globals: { |
| 52 | + ...globals.mocha, |
| 53 | + ...globals.node, |
| 54 | + }, |
| 55 | + |
| 56 | + parser: tsParser, |
| 57 | + ecmaVersion: 2022, |
| 58 | + sourceType: "module", |
| 59 | + }, |
| 60 | + |
| 61 | + rules: { |
| 62 | + curly: ["error", "all"], |
| 63 | + "max-len": "off", |
| 64 | + indent: "off", |
| 65 | + "jsdoc/check-param-names": "error", |
| 66 | + "jsdoc/require-description": "warn", |
| 67 | + |
| 68 | + "jsdoc/require-jsdoc": [ |
| 69 | + "warn", |
| 70 | + { |
| 71 | + require: { |
| 72 | + ArrowFunctionExpression: true, |
| 73 | + ClassDeclaration: true, |
| 74 | + ClassExpression: true, |
| 75 | + FunctionDeclaration: true, |
| 76 | + FunctionExpression: true, |
| 77 | + MethodDefinition: true, |
| 78 | + }, |
| 79 | + }, |
| 80 | + ], |
| 81 | + |
| 82 | + "jsdoc/require-param-type": "off", |
| 83 | + "jsdoc/require-returns": "error", |
| 84 | + "jsdoc/require-returns-type": "off", |
| 85 | + "jsdoc/no-undefined-types": "error", |
| 86 | + "jsdoc/require-yields": "error", |
| 87 | + "no-else-return": "error", |
| 88 | + "no-unused-vars": "off", |
| 89 | + "prefer-arrow/prefer-arrow-functions": "error", |
| 90 | + quotes: "off", |
| 91 | + "quote-props": ["error", "as-needed"], |
| 92 | + "require-jsdoc": "off", |
| 93 | + "space-before-function-paren": "off", |
| 94 | + "unicorn/prefer-node-protocol": "error", |
| 95 | + |
| 96 | + "@typescript-eslint/no-unused-vars": [ |
| 97 | + "error", |
| 98 | + { |
| 99 | + caughtErrors: "none", |
| 100 | + }, |
| 101 | + ], |
| 102 | + |
| 103 | + "@typescript-eslint/no-explicit-any": "off", |
| 104 | + "@typescript-eslint/no-empty-function": "off", |
| 105 | + }, |
| 106 | + }, |
| 107 | + { |
| 108 | + files: ["**/static/**"], |
| 109 | + languageOptions: { |
| 110 | + ecmaVersion: 3, |
| 111 | + sourceType: "script", |
| 112 | + globals: { |
| 113 | + ...globals.browser, |
| 114 | + JSON: "readonly", |
| 115 | + Promise: "readonly", |
| 116 | + }, |
| 117 | + }, |
| 118 | + |
| 119 | + rules: { |
| 120 | + "comma-dangle": ["error", "never"], |
| 121 | + curly: ["error", "all"], |
| 122 | + "guard-for-in": "off", |
| 123 | + indent: "off", |
| 124 | + "max-len": "off", |
| 125 | + "no-invalid-this": "off", |
| 126 | + |
| 127 | + "no-unused-vars": [ |
| 128 | + "error", |
| 129 | + { |
| 130 | + caughtErrors: "none", |
| 131 | + }, |
| 132 | + ], |
| 133 | + |
| 134 | + "no-var": "off", |
| 135 | + "prefer-arrow/prefer-arrow-functions": "off", |
| 136 | + quotes: "off", |
| 137 | + "require-jsdoc": "off", |
| 138 | + "space-before-function-paren": "off", |
| 139 | + "jsdoc/check-param-names": "error", |
| 140 | + "jsdoc/require-description": "warn", |
| 141 | + |
| 142 | + "jsdoc/require-jsdoc": [ |
| 143 | + "warn", |
| 144 | + { |
| 145 | + require: { |
| 146 | + ArrowFunctionExpression: true, |
| 147 | + ClassDeclaration: true, |
| 148 | + ClassExpression: true, |
| 149 | + FunctionDeclaration: true, |
| 150 | + FunctionExpression: true, |
| 151 | + MethodDefinition: true, |
| 152 | + }, |
| 153 | + }, |
| 154 | + ], |
| 155 | + |
| 156 | + "jsdoc/require-param-type": "error", |
| 157 | + "jsdoc/require-returns": "error", |
| 158 | + "jsdoc/require-returns-type": "off", |
| 159 | + "jsdoc/no-undefined-types": "error", |
| 160 | + "jsdoc/require-yields": "error", |
| 161 | + }, |
| 162 | + }, |
| 163 | + { |
| 164 | + files: ["**/static/unittest/**.js"], |
| 165 | + languageOptions: { |
| 166 | + ecmaVersion: 2022, |
| 167 | + globals: { |
| 168 | + ...globals.browser, |
| 169 | + ...globals.mocha, |
| 170 | + }, |
| 171 | + }, |
| 172 | + }, |
| 173 | + { |
| 174 | + files: [ |
| 175 | + "**/static/resources/custom-tests/api/AudioWorkletNode/WhiteNoiseProcessor.js", |
| 176 | + ], |
| 177 | + languageOptions: { |
| 178 | + ecmaVersion: 6, |
| 179 | + }, |
| 180 | + }, |
| 181 | +]; |
0 commit comments