eslint-config-xaxa
Version:
The ultimate ESLint config - successor to Airbnb Config. Built on Anthony Fu's ESLint config, Airbnb, ESLint Stylistic, Perfectionist, React, TypeScript, Astro, JSDocs, Prettier, Node.js, Unicorns, Promises, and more.
172 lines (171 loc) • 5.33 kB
JavaScript
import { GLOB_MARKDOWN_CODE } from "@antfu/eslint-config";
import { pluginNoUseExtendNative, pluginUnusedImports } from "../plugins.js";
export async function wgw(options) {
const { isAstro = false, isInEditor, isTypescript = true, overrides = {} } = { ...options };
const tsRules = {
"ts/no-explicit-any": "off",
"ts/no-unnecessary-template-expression": "off",
"ts/no-unused-vars": "off",
"ts/triple-slash-reference": "off"
};
return [
{
name: "xaxa/wgw/rules-and-overrides",
plugins: {
"no-use-extend-native": pluginNoUseExtendNative,
"unused-imports": pluginUnusedImports
},
rules: {
...isAstro ? { "astro/sort-attributes": ["error", {
ignoreCase: true,
order: "asc",
type: "alphabetical"
}] } : {},
...isTypescript ? tsRules : {},
"arrow-body-style": [
"error",
"as-needed",
{ requireReturnForObjectLiteral: false }
],
"camelcase": "off",
"class-methods-use-this": "off",
"consistent-return": "off",
"default-param-last": "error",
"func-names": ["error", "always"],
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"max-classes-per-file": "off",
"max-depth": ["error", { max: 4 }],
"max-nested-callbacks": ["error", { max: 4 }],
"max-params": ["error", { max: 6 }],
"max-statements": [
"error",
40,
{ ignoreTopLevelFunctions: true }
],
"no-await-in-loop": "off",
"no-console": "off",
"no-continue": "warn",
"no-empty": ["error", { allowEmptyCatch: true }],
"no-extend-native": "error",
"no-import-assign": "error",
"no-nested-ternary": "off",
"no-param-reassign": "off",
"no-plusplus": "off",
"no-restricted-exports": "off",
"no-restricted-syntax": [
"error",
"TSEnumDeclaration[const=true]",
"TSExportAssignment",
{
message: `for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.`,
selector: "ForInStatement"
},
{
message: `Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.`,
selector: "LabeledStatement"
},
{
message: `the "with" is disallowed in strict mode because it makes code impossible to predict and optimize.`,
selector: "WithStatement"
}
],
"no-underscore-dangle": "off",
"no-unnecessary-template-expression": "off",
"no-unsafe-optional-chaining": ["error", { disallowArithmeticOperators: true }],
"no-use-before-define": ["error", {
allowNamedExports: true,
classes: true,
functions: false,
variables: true
}],
"no-use-extend-native/no-use-extend-native": "error",
"no-useless-template-literals": "off",
"node/no-missing-import": "warn",
"node/no-unpublished-import": "warn",
"prefer-arrow-callback": ["error", {
allowNamedFunctions: true,
allowUnboundThis: true
}],
"prefer-const": [isInEditor ? "warn" : "error", { ignoreReadBeforeAssign: true }],
"prefer-destructuring": "off",
"prefer-object-has-own": "error",
"prefer-regex-literals": "error",
"sort-keys": "off",
"strict": ["off", "global"],
"style/arrow-parens": ["error", "always"],
"style/brace-style": [
"error",
"1tbs",
{ allowSingleLine: false }
],
"style/lines-between-class-members": ["error", { enforce: [
{
blankLine: "never",
next: "*",
prev: "field"
},
{
blankLine: "always",
next: "method",
prev: "field"
},
{
blankLine: "always",
next: "method",
prev: "method"
}
] }],
"style/max-statements-per-line": ["error", { max: 1 }],
"style/quote-props": "error",
"unused-imports/no-unused-imports": isInEditor ? "warn" : "error",
"unused-imports/no-unused-vars": ["error", {
args: "after-used",
argsIgnorePattern: "^(?:$$|xx|_|__|[iI]gnor(?:e|ing|ed))",
caughtErrors: "none",
ignoreRestSiblings: true,
vars: "all",
varsIgnorePattern: "^(?:$$|xx|_|__|[iI]gnor(?:e|ing|ed))"
}]
}
},
{
files: [GLOB_MARKDOWN_CODE],
name: "xaxa/markdown/disables",
rules: {
"antfu/no-top-level-await": "off",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off",
"no-alert": "off",
"no-console": "off",
"no-labels": "off",
"no-lone-blocks": "off",
"no-restricted-syntax": "off",
"no-undef": "off",
"no-unused-expressions": "off",
"no-unused-labels": "off",
"no-unused-vars": "off",
"node/no-missing-import": "off",
"node/no-unpublished-import": "off",
"node/prefer-global/process": "off",
"style/comma-dangle": "off",
"style/eol-last": "off",
"ts/consistent-type-imports": "off",
"ts/explicit-function-return-type": "off",
"ts/no-namespace": "off",
"ts/no-redeclare": "off",
"ts/no-require-imports": "off",
"ts/no-unused-expressions": "off",
"ts/no-unused-vars": "off",
"ts/no-use-before-define": "off",
"unicode-bom": "off",
"unused-imports/no-unused-imports": "off",
"unused-imports/no-unused-vars": "off"
}
},
{
name: "xaxa/wgw/user-overrides",
rules: { ...overrides }
}
];
}