Skip to content

Commit 0376138

Browse files
authored
Allow pascal-case imports and disable consistent-generic-constructors (#162)
Found two rules causing new, unwanted violations in the Nimble repo: - `@typescript-eslint/consistent-generic-constructors` results in code like this: ``` private readonly hiddenOptions: Set<ListOption> = new Set(); ``` reporting violations like "The generic type arguments should be specified as part of the constructor type arguments". I had tried to disable this in the prior PR, but was doing so from the wrong config. - `@typescript-eslint/naming-convention` now covers imported namespaces (e.g. `import * as Foo from '../foo'`), and it defaults to allowing both camel and pascal case. However, because we are configuring the `'default'` selector (which matches anything not otherwise specified) to only allow camel case, it was disallowing pascal case for those imported namespaces.
1 parent 81aa552 commit 0376138

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Allow pascal-case imports and disable consistent-generic-constructors",
4+
"packageName": "@ni/eslint-config-typescript",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/eslint-config-typescript/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ module.exports = {
4646
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic.ts
4747
*/
4848

49-
'@typescript-eslint/consistent-generic-constructors': 'off',
50-
5149
/*
5250
Overrides to Typescript rules outside of the recommended configuration:
5351
*/

packages/eslint-config-typescript/requiring-type-checking.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = {
5656
https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic-type-checked.ts
5757
*/
5858

59+
'@typescript-eslint/consistent-generic-constructors': 'off',
5960
'@typescript-eslint/prefer-regexp-exec': 'off',
6061

6162
/*
@@ -84,12 +85,6 @@ module.exports = {
8485
selector: 'enumMember',
8586
format: ['PascalCase'],
8687
},
87-
{
88-
selector: 'default',
89-
format: ['camelCase'],
90-
leadingUnderscore: 'allow',
91-
trailingUnderscore: 'allow',
92-
},
9388
{
9489
selector: 'variable',
9590
format: ['camelCase', 'UPPER_CASE'],
@@ -100,6 +95,16 @@ module.exports = {
10095
selector: 'typeLike',
10196
format: ['PascalCase'],
10297
},
98+
{
99+
selector: 'import',
100+
format: ['camelCase', 'PascalCase'],
101+
},
102+
{
103+
selector: 'default',
104+
format: ['camelCase'],
105+
leadingUnderscore: 'allow',
106+
trailingUnderscore: 'allow',
107+
},
103108
],
104109

105110
'@typescript-eslint/no-base-to-string': 'error',

0 commit comments

Comments
 (0)