-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
117 lines (116 loc) · 3.38 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const path = require('path');
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 11,
sourceType: 'module',
tsconfigRootDir: __dirname,
project: path.join(__dirname, 'tsconfig.json')
},
env: {
browser: true,
node: true,
commonjs: true,
es2020: true
},
globals: {
NodeJS: 'readonly'
},
plugins: ['@typescript-eslint', 'tsdoc', 'jsdoc', 'prettier'],
extends: [
'eslint:recommended',
'airbnb',
'airbnb-typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
'plugin:prettier/recommended'
],
rules: {
// Too restrictive, writing ugly code to defend against a very unlikely scenario: https://eslint.org/docs/rules/no-prototype-builtins
'no-prototype-builtins': 'off',
'no-bitwise': 'warn',
// why not?
'no-plusplus': 'off',
// Use function hoisting to improve code readability
'no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true }
],
// allow voids as statements
// https://eslint.org/docs/rules/no-void
'no-void': [
'error',
{
allowAsStatement: true
}
],
// eslint does not detect exported members properly
'no-unused-vars': 'off',
// why not?
'@typescript-eslint/no-this-alias': 'off',
// Makes no sense to allow type inference for expression parameters, but require typing the response
'@typescript-eslint/explicit-function-return-type': [
'error',
{ allowExpressions: true, allowTypedFunctionExpressions: true }
],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true, typedefs: true }
],
// if you use explicit any type, you know what you are doing
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
// allow numeric types in template expressions
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/restrict-template-expressions.md
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNumber: true,
allowAny: true
}
],
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
// documentation via fliegdoc
'tsdoc/syntax': 'error',
'@typescript-eslint/no-inferrable-types': 0,
'jsdoc/require-jsdoc': [
'error',
{
contexts: [
'TSInterfaceDeclaration',
'TSTypeAliasDeclaration',
'TSEnumDeclaration'
]
}
],
'jsdoc/require-description': 1,
'jsdoc/require-param-description': 'error',
'jsdoc/require-hyphen-before-param-description': 'error',
'jsdoc/no-types': 'error',
'jsdoc/require-throws': 'error',
'jsdoc/require-param-type': 0,
'jsdoc/require-property-type': 0,
'jsdoc/require-returns-type': 0,
'jsdoc/require-example': 2,
// treat wrong format as warning instead of error
// to inform the user and not slap him
'prettier/prettier': 'warn'
},
ignorePatterns: ['scripts', 'sample', 'types', '.eslintrc.js', 'docs'],
overrides: [
{
files: ['src/index.ts'],
rules: {
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
}
]
};