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): fix no-extraneous-class for class without name#174

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
armano2 merged 2 commits intotypescript-eslint:masterfromarmano2:no-extraneous-class
Jan 31, 2019
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
12 changes: 9 additions & 3 deletionspackages/eslint-plugin/lib/rules/no-extraneous-class.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,7 +68,10 @@ module.exports = {

if (node.body.length === 0) {
if (allowEmpty) return;
context.report({ node: id, messageId: 'empty' });
context.report({
node: id || node.parent,
messageId: 'empty'
});
return;
}

Expand DownExpand Up@@ -97,14 +100,17 @@ module.exports = {
if (onlyConstructor) {
if (!allowConstructorOnly) {
context.report({
node: id,
node: id || node.parent,
messageId: 'onlyConstructor'
});
}
return;
}
if (onlyStatic && !allowStaticOnly) {
context.report({ node: id, messageId: 'onlyStatic' });
context.report({
node: id || node.parent,
messageId: 'onlyStatic'
});
}
}
};
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,7 +70,9 @@ export class Bar {
}
`.trim(),
options: [{ allowStaticOnly: true }]
}
},
// https://github.com/typescript-eslint/typescript-eslint/issues/170
'export default class { hello() { return "I am foo!"; } }'
],

invalid: [
Expand DownExpand Up@@ -117,9 +119,13 @@ export class AClass {
}
}
}

`.trim(),
errors: [onlyStatic, empty]
},
{
// https://github.com/typescript-eslint/typescript-eslint/issues/170
code: 'export default class { static hello() {} }',
errors: [{ messageId: 'onlyStatic', type: 'ClassDeclaration' }]
}
]
});

[8]ページ先頭

©2009-2025 Movatter.jp