Skip to content

Instantly share code, notes, and snippets.

@Ascor8522
Last active September 16, 2023 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ascor8522/ad41cb490687adb2f06df70bc72f55bc to your computer and use it in GitHub Desktop.
Save Ascor8522/ad41cb490687adb2f06df70bc72f55bc to your computer and use it in GitHub Desktop.
My custom ESLint config
/**
* Dependencies:
* ```sh
* npm i -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-deprecation eslint-plugin-import eslint-plugin-only-warn
* ```
* @type {import("eslint").ESLint.ConfigData}
*/
module.exports = {
/* eslint-disable quote-props */
env: {
browser: true,
es6: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict",
],
rules: {
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/explicit-member-accessibility": ["warn", { "accessibility": "explicit" }],
"@typescript-eslint/indent": ["warn", "tab"],
"indent": "off",
"@typescript-eslint/member-delimiter-style": ["off", "semi"],
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/naming-convention": ["warn", { "selector": "enumMember", "format": null, "custom": { "regex": "[A-Z][A-Z0-9_]*[a-z0-9_]*", "match": true } }],
"@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/no-empty-function": ["warn", { "allow": ["constructors", "overrideMethods"] }],
"no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-extra-parens": "warn",
"no-extra-parens": "off",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-magic-numbers": ["warn", { "ignoreReadonlyClassProperties": true }],
"no-magic-numbers": "off",
"@typescript-eslint/no-misused-new": "warn",
"@typescript-eslint/no-misused-promises": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-shadow": "warn",
"no-shadow": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unused-expressions": "warn",
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
"no-unused-vars": "off",
"@typescript-eslint/no-use-before-define": "warn",
"no-use-before-define": "off",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/quotes": ["warn", "double", { "allowTemplateLiterals": true }],
"quotes": "off",
"@typescript-eslint/semi": ["warn", "always"],
"semi": "off",
"@typescript-eslint/type-annotation-spacing": "warn",
"@typescript-eslint/unified-signatures": "warn",
"array-callback-return": ["warn", { "checkForEach": false }],
"arrow-body-style": ["warn", "as-needed"],
"arrow-parens": ["warn", "as-needed"],
"brace-style": ["warn", "1tbs"],
"comma-dangle": ["warn", "always-multiline"],
"constructor-super": "warn",
"curly": ["warn", "multi"],
"deprecation/deprecation": "warn",
"dot-notation": "warn",
"eol-last": ["warn", "always"],
"eqeqeq": ["warn", "always", { "null": "ignore" }],
"guard-for-in": "warn",
"jsdoc/newline-after-description": "off",
"max-len": "off",
"no-bitwise": "warn",
"no-caller": "warn",
"no-console": "warn",
"no-debugger": "warn",
"no-empty": "warn",
"no-eval": "warn",
"no-fallthrough": "warn",
"no-new-wrappers": "warn",
"no-return-await": "warn",
"no-throw-literal": "warn",
"no-trailing-spaces": "warn",
"no-underscore-dangle": ["warn", { "allowInArrayDestructuring": true, "allowInObjectDestructuring": true, "allowFunctionParams": true }],
"no-unused-labels": "warn",
"no-useless-return": "warn",
"no-var": "warn",
"prefer-arrow/prefer-arrow-functions": "off",
"prefer-const": "warn",
"quote-props": ["warn", "as-needed", { "keywords": false, "numbers": true }],
"radix": "warn",
"spaced-comment": ["warn", "always"],
"no-restricted-syntax": ["warn", {
"selector": "MethodDefinition[static = true] ThisExpression",
"message": "Don't use 'this' on static methods and properties.",
}],
},
overrides: [
{
files: ["src/**/*.ts"],
}
],
parser: "@typescript-eslint/parser",
parserOptions: {
createDefaultProgram: true,
project: [
"tsconfig.json",
],
},
plugins: [
"@typescript-eslint",
"deprecation",
"eslint-plugin-import",
"only-warn",
],
root: true,
};
/**
* @type {import("eslint").ESLint.ConfigData}
*/
module.exports = { /* eslint-disable quote-props */
env: {
browser: true,
es6: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@typescript-eslint/strict",
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
],
rules: {
"@angular-eslint/component-class-suffix": "warn",
"@angular-eslint/directive-class-suffix": "warn",
"@angular-eslint/no-host-metadata-property": "warn",
"@angular-eslint/no-input-rename": "off",
"@angular-eslint/no-inputs-metadata-property": "warn",
"@angular-eslint/no-output-on-prefix": "warn",
"@angular-eslint/no-output-rename": "warn",
"@angular-eslint/no-outputs-metadata-property": "warn",
"@angular-eslint/use-lifecycle-interface": "warn",
"@angular-eslint/use-pipe-transform-interface": "warn",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/explicit-member-accessibility": ["warn", { "accessibility": "explicit" }],
"@typescript-eslint/indent": ["warn", "tab"],
"indent": "off",
"@typescript-eslint/member-delimiter-style": ["off", "semi"],
"@typescript-eslint/naming-convention": ["warn", { "selector": "enumMember", "format": null, "custom": { "regex": "[A-Z][A-Z0-9_]*[a-z0-9_]*", "match": true } }],
"@typescript-eslint/no-dynamic-delete": "off",
"@typescript-eslint/no-empty-function": ["warn", { "allow": ["constructors", "overrideMethods"] }],
"no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-extra-parens": "warn",
"no-extra-parens": "off",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/no-magic-numbers": ["warn", { "ignoreReadonlyClassProperties": true }],
"no-magic-numbers": "off",
"@typescript-eslint/no-misused-new": "warn",
"@typescript-eslint/no-misused-promises": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-shadow": "warn",
"no-shadow": "off",
"@typescript-eslint/no-unused-expressions": "warn",
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }],
"no-unused-vars": "off",
"@typescript-eslint/no-use-before-define": "warn",
"no-use-before-define": "off",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/quotes": ["warn", "double", { "allowTemplateLiterals": true }],
"quotes": "off",
"@typescript-eslint/semi": ["warn", "always"],
"semi": "off",
"@typescript-eslint/type-annotation-spacing": "warn",
"@typescript-eslint/unified-signatures": "warn",
"array-callback-return": ["warn", { "checkForEach": false }],
"arrow-body-style": ["warn", "as-needed"],
"arrow-parens": ["warn", "as-needed"],
"brace-style": ["warn", "1tbs"],
"comma-dangle": ["warn", "always-multiline"],
"constructor-super": "warn",
"curly": ["warn", "multi"],
"deprecation/deprecation": "warn",
"dot-notation": "warn",
"eol-last": ["warn", "always"],
"eqeqeq": ["warn", "always"],
"guard-for-in": "warn",
"jsdoc/newline-after-description": "off",
"max-len": "off",
"no-bitwise": "warn",
"no-caller": "warn",
"no-console": "warn",
"no-debugger": "warn",
"no-empty": "warn",
"no-eval": "warn",
"no-fallthrough": "warn",
"no-new-wrappers": "warn",
"no-return-await": "warn",
"no-throw-literal": "warn",
"no-trailing-spaces": "warn",
"no-underscore-dangle": ["warn", { "allowInArrayDestructuring": true, "allowInObjectDestructuring": true, "allowFunctionParams": true }],
"no-unused-labels": "warn",
"no-useless-return": "warn",
"no-var": "warn",
"prefer-arrow/prefer-arrow-functions": "off",
"prefer-const": "warn",
"quote-props": ["warn", "as-needed", { "keywords": false, "numbers": true }],
"radix": "warn",
"spaced-comment": ["warn", "always"],
"no-restricted-syntax": ["warn", {
"selector": "MethodDefinition[static = true] ThisExpression",
"message": "Don't use 'this' on static methods and properties.",
}],
},
parser: "@typescript-eslint/parser",
parserOptions: {
createDefaultProgram: true,
project: [
"tsconfig.json",
],
},
plugins: [
"@angular-eslint/eslint-plugin",
"@typescript-eslint",
"deprecation",
"eslint-plugin-import",
"only-warn",
],
overrides: [
{
files: [
"./src/**/*.ts",
"./e2e/**/*.ts",
],
},
{
files: [
"./src/**/*.html",
],
extends: [
// "plugin:@angular-eslint/template/recommended",
],
},
],
root: true,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment