|
| 1 | +import typescriptEslint from "@typescript-eslint/eslint-plugin"; |
| 2 | +import stylistic from "@stylistic/eslint-plugin"; |
| 3 | +import globals from "globals"; |
| 4 | +import tsParser from "@typescript-eslint/parser"; |
| 5 | +import path from "node:path"; |
| 6 | +import { fileURLToPath } from "node:url"; |
| 7 | +import js from "@eslint/js"; |
| 8 | +import { FlatCompat } from "@eslint/eslintrc"; |
| 9 | + |
| 10 | +const __filename = fileURLToPath(import.meta.url); |
| 11 | +const __dirname = path.dirname(__filename); |
| 12 | +const compat = new FlatCompat({ |
| 13 | + baseDirectory: __dirname, |
| 14 | + recommendedConfig: js.configs.recommended, |
| 15 | + allConfig: js.configs.all |
| 16 | +}); |
| 17 | + |
| 18 | +export default [{ |
| 19 | + ignores: [ |
| 20 | + // don't ever lint node_modules |
| 21 | + "**/node_modules", |
| 22 | + // don't lint build output (make sure it's set to your correct build folder name) |
| 23 | + "**/bin" |
| 24 | + ], |
| 25 | +}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), { |
| 26 | + files: ["**/*.ts"], |
| 27 | + |
| 28 | + plugins: { |
| 29 | + "@typescript-eslint": typescriptEslint, |
| 30 | + "@stylistic": stylistic, |
| 31 | + }, |
| 32 | + |
| 33 | + languageOptions: { |
| 34 | + globals: { |
| 35 | + ...globals.node, |
| 36 | + }, |
| 37 | + |
| 38 | + parser: tsParser, |
| 39 | + ecmaVersion: 5, |
| 40 | + sourceType: "module", |
| 41 | + |
| 42 | + parserOptions: { |
| 43 | + project: "tsconfig.json", |
| 44 | + }, |
| 45 | + }, |
| 46 | + |
| 47 | + rules: { |
| 48 | + "brace-style": ["warn", "1tbs", { |
| 49 | + allowSingleLine: true, |
| 50 | + }], |
| 51 | + |
| 52 | + "comma-dangle": ["warn", "always-multiline"], |
| 53 | + "comma-spacing": "warn", |
| 54 | + "comma-style": "warn", |
| 55 | + curly: ["warn", "multi-line", "consistent"], |
| 56 | + "dot-location": ["warn", "property"], |
| 57 | + "eol-last": "warn", |
| 58 | + "@stylistic/indent": ["warn", "tab"], |
| 59 | + "keyword-spacing": ["warn"], |
| 60 | + |
| 61 | + "max-nested-callbacks": ["warn", { |
| 62 | + max: 4, |
| 63 | + }], |
| 64 | + |
| 65 | + "max-statements-per-line": ["warn", { |
| 66 | + max: 2, |
| 67 | + }], |
| 68 | + |
| 69 | + "no-empty-function": "warn", |
| 70 | + "no-floating-decimal": "warn", |
| 71 | + "@typescript-eslint/no-floating-promises": "error", |
| 72 | + "no-inline-comments": "warn", |
| 73 | + "no-lonely-if": "warn", |
| 74 | + "no-multi-spaces": "warn", |
| 75 | + |
| 76 | + "no-multiple-empty-lines": ["warn", { |
| 77 | + max: 2, |
| 78 | + maxEOF: 1, |
| 79 | + maxBOF: 0, |
| 80 | + }], |
| 81 | + |
| 82 | + "no-shadow": "off", |
| 83 | + |
| 84 | + "@typescript-eslint/no-shadow": ["error", { |
| 85 | + allow: ["err", "resolve", "reject"], |
| 86 | + }], |
| 87 | + |
| 88 | + "no-trailing-spaces": ["warn"], |
| 89 | + "no-var": "error", |
| 90 | + "object-curly-spacing": ["warn", "always"], |
| 91 | + "prefer-const": "error", |
| 92 | + quotes: ["warn", "single"], |
| 93 | + "@stylistic/semi": ["warn"], |
| 94 | + "space-before-blocks": "warn", |
| 95 | + |
| 96 | + "space-before-function-paren": ["warn", { |
| 97 | + anonymous: "never", |
| 98 | + named: "never", |
| 99 | + asyncArrow: "always", |
| 100 | + }], |
| 101 | + |
| 102 | + "space-in-parens": ["warn", "always", { |
| 103 | + exceptions: ["empty"], |
| 104 | + }], |
| 105 | + |
| 106 | + "space-infix-ops": "warn", |
| 107 | + "space-unary-ops": "warn", |
| 108 | + "spaced-comment": "warn", |
| 109 | + "template-curly-spacing": ["warn", "always"], |
| 110 | + |
| 111 | + yoda: ["error", "never", { |
| 112 | + exceptRange: true, |
| 113 | + }], |
| 114 | + }, |
| 115 | +}]; |
0 commit comments