Last active
July 5, 2022 15:51
-
-
Save Raizan/9a3341a1cc566f368a8ebcbebb7f50dd to your computer and use it in GitHub Desktop.
Favorite Eslint Rules for Mocha
This file contains hidden or 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
/** | |
* For .ts, install: | |
* @typescript-eslint/eslint-plugin | |
* @typescript-eslint/parser" | |
* | |
* For .js, delete these props: | |
* parser, plugins, overrides | |
*/ | |
module.exports = { | |
root: true, | |
parser: '@typescript-eslint/parser', | |
plugins: [ | |
'@typescript-eslint' | |
], | |
extends: [ | |
'eslint:recommended', | |
'semistandard' | |
], | |
env: { | |
node: true, | |
es6: true | |
}, | |
parserOptions: { | |
ecmaVersion: 2020, | |
sourceType: 'module' | |
}, | |
rules: { | |
'array-bracket-newline': [ | |
'error', | |
{ | |
minItems: 1 | |
} | |
], | |
'array-bracket-spacing': [ | |
'error', | |
'never' | |
], | |
'array-element-newline': [ | |
'error', | |
{ | |
multiline: true, | |
minItems: 1 | |
} | |
], | |
'brace-style': [ | |
'error', | |
'1tbs', | |
{ | |
allowSingleLine: true | |
} | |
], | |
camelcase: [ | |
'error', | |
{ | |
properties: 'never' | |
} | |
], | |
'comma-spacing': [ | |
'error', | |
{ | |
before: false, | |
after: true | |
} | |
], | |
indent: [ | |
'off', | |
2 | |
], | |
'keyword-spacing': [ | |
'error' | |
], | |
'max-statements-per-line': [ | |
'error', | |
{ | |
max: 1 | |
} | |
], | |
'no-console': 'error', | |
'no-else-return': 'error', | |
'no-lonely-if': 'error', | |
'no-multiple-empty-lines': [ | |
2, | |
{ | |
max: 1, | |
maxEOF: 1 | |
} | |
], | |
'no-param-reassign': 'error', | |
'no-shadow': 'error', | |
'no-tabs': 'error', | |
'no-trailing-spaces': [ | |
'error', | |
{ | |
skipBlankLines: false, | |
ignoreComments: false | |
} | |
], | |
'no-unexpected-multiline': 'off', | |
'no-unused-vars': [ | |
'error', | |
{ | |
varsIgnorePattern: '^_' | |
} | |
], | |
'no-var': 'error', | |
'object-curly-newline': [ | |
'error', | |
{ | |
ObjectExpression: { | |
multiline: true, | |
minProperties: 1 | |
}, | |
ObjectPattern: { | |
multiline: true | |
}, | |
ImportDeclaration: { | |
multiline: true, | |
minProperties: 3 | |
}, | |
ExportDeclaration: { | |
multiline: true, | |
minProperties: 3 | |
} | |
} | |
], | |
'object-curly-spacing': [ | |
'error', | |
'always' | |
], | |
'object-property-newline': [ | |
'error', | |
{ | |
allowAllPropertiesOnSameLine: false | |
} | |
], | |
quotes: [ | |
'error', | |
'single', | |
{ | |
avoidEscape: true | |
} | |
], | |
'space-before-function-paren': [ | |
'error', | |
{ | |
named: 'never' | |
} | |
], | |
'spaced-comment': 'error', | |
'unicode-bom': [ | |
'error', | |
'never' | |
], | |
yoda: 'error' | |
}, | |
overrides: [ | |
{ | |
files: [ | |
'*.ts' | |
], | |
rules: { | |
// see https://stackoverflow.com/questions/55280555/typescript-eslint-eslint-plugin-error-route-is-defined-but-never-used-no-un | |
'@typescript-eslint/no-unused-vars': 'error', | |
'no-unused-vars': 'off', | |
'no-undef': 'off', | |
// allow overloads | |
'no-redeclare': 'off' | |
} | |
} | |
] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment