|
| 1 | +const { |
| 2 | + defineConfig, |
| 3 | +} = require("eslint/config"); |
| 4 | + |
| 5 | +const globals = require("globals"); |
| 6 | +const security = require("eslint-plugin-security"); |
| 7 | +const cypress = require("eslint-plugin-cypress"); |
| 8 | +const typescriptEslint = require("@typescript-eslint/eslint-plugin"); |
| 9 | +const tsParser = require("@typescript-eslint/parser"); |
| 10 | +const js = require("@eslint/js"); |
| 11 | + |
| 12 | +const { |
| 13 | + FlatCompat, |
| 14 | +} = require("@eslint/eslintrc"); |
| 15 | + |
| 16 | +const compat = new FlatCompat({ |
| 17 | + baseDirectory: __dirname, |
| 18 | + recommendedConfig: js.configs.recommended, |
| 19 | + allConfig: js.configs.all |
| 20 | +}); |
| 21 | + |
| 22 | +module.exports = defineConfig([{ |
| 23 | + languageOptions: { |
| 24 | + globals: { |
| 25 | + ...globals.browser, |
| 26 | + ...globals.amd, |
| 27 | + ...globals.jquery, |
| 28 | + ...cypress.environments.globals.globals, |
| 29 | + }, |
| 30 | + }, |
| 31 | + |
| 32 | + plugins: { |
| 33 | + security, |
| 34 | + cypress, |
| 35 | + "@typescript-eslint": typescriptEslint, |
| 36 | + }, |
| 37 | + |
| 38 | + extends: compat.extends( |
| 39 | + "eslint:recommended", |
| 40 | + "plugin:security/recommended-legacy", |
| 41 | + "plugin:react/recommended", |
| 42 | + ), |
| 43 | + |
| 44 | + "rules": { |
| 45 | + "indent": ["error", 4], |
| 46 | + "linebreak-style": ["error", "unix"], |
| 47 | + |
| 48 | + "no-unused-vars": ["error", { |
| 49 | + "vars": "all", |
| 50 | + "args": "none", |
| 51 | + }], |
| 52 | + |
| 53 | + "quotes": ["error", "single"], |
| 54 | + "semi": ["error", "always"], |
| 55 | + |
| 56 | + "max-len": [2, { |
| 57 | + "code": 80, |
| 58 | + "tabWidth": 4, |
| 59 | + "ignoreUrls": true, |
| 60 | + }], |
| 61 | + |
| 62 | + "space-before-function-paren": ["error", "never"], |
| 63 | + "space-in-parens": ["error", "never"], |
| 64 | + "no-trailing-spaces": ["error"], |
| 65 | + |
| 66 | + "key-spacing": ["error", { |
| 67 | + "beforeColon": false, |
| 68 | + }], |
| 69 | + |
| 70 | + "func-call-spacing": ["error", "never"], |
| 71 | + "react/prop-types": [0], |
| 72 | + "security/detect-buffer-noassert": 1, |
| 73 | + "security/detect-child-process": 1, |
| 74 | + "security/detect-disable-mustache-escape": 1, |
| 75 | + "security/detect-eval-with-expression": 1, |
| 76 | + "security/detect-new-buffer": 1, |
| 77 | + "security/detect-no-csrf-before-method-override": 1, |
| 78 | + "security/detect-non-literal-fs-filename": 1, |
| 79 | + "security/detect-non-literal-regexp": 1, |
| 80 | + "security/detect-non-literal-require": 0, |
| 81 | + "security/detect-object-injection": 0, |
| 82 | + "security/detect-possible-timing-attacks": 1, |
| 83 | + "security/detect-pseudoRandomBytes": 1, |
| 84 | + "security/detect-unsafe-regex": 1, |
| 85 | + }, |
| 86 | +}, { |
| 87 | + files: ["**/*.{ts,tsx}"], |
| 88 | + |
| 89 | + "rules": { |
| 90 | + "max-len": [2, { |
| 91 | + "code": 100, |
| 92 | + "tabWidth": 4, |
| 93 | + "ignoreUrls": true, |
| 94 | + }], |
| 95 | + }, |
| 96 | + |
| 97 | + languageOptions: { |
| 98 | + parser: tsParser, |
| 99 | + |
| 100 | + parserOptions: { |
| 101 | + tsconfigRootDir: __dirname, |
| 102 | + project: ["./tsconfig.json"], |
| 103 | + }, |
| 104 | + }, |
| 105 | + |
| 106 | + extends: compat.extends( |
| 107 | + "plugin:@typescript-eslint/eslint-recommended", |
| 108 | + "plugin:@typescript-eslint/recommended", |
| 109 | + "plugin:@typescript-eslint/recommended-requiring-type-checking", |
| 110 | + ), |
| 111 | +}]); |
0 commit comments