This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
recommended.js
166 lines (137 loc) Β· 6.86 KB
/
recommended.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* Js-coding-standards
*
* @author Robert Rossmann <[email protected]>
* @copyright 2018 STRV
* @license http://choosealicense.com/licenses/bsd-3-clause BSD-3-Clause License
*/
'use strict'
module.exports = {
settings: {
// Correctly recognise .ts and .d.ts files when checking import paths against the filesystem
'import/resolver': {
node: {
extensions: [
'.ts',
'.d.ts',
'.mjs',
'.js',
'.json',
],
},
},
},
plugins: [
'@typescript-eslint',
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
env: {
es6: true,
},
rules: {
// TS code is mostly self-documented and having JSDoc directives for everything is redundant
// when you can easily infer return values and argument types from the code itself.
'valid-jsdoc': 'off',
// Disabled because it generates false positives with interface declarations and TypeScript
// blows up anyway during compilation when it encouters an undefined variable.
'no-undef': 'off',
// Require that member overloads be consecutive
// Grouping overloaded members together can improve readability of the code.
'@typescript-eslint/adjacent-overload-signatures': 'warn',
// Require PascalCased class and interface names
// This rule aims to make it easy to differentiate classes from regular variables at a glance.
'@typescript-eslint/class-name-casing': 'warn',
// Require explicit return types on functions and class methods
// Explicit types for function return values makes it clear to any calling code what type is
// returned. This ensures that the return value is assigned to a variable of the correct type;
// or in the case where there is no return value, that the calling code doesn't try to use the
// undefined value when it shouldn't.
'@typescript-eslint/explicit-function-return-type': ['warn', {
allowExpressions: true,
}],
// Require explicit accessibility modifiers on class properties and methods
// This rule aims to make code more readable and explicit about who can use which properties.
'@typescript-eslint/explicit-member-accessibility': 'warn',
// Require that interface names be prefixed with I
// It can be hard to differentiate between classes and interfaces. Prefixing interfaces with "I"
// can help telling them apart at a glance.
'@typescript-eslint/interface-name-prefix': ['warn', 'always'],
// Require a specific member delimiter style for interfaces and type literals
// This rule aims to standardise the way interface and type literal members are delimited.
'@typescript-eslint/member-delimiter-style': ['warn', {
multiline: {
delimiter: 'none',
},
singleline: {
delimiter: 'comma',
},
}],
// Require a consistent member declaration order
// A consistent ordering of fields, methods and constructors can make interfaces, type literals,
// classes and class expressions easier to read, navigate and edit.
'@typescript-eslint/member-ordering': 'warn',
// Enforces the use of `as Type` assertions instead of `<Type>` assertions
// This rule aims to standardise the use of type assertion style across the codebase.
'@typescript-eslint/no-angle-bracket-type-assertion': 'warn',
// Disallow generic Array constructors
// Use of the Array constructor to construct a new array is generally discouraged in favor of
// array literal notation because of the single-argument pitfall and because the Array global
// may be redefined.
'@typescript-eslint/no-array-constructor': 'error',
// Disallow the declaration of empty interfaces
// An empty interface is equivalent to its supertype. If the interface does not implement a
// supertype, then the interface is equivalent to an empty object ({}). In both cases it can be
// omitted.
'@typescript-eslint/no-empty-interface': 'warn',
// Disallows explicit type declarations for variables or parameters initialized to a number,
// string, or boolean
// This rule disallows explicit type declarations on parameters, variables and properties where
// the type can be easily inferred from its value.
'@typescript-eslint/no-explicit-any': 'warn',
// Disallow the use of custom TypeScript modules and namespaces
// Custom TypeScript modules (module foo {}) and namespaces (namespace foo {}) are considered
// outdated ways to organize TypeScript code. ES2015 module syntax is now preferred
// (import/export).
'@typescript-eslint/no-namespace': 'error',
// Disallow non-null assertions using the ! postfix operator
// Using non-null assertions cancels the benefits of the strict null-checking mode.
'@typescript-eslint/no-non-null-assertion': 'warn',
// Disallow the use of parameter properties in class constructors
// This rule disallows the use of parameter properties in constructors, forcing the user to
// explicitly declare all properties in the class.
'@typescript-eslint/no-parameter-properties': 'warn',
// Disallow /// <reference path="" /> comments
// Triple-slash reference directive comments should not be used anymore. Use import instead.
'@typescript-eslint/no-triple-slash-reference': 'error',
// Prevent TypeScript-specific constructs from being erroneously flagged as unused
// This rule only has an effect when the no-unused-vars core rule is enabled. It ensures that
// TypeScript-specific constructs, such as implemented interfaces, are not erroneously flagged
// as unused.
'@typescript-eslint/no-unused-vars': 'error',
// Disallow the use of variables before they are defined
// This rule will warn when it encounters a reference to an identifier that has not yet been
// declared.
'@typescript-eslint/no-use-before-define': ['error', {
functions: false,
classes: false,
typedefs: false,
}],
// Disallows the use of require statements except in import statements
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6
// style imports or import foo = require("foo") imports.
'@typescript-eslint/no-var-requires': 'error',
// Require the use of the namespace keyword instead of the module keyword to declare custom
// TypeScript modules
// In an effort to prevent further confusion between custom TypeScript modules and the new
// ES2015 modules, starting with TypeScript v1.5 the keyword namespace is now the preferred way
// to declare custom TypeScript modules.
'@typescript-eslint/prefer-namespace-keyword': 'warn',
// Require consistent spacing around type annotations
// This rule aims to enforce specific spacing patterns around type annotations and function
// types in type literals.
'@typescript-eslint/type-annotation-spacing': 'warn',
},
}