-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract TypeScript-related rules to separate config
- Loading branch information
1 parent
8f67ad5
commit e032c3c
Showing
4 changed files
with
269 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,248 +1,8 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
env: { | ||
es6: true, | ||
node: true, | ||
}, | ||
extends: ['plugin:vue/base'], | ||
overrides: [ | ||
{ | ||
files: '*.ts', | ||
extends: [ | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:@typescript-eslint/recommended-requiring-type-checking', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
tsconfigRootDir: '.', | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/no-floating-promises': 'off', | ||
}, | ||
}, | ||
{ | ||
files: '*.js', | ||
extends: ['eslint:recommended'], | ||
parserOptions: { | ||
ecmaVersion: '2017', | ||
}, | ||
rules: { | ||
strict: ['error', 'global'], | ||
|
||
'jsdoc/no-undefined-types': 'warn', | ||
}, | ||
}, | ||
], | ||
plugins: ['jsdoc', 'vue'], | ||
rules: { | ||
/* | ||
* Possible errors | ||
*/ | ||
|
||
// Enforce "for" loop update clause moving the counter | ||
// in the right direction | ||
'for-direction': 'error', | ||
|
||
// Allow unnecessary parentheses | ||
'no-extra-parens': 'off', | ||
|
||
// Disallow template literal placeholder syntax in regular string | ||
'no-template-curly-in-string': 'error', | ||
|
||
/* | ||
* Best practices | ||
*/ | ||
|
||
// Enforce consistent brace style for all control statements | ||
curly: 'error', | ||
|
||
// Require the use of === and !== | ||
eqeqeq: 'error', | ||
|
||
// Disallow `else` blocks after `return` statements in `if` statements | ||
'no-else-return': 'error', | ||
|
||
// Disallow empty functions | ||
'no-empty-function': 'error', | ||
|
||
// Disallow function declarations and expressions inside loop statements | ||
'no-loop-func': 'error', | ||
|
||
// Disallow new operators with the String, Number, and Boolean objects | ||
'no-new-wrappers': 'error', | ||
|
||
// Disallow reassigning function parameters | ||
'no-param-reassign': 'error', | ||
|
||
// Disallow unnecessary concatenation of strings | ||
'no-useless-concat': 'error', | ||
|
||
// Disallow redundant return statements | ||
'no-useless-return': 'error', | ||
|
||
/* | ||
* Stylistic issues | ||
*/ | ||
|
||
// Require 'one true brace style', in which the opening brace | ||
// of a block is placed on the same line as its corresponding | ||
// statement or declaration | ||
'brace-style': ['error', '1tbs'], | ||
|
||
// Disallow spaces inside of brackets | ||
'array-bracket-spacing': ['error', 'never'], | ||
|
||
// Require CamelCase | ||
camelcase: ['error', { properties: 'never' }], | ||
|
||
// Require or disallow trailing commas | ||
'comma-dangle': [ | ||
'error', | ||
{ | ||
arrays: 'always-multiline', | ||
objects: 'always-multiline', | ||
imports: 'always-multiline', | ||
exports: 'never', | ||
functions: 'never', | ||
}, | ||
], | ||
|
||
// Require space after comma | ||
'comma-spacing': ['error', { after: true }], | ||
|
||
// Require newline at the end of files | ||
'eol-last': ['error', 'always'], | ||
|
||
// Disallow spacing between function identifiers and their invocations | ||
'func-call-spacing': 'error', | ||
|
||
// Use tabs as indentation | ||
// Enforce indentation level for case clauses in switch statements | ||
indent: ['error', 'tab', { SwitchCase: 1 }], | ||
|
||
// Require space after colon in object literal properties | ||
'key-spacing': ['error', { afterColon: true }], | ||
|
||
// Require space before and after keywords | ||
'keyword-spacing': 'error', | ||
|
||
// Require Unix line endings | ||
'linebreak-style': ['error', 'unix'], | ||
const { baseRules, jsRules } = require('./rules'); | ||
|
||
// Disallow empty block statements | ||
'no-empty': ['error', { allowEmptyCatch: true }], | ||
|
||
// Disallow `if` statements as the only statement in `else` blocks | ||
'no-lonely-if': 'error', | ||
|
||
// Disallow multiple spaces | ||
'no-multi-spaces': 'error', | ||
|
||
// Disallow nested ternary expressions | ||
'no-nested-ternary': 'error', | ||
|
||
// Disallow trailing whitespace at the end of lines | ||
'no-trailing-spaces': 'error', | ||
|
||
// Disallow ternary operators when simpler alternatives exist | ||
'no-unneeded-ternary': 'error', | ||
|
||
// Disallow whitespace before properties | ||
'no-whitespace-before-property': 'error', | ||
|
||
'one-var': ['error', 'never'], | ||
|
||
// Require spaces inside curly braces | ||
'object-curly-spacing': ['error', 'always'], | ||
|
||
// Require single quotes | ||
quotes: [ | ||
'error', | ||
'single', | ||
{ | ||
avoidEscape: true, | ||
}, | ||
], | ||
|
||
// Require space before blocks | ||
'space-before-blocks': ['error', 'always'], | ||
|
||
// Disallow a space before function parenthesis | ||
'space-before-function-paren': [ | ||
'error', | ||
{ | ||
named: 'never', | ||
anonymous: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
|
||
// Disallow spaces inside of parentheses | ||
'space-in-parens': 'error', | ||
|
||
// Require spacing around infix operators | ||
'space-infix-ops': 'error', | ||
|
||
// Enforce consistent spacing after the // or /* in a comment | ||
'spaced-comment': 'error', | ||
|
||
// Require semicolon at the end of statement | ||
semi: ['error', 'always'], | ||
|
||
// Enforce spacing around colons of switch statements | ||
'switch-colon-spacing': ['error', { after: true, before: false }], | ||
|
||
/* | ||
* ECMAScript 6 | ||
*/ | ||
|
||
// Require parentheses around arrow function arguments | ||
'arrow-parens': 'error', | ||
'arrow-spacing': 'error', | ||
|
||
// Require let or const instead of var | ||
'no-var': 'error', | ||
|
||
// Require method and property shorthand syntax for object literals | ||
'object-shorthand': ['error', 'always'], | ||
|
||
// Require `const` declarations for variables | ||
// that are never reassigned after declared | ||
'prefer-const': ['error', { destructuring: 'all' }], | ||
|
||
// Require template literals instead of string concatenation | ||
'prefer-template': 'error', | ||
|
||
// Disallow spacing around embedded expressions of template strings | ||
'template-curly-spacing': 'error', | ||
|
||
/* | ||
* JSDoc plugin | ||
*/ | ||
|
||
'jsdoc/check-param-names': 'warn', | ||
'jsdoc/check-syntax': 'warn', | ||
'jsdoc/check-tag-names': 'warn', | ||
'jsdoc/check-types': ['warn', { noDefaults: true }], | ||
'jsdoc/require-param': 'warn', | ||
'jsdoc/require-param-description': 'warn', | ||
'jsdoc/require-param-name': 'warn', | ||
'jsdoc/require-param-type': 'warn', | ||
'jsdoc/require-returns-check': 'warn', | ||
'jsdoc/require-returns-description': 'warn', | ||
'jsdoc/require-returns-type': 'warn', | ||
'jsdoc/valid-types': 'warn', | ||
}, | ||
settings: { | ||
jsdoc: { | ||
tagNamePreference: { | ||
class: 'constructor', | ||
returns: 'return', | ||
}, | ||
}, | ||
}, | ||
module.exports = { | ||
...baseRules, | ||
overrides: [jsRules], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.