Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): [naming-convention] cover case that requires quotes#4582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -127,7 +127,9 @@ function createValidator(
return;
}

if (!validatePredefinedFormat(config, name, node, originalName)) {
if (
!validatePredefinedFormat(config, name, node, originalName, modifiers)
) {
// fail
return;
}
Expand DownExpand Up@@ -376,16 +378,19 @@ function createValidator(
name: string,
node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal,
originalName: string,
modifiers: Set<Modifiers>,
): boolean {
const formats = config.format;
if (formats === null || formats.length === 0) {
return true;
}

for (const format of formats) {
const checker = PredefinedFormatToCheckFunction[format];
if (checker(name)) {
return true;
if (!modifiers.has(Modifiers.requiresQuotes)) {
for (const format of formats) {
const checker = PredefinedFormatToCheckFunction[format];
if (checker(name)) {
return true;
}
}
}

Expand Down
20 changes: 19 additions & 1 deletionpackages/eslint-plugin/tests/rules/naming-convention.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import {
Selector,
selectorTypeToMessageString,
} from '../../src/rules/naming-convention-utils';
import { getFixturesRootDir, RuleTester } from '../RuleTester';
import { getFixturesRootDir,noFormat,RuleTester } from '../RuleTester';

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand DownExpand Up@@ -2224,5 +2224,23 @@ ruleTester.run('naming-convention', rule, {
],
errors: Array(13).fill({ messageId: 'doesNotMatchFormat' }),
},
{
code: noFormat`
type Foo = {
'foo Bar': string;
'': string;
'0': string;
'foo': string;
'foo-bar': string;
'#foo-bar': string;
};

interface Bar {
'boo-----foo': string;
}
`,
// 6, not 7 because 'foo' is valid
errors: Array(6).fill({ messageId: 'doesNotMatchFormat' }),
},
],
});

[8]ページ先頭

©2009-2025 Movatter.jp