@odg/eslint-config 1.2.0 → 1.3.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 CHANGED
@@ -300,6 +300,7 @@
300
300
  - [Sort Character Class Elements](#sort-character-class-elements)
301
301
  - [Sort Flags](#sort-flags)
302
302
  - [Prefer Named Capture Group](#prefer-named-capture-group)
303
+ - [Prefer Regexp Exec](#prefer-regexp-exec)
303
304
  - [Security](#security)
304
305
  - [Eval Disabled](#eval-disabled)
305
306
  - [Detect Unsafe Regex](#detect-unsafe-regex)
@@ -396,6 +397,11 @@
396
397
  - [Prefer Nullish Coalescing](#prefer-nullish-coalescing)
397
398
  - [Prefer Optional Chain](#prefer-optional-chain)
398
399
  - [Prefer Readonly](#prefer-readonly)
400
+ - [Prefer Reduce Type Parameter](#prefer-reduce-type-parameter)
401
+ - [Promise Function Async](#promise-function-async)
402
+ - [Require Array Sort Compare](#require-array-sort-compare)
403
+ - [Sort Type Constituents](#sort-type-constituents)
404
+ - [Space Before Blocks](#space-before-blocks)
399
405
  - [Performance](#performance)
400
406
  - [No Alert](#no-alert)
401
407
  - [No Loop Func](#no-loop-func)
@@ -457,6 +463,9 @@
457
463
  - [No Non Null Asserted Optional Chain](#no-non-null-asserted-optional-chain)
458
464
  - [No Unsafe Declaration Merging](#no-unsafe-declaration-merging)
459
465
  - [No Useless Empty Export](#no-useless-empty-export)
466
+ - [Restrict Template Expressions](#restrict-template-expressions)
467
+ - [Return Await Try Catch](#return-await-try-catch)
468
+ - [Switch Exhaustiveness Check](#switch-exhaustiveness-check)
460
469
  - [YAML / JSON](#yaml-json)
461
470
 
462
471
  ## Introduction
@@ -993,6 +1002,7 @@ class Foo {
993
1002
 
994
1003
  Enforces default parameters to be last.
995
1004
 
1005
+ <https://eslint.org/docs/latest/rules/space-before-function-paren>
996
1006
  <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/space-before-function-paren.md>
997
1007
 
998
1008
  👍 Examples of correct code
@@ -10362,6 +10372,39 @@ var foo = /\b(?:foo)+\b/;
10362
10372
  var foo = /\b(foo)+\b/;
10363
10373
  ```
10364
10374
 
10375
+ ### Prefer Regexp Exec
10376
+
10377
+ ----------
10378
+
10379
+ RegExp#exec is faster than String#match and both work the same when not using the /g flag.
10380
+
10381
+ <https://ota-meshi.github.io/eslint-plugin-regexp/rules/prefer-regexp-exec.html>
10382
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md>
10383
+
10384
+ 👍 Examples of correct code
10385
+
10386
+ ```typescript
10387
+ /thing/.exec('something');
10388
+
10389
+ 'some things are just things'.match(/thing/g);
10390
+
10391
+ const text = 'something';
10392
+ const search = /thing/;
10393
+ search.exec(text);
10394
+ ```
10395
+
10396
+ 👎 Examples of incorrect code
10397
+
10398
+ ```typescript
10399
+ 'something'.match(/thing/);
10400
+
10401
+ 'some things are just things'.match(/thing/);
10402
+
10403
+ const text = 'something';
10404
+ const search = /thing/;
10405
+ text.match(search);
10406
+ ```
10407
+
10365
10408
  ## Security
10366
10409
 
10367
10410
  ### Eval Disabled
@@ -12473,6 +12516,7 @@ string.replace(/Works for u flag too/gu, "");
12473
12516
  Prefer String#startsWith() & String#endsWith() over RegExp#test()
12474
12517
 
12475
12518
  <https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-string-starts-ends-with.md>
12519
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md>
12476
12520
 
12477
12521
  👍 Examples of correct code
12478
12522
 
@@ -12490,6 +12534,28 @@ const foo = /^bar/i.test(baz);
12490
12534
  ```typescript
12491
12535
  const foo = /^bar/.test(baz);
12492
12536
  const foo = /bar$/.test(baz);
12537
+
12538
+ // or
12539
+
12540
+ declare const foo: string;
12541
+
12542
+ // starts with
12543
+ foo[0] === 'b';
12544
+ foo.charAt(0) === 'b';
12545
+ foo.indexOf('bar') === 0;
12546
+ foo.slice(0, 3) === 'bar';
12547
+ foo.substring(0, 3) === 'bar';
12548
+ foo.match(/^bar/) != null;
12549
+ /^bar/.test(foo);
12550
+
12551
+ // ends with
12552
+ foo[foo.length - 1] === 'b';
12553
+ foo.charAt(foo.length - 1) === 'b';
12554
+ foo.lastIndexOf('bar') === foo.length - 3;
12555
+ foo.slice(-3) === 'bar';
12556
+ foo.substring(foo.length - 3) === 'bar';
12557
+ foo.match(/bar$/) != null;
12558
+ /bar$/.test(foo);
12493
12559
  ```
12494
12560
 
12495
12561
  ## Prefer String Trim Start End
@@ -12966,12 +13032,17 @@ Instead, it's generally better to correct the types of code, to make directives
12966
13032
 
12967
13033
  ```typescript
12968
13034
  if (false) {
12969
- // @ts-ignore: Unreachable code error
13035
+ // Compiler warns about unreachable code error
13036
+ console.log('hello');
13037
+ }
13038
+
13039
+ if (false) {
13040
+ // @ts-expect-error: Unreachable code error
12970
13041
  console.log('hello');
12971
13042
  }
12972
13043
  if (false) {
12973
13044
  /*
12974
- @ts-ignore: Unreachable code error
13045
+ @ts-expect-error: Unreachable code error
12975
13046
  */
12976
13047
  console.log('hello');
12977
13048
  }
@@ -12981,17 +13052,12 @@ if (false) {
12981
13052
 
12982
13053
  ```typescript
12983
13054
  if (false) {
12984
- // Compiler warns about unreachable code error
12985
- console.log('hello');
12986
- }
12987
-
12988
- if (false) {
12989
- // @ts-expect-error: Unreachable code error
13055
+ // @ts-ignore: Unreachable code error
12990
13056
  console.log('hello');
12991
13057
  }
12992
13058
  if (false) {
12993
13059
  /*
12994
- @ts-expect-error: Unreachable code error
13060
+ @ts-ignore: Unreachable code error
12995
13061
  */
12996
13062
  console.log('hello');
12997
13063
  }
@@ -13960,6 +14026,256 @@ class Container {
13960
14026
  }
13961
14027
  ```
13962
14028
 
14029
+ ## Prefer Reduce Type Parameter
14030
+
14031
+ ----------
14032
+
14033
+ It's common to call Array#reduce with a generic type, such as an array or object, as the initial value.
14034
+ Since these values are empty, their types are not usable:
14035
+
14036
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md>
14037
+
14038
+ 👍 Examples of correct code
14039
+
14040
+ ```typescript
14041
+ [1, 2, 3].reduce<number[]>((arr, num) => arr.concat(num * 2), []);
14042
+
14043
+ ['a', 'b'].reduce<Record<string, boolean>>(
14044
+ (accum, name) => ({
14045
+ ...accum,
14046
+ [name]: true,
14047
+ }),
14048
+ {},
14049
+ );
14050
+ ```
14051
+
14052
+ 👎 Examples of incorrect code
14053
+
14054
+ ```typescript
14055
+ [1, 2, 3].reduce((arr, num) => arr.concat(num * 2), [] as number[]);
14056
+
14057
+ ['a', 'b'].reduce(
14058
+ (accum, name) => ({
14059
+ ...accum,
14060
+ [name]: true,
14061
+ }),
14062
+ {} as Record<string, boolean>,
14063
+ );
14064
+ ```
14065
+
14066
+ ## Promise Function Async
14067
+
14068
+ ----------
14069
+
14070
+ In contrast, non-async Promise - returning functions are technically capable of either.
14071
+ Code that handles the results of those functions will often need to handle both cases,
14072
+ which can get complex. This rule's practice removes a requirement for creating code to handle both cases.
14073
+
14074
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/promise-function-async.md>
14075
+
14076
+ 👍 Examples of correct code
14077
+
14078
+ ```typescript
14079
+ const arrowFunctionReturnsPromise = async () => Promise.resolve('value');
14080
+
14081
+ async function functionReturnsPromise() {
14082
+ return Promise.resolve('value');
14083
+ }
14084
+ ```
14085
+
14086
+ 👎 Examples of incorrect code
14087
+
14088
+ ```typescript
14089
+ const arrowFunctionReturnsPromise = () => Promise.resolve('value');
14090
+
14091
+ function functionReturnsPromise() {
14092
+ return Promise.resolve('value');
14093
+ }
14094
+ ```
14095
+
14096
+ ## Require Array Sort Compare
14097
+
14098
+ ----------
14099
+
14100
+ When called without a compare function, Array#sort() converts all non-undefined array elements
14101
+ into strings and then compares said strings based off their UTF-16
14102
+
14103
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/require-array-sort-compare.md>
14104
+
14105
+ 👍 Examples of correct code
14106
+
14107
+ ```typescript
14108
+ const array: any[];
14109
+ const userDefinedType: { sort(): void };
14110
+
14111
+ array.sort((a, b) => a - b);
14112
+ array.sort((a, b) => a.localeCompare(b));
14113
+
14114
+ userDefinedType.sort();
14115
+
14116
+ const one = '1';
14117
+ const two = '2';
14118
+ const three = '3';
14119
+ [one, two, three].sort();
14120
+ ```
14121
+
14122
+ 👎 Examples of incorrect code
14123
+
14124
+ ```typescript
14125
+ const array: any[];
14126
+ const stringArray: string[];
14127
+
14128
+ array.sort();
14129
+
14130
+ // String arrays should be sorted using `String#localeCompare`.
14131
+ stringArray.sort();
14132
+ ```
14133
+
14134
+ ## Sort Type Constituents
14135
+
14136
+ ----------
14137
+
14138
+ Sorting union (|) and intersection (&) types can help:
14139
+
14140
+ keep your codebase standardized
14141
+ find repeated types
14142
+ reduce diff churn
14143
+ This rule reports on any types that aren't sorted alphabetically.
14144
+
14145
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/sort-type-constituents.md>
14146
+
14147
+ 👍 Examples of correct code
14148
+
14149
+ ```typescript
14150
+ type T1 = A | B;
14151
+
14152
+ type T2 = { a: string } & { b: string };
14153
+
14154
+ type T3 = [1, 2, 3] & [1, 2, 4];
14155
+
14156
+ type T4 =
14157
+ | any
14158
+ | string
14159
+ | A
14160
+ | B
14161
+ | number[]
14162
+ | string[]
14163
+ | readonly number[]
14164
+ | readonly string[]
14165
+ | 'a'
14166
+ | 'b'
14167
+ | 'a'
14168
+ | 'b'
14169
+ | (() => string)
14170
+ | (() => void)
14171
+ | { a: string }
14172
+ | { b: string }
14173
+ | [1, 2, 3]
14174
+ | [1, 2, 4];
14175
+ ```
14176
+
14177
+ 👎 Examples of incorrect code
14178
+
14179
+ ```typescript
14180
+ type T1 = B | A;
14181
+
14182
+ type T2 = { b: string } & { a: string };
14183
+
14184
+ type T3 = [1, 2, 4] & [1, 2, 3];
14185
+
14186
+ type T4 =
14187
+ | [1, 2, 4]
14188
+ | [1, 2, 3]
14189
+ | { b: string }
14190
+ | { a: string }
14191
+ | (() => void)
14192
+ | (() => string)
14193
+ | 'b'
14194
+ | 'a'
14195
+ | 'b'
14196
+ | 'a'
14197
+ | readonly string[]
14198
+ | readonly number[]
14199
+ | string[]
14200
+ | number[]
14201
+ | B
14202
+ | A
14203
+ | string
14204
+ | any;
14205
+ ```
14206
+
14207
+ ## Space Before Blocks
14208
+
14209
+ ----------
14210
+
14211
+ Consistency is an important part of any style guide. While it is a personal preference where to put the opening
14212
+ brace of blocks, it should be consistent across a whole project. Having an inconsistent style distracts the reader
14213
+ from seeing the important parts of the code.
14214
+
14215
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/space-before-blocks.md>
14216
+
14217
+ 👍 Examples of correct code
14218
+
14219
+ ```typescript
14220
+ if (a) {
14221
+ b();
14222
+ }
14223
+
14224
+ if (a) {
14225
+ b();
14226
+ } else{ /*no error. this is checked by `keyword-spacing` rule.*/
14227
+ c();
14228
+ }
14229
+
14230
+ class C {
14231
+ static{} /*no error. this is checked by `keyword-spacing` rule.*/
14232
+ }
14233
+
14234
+ function a() {}
14235
+
14236
+ for (;;) {
14237
+ b();
14238
+ }
14239
+
14240
+ try {} catch(a) {}
14241
+
14242
+ enum Breakpoint {
14243
+ Large, Medium;
14244
+ }
14245
+
14246
+ interface State {
14247
+ currentBreakpoint: Breakpoint;
14248
+ }
14249
+ ```
14250
+
14251
+ 👎 Examples of incorrect code
14252
+
14253
+ ```typescript
14254
+ if (a){
14255
+ b();
14256
+ }
14257
+
14258
+ function a(){}
14259
+
14260
+ for (;;){
14261
+ b();
14262
+ }
14263
+
14264
+ try {} catch(a){}
14265
+
14266
+ class Foo{
14267
+ constructor(){}
14268
+ }
14269
+
14270
+ enum Breakpoint{
14271
+ Large, Medium;
14272
+ }
14273
+
14274
+ interface State{
14275
+ currentBreakpoint: Breakpoint;
14276
+ }
14277
+ ```
14278
+
13963
14279
  ## Performance
13964
14280
 
13965
14281
  ### No Alert
@@ -16655,7 +16971,7 @@ foo?.bar!;
16655
16971
  foo?.bar()!;
16656
16972
  ```
16657
16973
 
16658
- ## No Unsafe Declaration Merging
16974
+ ### No Unsafe Declaration Merging
16659
16975
 
16660
16976
  ----------
16661
16977
 
@@ -16685,7 +17001,7 @@ interface Foo {}
16685
17001
  class Foo {}
16686
17002
  ```
16687
17003
 
16688
- ## No Useless Empty Export
17004
+ ### No Useless Empty Export
16689
17005
 
16690
17006
  ----------
16691
17007
 
@@ -16712,6 +17028,229 @@ export const value = 'Hello, world!';
16712
17028
  import 'some-other-module';
16713
17029
  ```
16714
17030
 
17031
+ ### Restrict Template Expressions
17032
+
17033
+ ----------
17034
+
17035
+ JavaScript will call toString() on an object when it is converted to a string,
17036
+ such as when + adding to a string or in ${} template literals. The default Object .toString() returns "[object Object]",
17037
+ which is often not what was intended. This rule reports on values used in a template literal string that aren't strings.
17038
+ primitives and don't define a more useful .toString() method.
17039
+
17040
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/restrict-template-expressions.md>
17041
+
17042
+ 👍 Examples of correct code
17043
+
17044
+ ```typescript
17045
+ const arg = 'foo';
17046
+ const msg1 = `arg = ${arg}`;
17047
+ const msg2 = `arg = ${arg || 'default'}`;
17048
+
17049
+ const stringWithKindProp: string & { _kind?: 'MyString' } = 'foo';
17050
+ const msg3 = `stringWithKindProp = ${stringWithKindProp}`;
17051
+
17052
+ const arg = 123;
17053
+ const msg1 = `arg = ${arg}`;
17054
+ const msg2 = `arg = ${arg || 'zero'}`;
17055
+
17056
+ const arg = true;
17057
+ const msg1 = `arg = ${arg}`;
17058
+ const msg2 = `arg = ${arg || 'not truthy'}`;
17059
+ ```
17060
+
17061
+ 👎 Examples of incorrect code
17062
+
17063
+ ```typescript
17064
+ const arg1 = [1, 2];
17065
+ const msg1 = `arg1 = ${arg1}`;
17066
+
17067
+ const arg2 = { name: 'Foo' };
17068
+ const msg2 = `arg2 = ${arg2 || null}`;
17069
+ ```
17070
+
17071
+ ### Return Await Try Catch
17072
+
17073
+ ----------
17074
+
17075
+ Returning an awaited promise can make sense for better stack trace information as well as for consistent error
17076
+ handling (returned promises will not be caught in an async function try/catch).
17077
+
17078
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/return-await.md>
17079
+
17080
+ 👍 Examples of correct code
17081
+
17082
+ ```typescript
17083
+ async function validInTryCatch1() {
17084
+ try {
17085
+ return await Promise.resolve('try');
17086
+ } catch (e) {}
17087
+ }
17088
+
17089
+ async function validInTryCatch2() {
17090
+ try {
17091
+ throw new Error('error');
17092
+ } catch (e) {
17093
+ return Promise.resolve('catch');
17094
+ }
17095
+ }
17096
+
17097
+ async function validInTryCatch3() {
17098
+ try {
17099
+ throw new Error('error');
17100
+ } catch (e) {
17101
+ return await Promise.resolve('catch');
17102
+ } finally {
17103
+ console.log('cleanup');
17104
+ }
17105
+ }
17106
+
17107
+ async function validInTryCatch4() {
17108
+ try {
17109
+ throw new Error('error');
17110
+ } catch (e) {
17111
+ throw new Error('error2');
17112
+ } finally {
17113
+ return Promise.resolve('finally');
17114
+ }
17115
+ }
17116
+
17117
+ async function validInTryCatch5() {
17118
+ return Promise.resolve('try');
17119
+ }
17120
+
17121
+ async function validInTryCatch6() {
17122
+ return 'value';
17123
+ }
17124
+ ```
17125
+
17126
+ 👎 Examples of incorrect code
17127
+
17128
+ ```typescript
17129
+ async function invalidInTryCatch1() {
17130
+ try {
17131
+ return Promise.resolve('try');
17132
+ } catch (e) {}
17133
+ }
17134
+
17135
+ async function invalidInTryCatch2() {
17136
+ try {
17137
+ throw new Error('error');
17138
+ } catch (e) {
17139
+ return await Promise.resolve('catch');
17140
+ }
17141
+ }
17142
+
17143
+ async function invalidInTryCatch3() {
17144
+ try {
17145
+ throw new Error('error');
17146
+ } catch (e) {
17147
+ return Promise.resolve('catch');
17148
+ } finally {
17149
+ console.log('cleanup');
17150
+ }
17151
+ }
17152
+
17153
+ async function invalidInTryCatch4() {
17154
+ try {
17155
+ throw new Error('error');
17156
+ } catch (e) {
17157
+ throw new Error('error2');
17158
+ } finally {
17159
+ return await Promise.resolve('finally');
17160
+ }
17161
+ }
17162
+
17163
+ async function invalidInTryCatch5() {
17164
+ return await Promise.resolve('try');
17165
+ }
17166
+
17167
+ async function invalidInTryCatch6() {
17168
+ return await 'value';
17169
+ }
17170
+ ```
17171
+
17172
+ ### Switch Exhaustiveness Check
17173
+
17174
+ ----------
17175
+
17176
+ When working with union types in TypeScript, it's common to want to write a switch statement intended to contain a
17177
+ case for each constituent (possible type in the union). However, if the union type changes,
17178
+ it's easy to forget to modify the cases to account for any new types.
17179
+
17180
+ <https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/switch-exhaustiveness-check.md>
17181
+
17182
+ 👍 Examples of correct code
17183
+
17184
+ ```typescript
17185
+ type Day =
17186
+ | 'Monday'
17187
+ | 'Tuesday'
17188
+ | 'Wednesday'
17189
+ | 'Thursday'
17190
+ | 'Friday'
17191
+ | 'Saturday'
17192
+ | 'Sunday';
17193
+
17194
+ const day = 'Monday' as Day;
17195
+ let result = 0;
17196
+
17197
+ switch (day) {
17198
+ case 'Monday':
17199
+ result = 1;
17200
+ break;
17201
+ case 'Tuesday':
17202
+ result = 2;
17203
+ break;
17204
+ case 'Wednesday':
17205
+ result = 3;
17206
+ break;
17207
+ case 'Thursday':
17208
+ result = 4;
17209
+ break;
17210
+ case 'Friday':
17211
+ result = 5;
17212
+ break;
17213
+ case 'Saturday':
17214
+ result = 6;
17215
+ break;
17216
+ case 'Sunday':
17217
+ result = 7;
17218
+ break;
17219
+ }
17220
+
17221
+ // OR default
17222
+
17223
+ switch (day) {
17224
+ case 'Monday':
17225
+ result = 1;
17226
+ break;
17227
+ default:
17228
+ result = 42;
17229
+ }
17230
+ ```
17231
+
17232
+ 👎 Examples of incorrect code
17233
+
17234
+ ```typescript
17235
+ type Day =
17236
+ | 'Monday'
17237
+ | 'Tuesday'
17238
+ | 'Wednesday'
17239
+ | 'Thursday'
17240
+ | 'Friday'
17241
+ | 'Saturday'
17242
+ | 'Sunday';
17243
+
17244
+ const day = 'Monday' as Day;
17245
+ let result = 0;
17246
+
17247
+ switch (day) {
17248
+ case 'Monday':
17249
+ result = 1;
17250
+ break;
17251
+ }
17252
+ ```
17253
+
16715
17254
  ## Yaml Json
16716
17255
 
16717
17256
  add suport yaml and json files
package/index.js CHANGED
@@ -98,6 +98,7 @@ module.exports = {
98
98
  ecmaFeatures: {
99
99
  jsx: true,
100
100
  },
101
+ warnOnUnsupportedTypeScriptVersion: false,
101
102
  ecmaVersion: 2022,
102
103
  sourceType: "module",
103
104
  project: [ "tsconfig.json", "@odg/tsconfig/tsconfig.json" ], // Specify it only for TypeScript files
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odg/eslint-config",
3
- "version": "1.2.0",
3
+ "version": "1.3.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>",
@@ -9,6 +9,7 @@ module.exports = {
9
9
  "space-before-function-paren": [ "error", {
10
10
  anonymous: "never",
11
11
  named: "never",
12
+ asyncArrow: "always",
12
13
  } ], // Não permite espaço antes dos parenteses
13
14
  "no-unused-vars": [ "error", {
14
15
  "vars": "all",
@@ -234,6 +235,7 @@ module.exports = {
234
235
  "regexp/sort-character-class-elements": [ "error" ], // Coloque [] em ordem Alfabética
235
236
  "regexp/sort-flags": [ "error" ], // Flag em ordem alfabética
236
237
  "regexp/prefer-named-capture-group": [ "error" ], // Prefira group com nomes
238
+ "regexp/prefer-regexp-exec": [ "error" ], // Prefira exec em regex
237
239
  "max-statements-per-line": [ "error", { "max": 1 } ], // Máximo operação em 1 linha
238
240
  "arrow-parens": [ "error", "always" ], // Arrow Function sempre com parentese
239
241
  "padding-line-between-statements": [
@@ -143,7 +143,7 @@ module.exports = {
143
143
  after: true,
144
144
  } ],
145
145
  "no-underscore-dangle": [ "error" ], // Não permite _ no nome
146
- "@typescript-eslint/prefer-return-this-type": [ "error" ], // Não permite _ no nome
146
+ "@typescript-eslint/prefer-return-this-type": [ "error" ], // Return this ao invés do nome classe
147
147
  "for-direction": [ "error" ], // Não faça for contador infinito.
148
148
  "no-shadow": [ "off" ], // Erro caso ja esteja declarado escopo a cima
149
149
  "@typescript-eslint/no-shadow": [ "error" ], // Erro caso ja esteja declarado escopo a cima
@@ -373,6 +373,7 @@ module.exports = {
373
373
  ],
374
374
  format: [
375
375
  "strictCamelCase",
376
+ "camelCase",
376
377
  ],
377
378
 
378
379
  // We allow double underscore because of GraphQL type names and some React names.
@@ -389,6 +390,7 @@ module.exports = {
389
390
  selector: "classProperty",
390
391
  format: [
391
392
  "strictCamelCase",
393
+ "camelCase",
392
394
  "UPPER_CASE",
393
395
  ],
394
396
  },
@@ -396,6 +398,7 @@ module.exports = {
396
398
  selector: "typeLike",
397
399
  format: [
398
400
  "StrictPascalCase",
401
+ "camelCase",
399
402
  ],
400
403
  },
401
404
  {
@@ -486,5 +489,12 @@ module.exports = {
486
489
  ], // Use ?? em vez de ternário com &&
487
490
  "@typescript-eslint/prefer-optional-chain": [ "error" ], // Prefira Optional chain ao invés de &&.
488
491
  "@typescript-eslint/prefer-readonly": [ "error" ], // Prefira readonly
492
+ "@typescript-eslint/prefer-reduce-type-parameter": [ "error" ], // Use <> em reduce em vez de as default type
493
+ "@typescript-eslint/prefer-regexp-exec": [ "error" ], // Prefira regex exec
494
+ "@typescript-eslint/prefer-string-starts-ends-with": [ "error" ], // Prefira startsWith e endsWith
495
+ "@typescript-eslint/promise-function-async": [ "error" ], // Prefira async function quando retorna Promise
496
+ "@typescript-eslint/require-array-sort-compare": [ "error" ], // Passe parâmetro array sort
497
+ "@typescript-eslint/sort-type-constituents": [ "error" ], // Ordene agrupação de tipos
498
+ "@typescript-eslint/space-before-blocks": [ "error" ], // Espaço apos antes {} interface e enum
489
499
  }, // Convenção de nomes
490
500
  };
@@ -11,5 +11,18 @@ module.exports = {
11
11
  ], // Não misture not null assert com optional
12
12
  "@typescript-eslint/no-unsafe-declaration-merging": [ "error" ], // Evita unir automaticamente tipos
13
13
  "@typescript-eslint/no-useless-empty-export": [ "error" ], // Bloqueia export vazio
14
+ "@typescript-eslint/restrict-template-expressions": [
15
+ "error",
16
+ {
17
+ allowNumber: true,
18
+ allowBoolean: true,
19
+ },
20
+ ], // Não concatene strings com tipos inválidos
21
+ "@typescript-eslint/return-await": [ "error" ], // Ao retornar um promise em try catch, use await evitando erros
22
+ "@typescript-eslint/switch-exhaustiveness-check": [
23
+ "error",
24
+ ], // Switch com typo coloque default ou todos os casos
25
+ "brace-style": [ "off" ], // Força formatação {}
26
+ "@typescript-eslint/brace-style": [ "error" ], // Força formatação {}
14
27
  },
15
28
  };