@odg/eslint-config 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/index.js +15 -0
- package/package.json +3 -1
- package/rules/global/base.js +5 -1
- package/rules/javascript/best-practices.js +0 -1
- package/rules/typescript/best-practices.js +6 -1
- package/rules/typescript/errors.js +1 -0
package/README.md
CHANGED
|
@@ -250,6 +250,7 @@
|
|
|
250
250
|
- [No Empty Import](#no-empty-import)
|
|
251
251
|
- [Export End File](#export-end-file)
|
|
252
252
|
- [Import First](#import-first)
|
|
253
|
+
- [No Named Default](#no-named-default)
|
|
253
254
|
- [Documentation](#documentation)
|
|
254
255
|
- [Space Comment](#spaced-comment)
|
|
255
256
|
- [Capitalized Comments](#capitalized-comments)
|
|
@@ -455,6 +456,7 @@
|
|
|
455
456
|
- [No Setter Return](#no-setter-return)
|
|
456
457
|
- [Useless Loop](#useless-loop)
|
|
457
458
|
- [No Loss Of Precision](#no-loss-of-precision)
|
|
459
|
+
- [No Unsafe Argument](#no-unsafe-argument)
|
|
458
460
|
- [No Dupe Class Members](#no-dupe-class-members)
|
|
459
461
|
- [No Dupe Keys](#no-dupe-keys)
|
|
460
462
|
- [Import Default Not Fount](#import-default-not-fount)
|
|
@@ -17132,6 +17134,59 @@ const x = 0X20000000000001
|
|
|
17132
17134
|
const x = 0X2_000000000_0001;
|
|
17133
17135
|
```
|
|
17134
17136
|
|
|
17137
|
+
### No Unsafe Argument
|
|
17138
|
+
|
|
17139
|
+
----------
|
|
17140
|
+
|
|
17141
|
+
Disallow calling a function with a value with type `any`.
|
|
17142
|
+
|
|
17143
|
+
<https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-unsafe-argument.md>
|
|
17144
|
+
|
|
17145
|
+
👍 Examples of correct code
|
|
17146
|
+
|
|
17147
|
+
```typescript
|
|
17148
|
+
declare function foo(arg1: string, arg2: number, arg3: string): void;
|
|
17149
|
+
|
|
17150
|
+
foo('a', 1, 'b');
|
|
17151
|
+
|
|
17152
|
+
const tuple1 = ['a', 1, 'b'] as const;
|
|
17153
|
+
foo(...tuple1);
|
|
17154
|
+
|
|
17155
|
+
declare function bar(arg1: string, arg2: number, ...rest: string[]): void;
|
|
17156
|
+
const array: string[] = ['a'];
|
|
17157
|
+
bar('a', 1, ...array);
|
|
17158
|
+
|
|
17159
|
+
declare function baz(arg1: Set<string>, arg2: Map<string, string>): void;
|
|
17160
|
+
foo(new Set<string>(), new Map<string, string>());
|
|
17161
|
+
```
|
|
17162
|
+
|
|
17163
|
+
👎 Examples of incorrect code
|
|
17164
|
+
|
|
17165
|
+
```typescript
|
|
17166
|
+
declare function foo(arg1: string, arg2: number, arg3: string): void;
|
|
17167
|
+
|
|
17168
|
+
const anyTyped = 1 as any;
|
|
17169
|
+
|
|
17170
|
+
foo(...anyTyped);
|
|
17171
|
+
foo(anyTyped, 1, 'a');
|
|
17172
|
+
|
|
17173
|
+
const anyArray: any[] = [];
|
|
17174
|
+
foo(...anyArray);
|
|
17175
|
+
|
|
17176
|
+
const tuple1 = ['a', anyTyped, 'b'] as const;
|
|
17177
|
+
foo(...tuple1);
|
|
17178
|
+
|
|
17179
|
+
const tuple2 = [1] as const;
|
|
17180
|
+
foo('a', ...tuple, anyTyped);
|
|
17181
|
+
|
|
17182
|
+
declare function bar(arg1: string, arg2: number, ...rest: string[]): void;
|
|
17183
|
+
const x = [1, 2] as [number, ...number[]];
|
|
17184
|
+
foo('a', ...x, anyTyped);
|
|
17185
|
+
|
|
17186
|
+
declare function baz(arg1: Set<string>, arg2: Map<string, string>): void;
|
|
17187
|
+
foo(new Set<any>(), new Map<any, string>());
|
|
17188
|
+
```
|
|
17189
|
+
|
|
17135
17190
|
### Import Default Not Fount
|
|
17136
17191
|
|
|
17137
17192
|
----------
|
package/index.js
CHANGED
|
@@ -111,6 +111,21 @@ module.exports = {
|
|
|
111
111
|
"./rules/typescript/possible-errors.js",
|
|
112
112
|
],
|
|
113
113
|
parser: "@typescript-eslint/parser",
|
|
114
|
+
settings: {
|
|
115
|
+
"import/extensions": [ ".mjs", ".js", ".jsx", ".json", ".ts", ".tsx", ".d.ts" ],
|
|
116
|
+
"import/external-module-folders": [ "node_modules", "node_modules/@types" ],
|
|
117
|
+
"import/parsers": {
|
|
118
|
+
"@typescript-eslint/parser": [ ".ts", ".tsx" ],
|
|
119
|
+
},
|
|
120
|
+
"import/resolver": {
|
|
121
|
+
"typescript": {
|
|
122
|
+
"project": [ "tsconfig.json" ],
|
|
123
|
+
},
|
|
124
|
+
"node": {
|
|
125
|
+
"extensions": [ ".mjs", ".js", ".jsx", ".json", ".ts", ".tsx", ".d.ts" ],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
},
|
|
114
129
|
parserOptions: {
|
|
115
130
|
ecmaFeatures: {
|
|
116
131
|
jsx: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@odg/eslint-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Linter for JavaScript And Typescript project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Dragons Gamers <https://www.linkedin.com/in/victor-alves-odgodinho>",
|
|
@@ -20,11 +20,13 @@
|
|
|
20
20
|
"eslint": "*"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@babel/core": "*",
|
|
23
24
|
"@odg/tsconfig": "*",
|
|
24
25
|
"@typescript-eslint/eslint-plugin": "*",
|
|
25
26
|
"@typescript-eslint/parser": "*",
|
|
26
27
|
"any-eslint-parser": "^1.0.1",
|
|
27
28
|
"eslint": "*",
|
|
29
|
+
"eslint-import-resolver-typescript": "^3.5.3",
|
|
28
30
|
"eslint-plugin-array-func": "^3.1.8",
|
|
29
31
|
"eslint-plugin-file-progress": "^1.3.0",
|
|
30
32
|
"eslint-plugin-filenames": "^1.3.2",
|
package/rules/global/base.js
CHANGED
|
@@ -17,7 +17,11 @@ module.exports = {
|
|
|
17
17
|
ignoreComments: false,
|
|
18
18
|
} ], // 4 spaces
|
|
19
19
|
"quotes": [ "error", "double" ], // Aspas duplas
|
|
20
|
-
"capitalized-comments": [ "error"
|
|
20
|
+
"capitalized-comments": [ "error", "always", {
|
|
21
|
+
"line": {
|
|
22
|
+
"ignorePattern": "region",
|
|
23
|
+
},
|
|
24
|
+
} ], // Comentários devem ser iniciados em letras maiúsculas
|
|
21
25
|
"space-before-function-paren": [ "error", {
|
|
22
26
|
anonymous: "never",
|
|
23
27
|
named: "never",
|
|
@@ -447,6 +447,5 @@ module.exports = {
|
|
|
447
447
|
"sonar/production-debug": [ "error" ], // Não use debug em prod
|
|
448
448
|
"sonar/shorthand-property-grouping": [ "error" ], // Agrupe { a, b, c:1, d:2}
|
|
449
449
|
"sonar/unused-named-groups": [ "error" ], // Grupos não usados de regex
|
|
450
|
-
|
|
451
450
|
},
|
|
452
451
|
};
|
|
@@ -22,7 +22,7 @@ const allAccessibility = [
|
|
|
22
22
|
* @param {Array<string>} accessibilityList Accessibility list
|
|
23
23
|
* @returns {Array<string>}
|
|
24
24
|
*/
|
|
25
|
-
function orderMember
|
|
25
|
+
function orderMember(types, tag, accessibilityList) {
|
|
26
26
|
return [ ...accessibilityList.flatMap((accessibility) => types.map(
|
|
27
27
|
(type) => {
|
|
28
28
|
const accessibilityName = accessibility ? `${accessibility}-` : "";
|
|
@@ -383,6 +383,9 @@ module.exports = {
|
|
|
383
383
|
"should",
|
|
384
384
|
"will",
|
|
385
385
|
"did",
|
|
386
|
+
"does",
|
|
387
|
+
"are",
|
|
388
|
+
"do",
|
|
386
389
|
],
|
|
387
390
|
},
|
|
388
391
|
{
|
|
@@ -472,5 +475,7 @@ module.exports = {
|
|
|
472
475
|
"ignoreReadonlyClassProperties": true,
|
|
473
476
|
},
|
|
474
477
|
], // Não permite numero mágicos
|
|
478
|
+
"@typescript-eslint/prefer-for-of": "error",
|
|
479
|
+
"@typescript-eslint/restrict-plus-operands": [ "error", { "checkCompoundAssignments": true } ],
|
|
475
480
|
}, // Convenção de nomes
|
|
476
481
|
};
|
|
@@ -20,5 +20,6 @@ module.exports = {
|
|
|
20
20
|
"error",
|
|
21
21
|
], // Não coloque dentro de string algo q n pode ser convertido
|
|
22
22
|
"@typescript-eslint/no-loss-of-precision": [ "error" ], // Não permite números com perda de precisão
|
|
23
|
+
"@typescript-eslint/no-unsafe-argument": [ "error" ], // Não permite argumentos inseguros função
|
|
23
24
|
},
|
|
24
25
|
};
|