@tangany/eslint-config
Version:
Tangany's ESLint config
169 lines (145 loc) • 5.12 kB
JavaScript
import TSESLint from "typescript-eslint";
export default TSESLint.config(
{
languageOptions: {
ecmaVersion: 6,
sourceType: "module",
},
rules: {
// enforces no braces where they can be omitted
// https://eslint.org/docs/rules/arrow-body-style
"arrow-body-style": [
"error",
"as-needed",
{
requireReturnForObjectLiteral: false,
},
],
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
"arrow-parens": ["error", "always"],
// require space before/after arrow function's arrow
// https://eslint.org/docs/rules/arrow-spacing
"arrow-spacing": ["error", { before: true, after: true }],
// enforce the spacing around the * in generator functions
// https://eslint.org/docs/rules/generator-star-spacing
"generator-star-spacing": ["error", { before: false, after: true }],
// disallow arrow functions where they could be confused with comparisons
// https://eslint.org/docs/rules/no-confusing-arrow
"no-confusing-arrow": [
"error",
{
allowParens: true,
},
],
// disallow symbol constructor
// https://eslint.org/docs/rules/no-new-symbol
"no-new-symbol": "error",
// Disallow specified names in exports
// https://eslint.org/docs/rules/no-restricted-exports
"no-restricted-exports": [
"error",
{
restrictedNamedExports: [
"default", // use `export default` to provide a default export
"then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
],
},
],
// disallow useless computed property keys
// https://eslint.org/docs/rules/no-useless-computed-key
"no-useless-computed-key": "error",
// disallow renaming import, export, and destructured assignments to the same name
// https://eslint.org/docs/rules/no-useless-rename
"no-useless-rename": [
"error",
{
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
},
],
// require let or const instead of var
"no-var": "error",
// require method and property shorthand syntax for object literals
// https://eslint.org/docs/rules/object-shorthand
"object-shorthand": [
"error",
"always",
{
ignoreConstructors: false,
avoidQuotes: true,
},
],
// suggest using arrow functions as callbacks
"prefer-arrow-callback": [
"error",
{
allowNamedFunctions: false,
allowUnboundThis: true,
},
],
// suggest using of const declaration for variables that are never modified after declared
"prefer-const": [
"error",
{
destructuring: "any",
ignoreReadBeforeAssign: true,
},
],
// Prefer destructuring from arrays and objects
// https://eslint.org/docs/rules/prefer-destructuring
"prefer-destructuring": [
"error",
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
},
{
enforceForRenamedProperties: false,
},
],
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
// https://eslint.org/docs/rules/prefer-numeric-literals
"prefer-numeric-literals": "error",
// use rest parameters instead of arguments
// https://eslint.org/docs/rules/prefer-rest-params
"prefer-rest-params": "error",
// suggest using the spread syntax instead of .apply()
// https://eslint.org/docs/rules/prefer-spread
"prefer-spread": "error",
// suggest using template literals instead of string concatenation
// https://eslint.org/docs/rules/prefer-template
"prefer-template": "error",
// enforce spacing between object rest-spread
// https://eslint.org/docs/rules/rest-spread-spacing
"rest-spread-spacing": ["error", "never"],
// import sorting
// https://eslint.org/docs/rules/sort-imports
"sort-imports": [
"off",
{
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ["none", "all", "multiple", "single"],
},
],
// require a Symbol description
// https://eslint.org/docs/rules/symbol-description
"symbol-description": "error",
// enforce usage of spacing in template strings
// https://eslint.org/docs/rules/template-curly-spacing
"template-curly-spacing": "error",
// enforce spacing around the * in yield* expressions
// https://eslint.org/docs/rules/yield-star-spacing
"yield-star-spacing": ["error", "after"],
},
},
);