Closed
Description
Originally reported over here + confirmed by @JoshuaKGoldberg :
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
import React from 'react';
ESLint Config
This is using [the default rule configuration mentioned in the docs](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/naming-convention.md#options):
// the default config is similar to ESLint's camelcase rule but more strict
const defaultOptions: Options = [
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE'],
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
];
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/naming-convention": ["error", ...defaultOptions],
},
};
tsconfig
Expected Result
Just upgraded to @typescript-eslint/[email protected]
with the new import
option for naming-convention
config and received a number of new warnings, such as this one:
checkbox/index.js
Warning: 1:8 warning Import name `React` must match one of the following formats: camelCase @typescript-eslint/naming-convention
With this code:
import React from 'react';
I guess this is going to be a pretty common pattern that gets rejected now. 😬
Actual Result
Maybe the default configuration should accept every format as an import? (format: null
)
Alternative: expect all users with default PascalCase
imports (pretty common across the npm ecosystem, incl. React) and other case format eg. UPPER_CASE
or snake_case
to add the following to their config:
// the default config is similar to ESLint's camelcase rule but more strict
const defaultOptions: Options = [
// ...
+ // Disable @typescript-eslint/naming-convention format for imports
+ // https://github.com/typescript-eslint/typescript-eslint/pull/7269#issuecomment-1777628591
+ {
+ selector: 'import',
+ format: null,
+ },
];
Additional Info
No response