|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +const js = require("@eslint/js"); |
| 4 | +const { FlatCompat } = require("@eslint/eslintrc"); |
| 5 | +const eslintPluginMarkdown = require("eslint-plugin-markdown"); |
| 6 | +const eslintPluginEslintPluginAll = require("eslint-plugin-eslint-plugin/configs/all"); |
| 7 | +const globals = require("globals"); |
| 8 | + |
| 9 | +const compat = new FlatCompat({ |
| 10 | + baseDirectory: __dirname, |
| 11 | + recommendedConfig: js.configs.recommended |
| 12 | +}); |
| 13 | + |
| 14 | +module.exports = [ |
| 15 | + ...compat.extends( |
| 16 | + "plugin:node/recommended", |
| 17 | + "plugin:eslint-comments/recommended", |
| 18 | + "plugin:unicorn/recommended" |
| 19 | + ), |
| 20 | + |
| 21 | + eslintPluginEslintPluginAll, |
| 22 | + |
| 23 | + // Apply mocha config only to tests. |
| 24 | + ...compat.extends("plugin:mocha/recommended").map(config => ({ ...config, |
| 25 | + files: ["tests/**/*.js"] })), |
| 26 | + |
| 27 | + { |
| 28 | + languageOptions: { |
| 29 | + "sourceType": "script", |
| 30 | + "ecmaVersion": "latest", |
| 31 | + "globals": globals.node |
| 32 | + } |
| 33 | + }, |
| 34 | + { |
| 35 | + "rules": |
| 36 | + { |
| 37 | + "array-bracket-spacing": ["error", "never"], |
| 38 | + "block-spacing": ["error", "always"], |
| 39 | + "brace-style": ["error", "1tbs"], |
| 40 | + "camelcase": ["error", { "properties": "always" }], |
| 41 | + "comma-dangle": ["error", "never"], |
| 42 | + "comma-spacing": ["error", { "before": false, |
| 43 | + "after": true }], |
| 44 | + "comma-style": ["error", "last"], |
| 45 | + "complexity": ["error", 10], |
| 46 | + "computed-property-spacing": ["error", "never"], |
| 47 | + "consistent-return": "error", |
| 48 | + "consistent-this": ["error", "self"], |
| 49 | + "curly": ["error", "multi-line"], |
| 50 | + "default-case": "error", |
| 51 | + "dot-location": ["error", "property"], |
| 52 | + "dot-notation": "error", |
| 53 | + "eol-last": "error", |
| 54 | + "eqeqeq": "error", |
| 55 | + "func-call-spacing": "error", |
| 56 | + "func-style": ["error", "declaration"], |
| 57 | + "guard-for-in": "error", |
| 58 | + "indent": ["error", 4, { "SwitchCase": 1, |
| 59 | + "VariableDeclarator": 1 }], |
| 60 | + "key-spacing": ["error", { "beforeColon": false, |
| 61 | + "afterColon": true }], |
| 62 | + "keyword-spacing": ["error", { "before": true, |
| 63 | + "after": true }], |
| 64 | + "linebreak-style": ["error", "unix"], |
| 65 | + "lines-around-comment": [ |
| 66 | + "error", |
| 67 | + { |
| 68 | + "beforeBlockComment": false, |
| 69 | + "afterBlockComment": false, |
| 70 | + "beforeLineComment": true, |
| 71 | + "afterLineComment": false, |
| 72 | + "allowBlockStart": true, |
| 73 | + "allowBlockEnd": true, |
| 74 | + "allowObjectStart": true, |
| 75 | + "allowObjectEnd": true, |
| 76 | + "allowArrayStart": true, |
| 77 | + "allowArrayEnd": true |
| 78 | + } |
| 79 | + ], |
| 80 | + "max-depth": ["error", 5], |
| 81 | + "new-cap": ["error", { "newIsCap": true, |
| 82 | + "capIsNew": true }], |
| 83 | + "new-parens": "error", |
| 84 | + "no-array-constructor": "error", |
| 85 | + "no-caller": "error", |
| 86 | + "no-catch-shadow": "error", |
| 87 | + "no-cond-assign": ["error", "except-parens"], |
| 88 | + "no-console": "error", |
| 89 | + "no-const-assign": "error", |
| 90 | + "no-constant-condition": "error", |
| 91 | + "no-control-regex": "error", |
| 92 | + "no-debugger": "error", |
| 93 | + "no-delete-var": "error", |
| 94 | + "no-dupe-args": "error", |
| 95 | + "no-dupe-keys": "error", |
| 96 | + "no-duplicate-case": "error", |
| 97 | + "no-else-return": "error", |
| 98 | + "no-empty": "error", |
| 99 | + "no-empty-character-class": "error", |
| 100 | + "no-empty-function": "error", |
| 101 | + "no-eval": "error", |
| 102 | + "no-ex-assign": "error", |
| 103 | + "no-extend-native": "error", |
| 104 | + "no-extra-boolean-cast": "error", |
| 105 | + "no-extra-parens": "error", |
| 106 | + "no-extra-semi": "error", |
| 107 | + "no-fallthrough": "error", |
| 108 | + "no-floating-decimal": "error", |
| 109 | + "no-func-assign": "error", |
| 110 | + "no-implied-eval": "error", |
| 111 | + "no-invalid-regexp": "error", |
| 112 | + "no-irregular-whitespace": "error", |
| 113 | + "no-labels": "error", |
| 114 | + "no-lone-blocks": "error", |
| 115 | + "no-lonely-if": "error", |
| 116 | + "no-loop-func": "error", |
| 117 | + "no-mixed-requires": "error", |
| 118 | + "no-mixed-spaces-and-tabs": "error", |
| 119 | + "no-multi-spaces": ["error", { "ignoreEOLComments": true }], |
| 120 | + "no-multi-str": "error", |
| 121 | + "no-multiple-empty-lines": "error", |
| 122 | + "no-unsafe-negation": "error", |
| 123 | + "no-nested-ternary": "error", |
| 124 | + "no-new-func": "error", |
| 125 | + "no-new-object": "error", |
| 126 | + "no-new-require": "error", |
| 127 | + "no-new-wrappers": "error", |
| 128 | + "no-octal": "error", |
| 129 | + "no-octal-escape": "error", |
| 130 | + "no-path-concat": "error", |
| 131 | + "no-process-exit": "error", |
| 132 | + "no-redeclare": "error", |
| 133 | + "no-return-assign": "error", |
| 134 | + "no-regex-spaces": "error", |
| 135 | + "no-self-assign": "error", |
| 136 | + "no-self-compare": "error", |
| 137 | + "no-sequences": "error", |
| 138 | + "no-sparse-arrays": "error", |
| 139 | + "no-template-curly-in-string": "error", |
| 140 | + "no-throw-literal": "error", |
| 141 | + "no-trailing-spaces": "error", |
| 142 | + "no-undef": "error", |
| 143 | + "no-undefined": "error", |
| 144 | + "no-underscore-dangle": "error", |
| 145 | + "no-unexpected-multiline": "error", |
| 146 | + "no-unmodified-loop-condition": "error", |
| 147 | + "no-unneeded-ternary": "error", |
| 148 | + "no-unreachable": "error", |
| 149 | + "no-unsafe-finally": "error", |
| 150 | + "no-unused-expressions": "error", |
| 151 | + "no-unused-vars": "error", |
| 152 | + "no-use-before-define": "error", |
| 153 | + "no-useless-call": "error", |
| 154 | + "no-useless-concat": "error", |
| 155 | + "no-useless-escape": "error", |
| 156 | + "no-useless-return": "error", |
| 157 | + "no-var": "error", |
| 158 | + "no-warning-comments": "error", |
| 159 | + "no-whitespace-before-property": "error", |
| 160 | + "no-with": "error", |
| 161 | + "object-curly-newline": ["error", { "consistent": true }], |
| 162 | + "object-curly-spacing": ["error", "always"], |
| 163 | + "object-property-newline": "error", |
| 164 | + "operator-assignment": ["error", "always"], |
| 165 | + "operator-linebreak": ["error", "after"], |
| 166 | + "padded-blocks": ["error", "never"], |
| 167 | + "prefer-const": "error", |
| 168 | + "prefer-template": "error", |
| 169 | + "quote-props": ["error", "consistent"], |
| 170 | + "quotes": ["error", "double"], |
| 171 | + "radix": "error", |
| 172 | + "semi": ["error", "always"], |
| 173 | + "semi-spacing": ["error", { "before": false, |
| 174 | + "after": true }], |
| 175 | + "space-before-blocks": ["error", "always"], |
| 176 | + "space-before-function-paren": ["error", { "anonymous": "always", |
| 177 | + "named": "never" }], |
| 178 | + "space-in-parens": ["error", "never"], |
| 179 | + "space-infix-ops": "error", |
| 180 | + "space-unary-ops": ["error", { "words": true, |
| 181 | + "nonwords": false }], |
| 182 | + "spaced-comment": ["error", "always", { "exceptions": ["-"] }], |
| 183 | + "strict": ["error", "global"], |
| 184 | + "template-curly-spacing": ["error", "never"], |
| 185 | + "use-isnan": "error", |
| 186 | + "valid-jsdoc": ["error", { |
| 187 | + "prefer": { |
| 188 | + "return": "returns" |
| 189 | + } |
| 190 | + }], |
| 191 | + "valid-typeof": "error", |
| 192 | + "wrap-iife": "error", |
| 193 | + "yoda": ["error", "never"], |
| 194 | + |
| 195 | + // eslint-plugin-eslint-plugin |
| 196 | + "eslint-plugin/meta-property-ordering": ["error", [ |
| 197 | + "type", "docs", "fixable", "messages", "schema", "deprecated", "replacedBy" |
| 198 | + ]], |
| 199 | + "eslint-plugin/require-meta-docs-url": ["error", { |
| 200 | + "pattern": "https://github.com/platinumazure/eslint-plugin-qunit/blob/master/docs/rules/{{name}}.md" |
| 201 | + }], |
| 202 | + |
| 203 | + // eslint-plugin-node |
| 204 | + "node/no-missing-require": ["error", { |
| 205 | + "allowModules": ["@typescript-eslint/parser"] |
| 206 | + }], |
| 207 | + |
| 208 | + // eslint-plugin-unicorn |
| 209 | + "unicorn/consistent-function-scoping": "off", |
| 210 | + "unicorn/empty-brace-spaces": "off", |
| 211 | + "unicorn/filename-case": "off", |
| 212 | + "unicorn/no-array-reduce": "off", |
| 213 | + "unicorn/no-null": "off", |
| 214 | + // eslint-disable-next-line no-warning-comments |
| 215 | + "unicorn/prefer-at": "off", // TODO: enable once we raise Node requirement to v16.6.0 |
| 216 | + "unicorn/prefer-module": "off", |
| 217 | + "unicorn/prevent-abbreviations": "off" |
| 218 | + } |
| 219 | + }, |
| 220 | + { |
| 221 | + files: ["**/*.md"], |
| 222 | + plugins: { markdown: eslintPluginMarkdown }, |
| 223 | + processor: "markdown/markdown" |
| 224 | + }, |
| 225 | + { |
| 226 | + "files": ["**/*.md/*.js", "**/*.md/*.javascript"], |
| 227 | + "languageOptions": { |
| 228 | + "parserOptions": { |
| 229 | + "sourceType": "module" |
| 230 | + } |
| 231 | + }, |
| 232 | + "rules": { |
| 233 | + "brace-style": "off", |
| 234 | + "eqeqeq": "off", |
| 235 | + "guard-for-in": "off", |
| 236 | + "no-constant-condition": "off", |
| 237 | + "no-empty-function": "off", |
| 238 | + "no-undef": "off", |
| 239 | + "no-unused-expressions": "off", |
| 240 | + "no-unused-vars": "off", |
| 241 | + "no-var": "off", |
| 242 | + "quotes": "off", |
| 243 | + "space-before-function-paren": "off", |
| 244 | + "strict": "off" |
| 245 | + } |
| 246 | + } |
| 247 | +]; |
| 248 | + |
0 commit comments