|
| 1 | +import json from "eslint-plugin-json"; |
| 2 | +import globals from "globals"; |
| 3 | +import tsParser from "@typescript-eslint/parser"; |
| 4 | +import path from "node:path"; |
| 5 | +import { fileURLToPath } from "node:url"; |
| 6 | +import js from "@eslint/js"; |
| 7 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 8 | + |
| 9 | +const __filename = fileURLToPath(import.meta.url); |
| 10 | +const __dirname = path.dirname(__filename); |
| 11 | +const compat = new FlatCompat({ |
| 12 | + baseDirectory: __dirname, |
| 13 | + recommendedConfig: js.configs.recommended, |
| 14 | + allConfig: js.configs.all |
| 15 | +}); |
| 16 | + |
| 17 | +export default [{ |
| 18 | + ignores: ["**/node_modules"], |
| 19 | +}, ...compat.extends( |
| 20 | + "eslint:recommended", |
| 21 | + "plugin:json/recommended", |
| 22 | + "plugin:@typescript-eslint/recommended", |
| 23 | +), { |
| 24 | + plugins: { |
| 25 | + json, |
| 26 | + }, |
| 27 | + |
| 28 | + languageOptions: { |
| 29 | + globals: { |
| 30 | + ...globals.node, |
| 31 | + }, |
| 32 | + |
| 33 | + parser: tsParser, |
| 34 | + ecmaVersion: 2018, |
| 35 | + sourceType: "commonjs", |
| 36 | + }, |
| 37 | + |
| 38 | + rules: { |
| 39 | + "no-await-in-loop": "error", |
| 40 | + "no-extra-parens": "warn", |
| 41 | + "no-template-curly-in-string": "error", |
| 42 | + "class-methods-use-this": "error", |
| 43 | + complexity: ["error", 5], |
| 44 | + "consistent-return": "warn", |
| 45 | + curly: "error", |
| 46 | + "dot-notation": "warn", |
| 47 | + eqeqeq: "error", |
| 48 | + "guard-for-in": "error", |
| 49 | + "no-alert": "error", |
| 50 | + "no-caller": "error", |
| 51 | + "no-eval": "error", |
| 52 | + "no-extend-native": "error", |
| 53 | + "no-extra-bind": "warn", |
| 54 | + "no-extra-label": "warn", |
| 55 | + "no-invalid-this": "error", |
| 56 | + "no-magic-numbers": "warn", |
| 57 | + "no-multi-spaces": "warn", |
| 58 | + "no-new-wrappers": "error", |
| 59 | + "no-new": "error", |
| 60 | + "no-console": "warn", |
| 61 | + "no-proto": "error", |
| 62 | + "no-return-await": "error", |
| 63 | + "no-self-compare": "error", |
| 64 | + "no-sequences": "error", |
| 65 | + "no-throw-literal": "error", |
| 66 | + "no-unused-expressions": "warn", |
| 67 | + "no-useless-call": "warn", |
| 68 | + "no-useless-return": "warn", |
| 69 | + radix: "error", |
| 70 | + "require-await": "error", |
| 71 | + "require-unicode-regexp": "error", |
| 72 | + "wrap-iife": ["error", "inside"], |
| 73 | + "no-shadow": "error", |
| 74 | + "no-label-var": "error", |
| 75 | + "no-undef-init": "error", |
| 76 | + "no-undefined": "error", |
| 77 | + "no-use-before-define": "error", |
| 78 | + "func-call-spacing": ["warn", "never"], |
| 79 | + "func-names": ["error", "never"], |
| 80 | + "func-style": ["warn", "expression"], |
| 81 | + "function-call-argument-newline": ["error", "consistent"], |
| 82 | + "implicit-arrow-linebreak": ["warn", "beside"], |
| 83 | + |
| 84 | + indent: ["warn", 2, { |
| 85 | + SwitchCase: 1, |
| 86 | + }], |
| 87 | + |
| 88 | + "key-spacing": "warn", |
| 89 | + "keyword-spacing": "warn", |
| 90 | + "lines-between-class-members": ["warn", "always"], |
| 91 | + "max-depth": "warn", |
| 92 | + |
| 93 | + "max-len": ["warn", { |
| 94 | + code: 80, |
| 95 | + ignorePattern: "eslint", |
| 96 | + }], |
| 97 | + |
| 98 | + "max-params": "warn", |
| 99 | + "newline-per-chained-call": "warn", |
| 100 | + "new-parens": "error", |
| 101 | + "no-array-constructor": "error", |
| 102 | + "no-continue": "error", |
| 103 | + "no-lonely-if": "error", |
| 104 | + "no-multi-assign": "error", |
| 105 | + |
| 106 | + "no-multiple-empty-lines": ["warn", { |
| 107 | + max: 1, |
| 108 | + }], |
| 109 | + |
| 110 | + "no-nested-ternary": "error", |
| 111 | + "no-new-object": "error", |
| 112 | + "no-tabs": "warn", |
| 113 | + "no-trailing-spaces": "warn", |
| 114 | + "no-unneeded-ternary": "error", |
| 115 | + "no-whitespace-before-property": "warn", |
| 116 | + |
| 117 | + "object-curly-newline": ["warn", { |
| 118 | + multiline: true, |
| 119 | + minProperties: 1, |
| 120 | + }], |
| 121 | + |
| 122 | + "object-curly-spacing": ["warn", "always"], |
| 123 | + "object-property-newline": "warn", |
| 124 | + "one-var-declaration-per-line": ["error", "always"], |
| 125 | + quotes: ["warn", "single"], |
| 126 | + semi: "error", |
| 127 | + "semi-spacing": "warn", |
| 128 | + "semi-style": ["error", "last"], |
| 129 | + |
| 130 | + "space-unary-ops": ["warn", { |
| 131 | + words: true, |
| 132 | + nonwords: true, |
| 133 | + }], |
| 134 | + |
| 135 | + "space-before-function-paren": ["warn", "never"], |
| 136 | + "space-before-blocks": ["warn", "always"], |
| 137 | + |
| 138 | + "switch-colon-spacing": ["warn", { |
| 139 | + after: true, |
| 140 | + before: false, |
| 141 | + }], |
| 142 | + |
| 143 | + "template-tag-spacing": ["warn", "always"], |
| 144 | + "eol-last": ["warn", "always"], |
| 145 | + "computed-property-spacing": ["warn", "never"], |
| 146 | + "comma-style": ["warn", "last"], |
| 147 | + "comma-spacing": "warn", |
| 148 | + "comma-dangle": ["warn", "always"], |
| 149 | + "block-spacing": ["warn", "always"], |
| 150 | + "array-element-newline": "warn", |
| 151 | + "brace-style": "warn", |
| 152 | + |
| 153 | + "array-bracket-spacing": ["warn", "never", { |
| 154 | + singleValue: true, |
| 155 | + }], |
| 156 | + |
| 157 | + "array-bracket-newline": ["warn", { |
| 158 | + minItems: 2, |
| 159 | + }], |
| 160 | + |
| 161 | + "prefer-rest-params": "warn", |
| 162 | + "template-curly-spacing": ["warn", "always"], |
| 163 | + "prefer-const": "error", |
| 164 | + "no-var": "error", |
| 165 | + "no-useless-constructor": "warn", |
| 166 | + "no-useless-computed-key": "warn", |
| 167 | + "no-confusing-arrow": "warn", |
| 168 | + "arrow-spacing": "warn", |
| 169 | + "arrow-body-style": ["warn", "as-needed"], |
| 170 | + }, |
| 171 | +}]; |
0 commit comments