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

feat(eslint-plugin): [no-invalid-void-type] better report message for void used as a constituent inside a function return type#5274

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
JoshuaKGoldberg merged 53 commits intotypescript-eslint:mainfromkmin-jeong:feat/5255
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
53 commits
Select commitHold shift + click to select a range
5b79028
feat: update repository
kmin-jeongApr 7, 2022
5c3af4d
remove duplicate examples
kmin-jeongApr 7, 2022
f5674a8
feat:add about re-exporting --isolatedModules in When Not To Use It
kmin-jeongApr 7, 2022
d47eeb4
feat: add exmaples
kmin-jeongApr 8, 2022
6f74fea
fix: remove duplicate examples in correct
kmin-jeongApr 8, 2022
7fb6dc7
fix:correct words
kmin-jeongApr 8, 2022
e77ae67
fix: fix space-between
kmin-jeongApr 8, 2022
2572fd6
fix: fix code
kmin-jeongApr 8, 2022
40f496f
fix: fix code space
kmin-jeongApr 8, 2022
b508138
fix: check error
kmin-jeongApr 8, 2022
70dc242
fix:missed examples
kmin-jeongApr 8, 2022
c895ad8
feat: read review and fix them
kmin-jeongApr 8, 2022
6158e57
feat: add two taps
kmin-jeongApr 8, 2022
c4a25fd
fix: add <!--tabs-->
kmin-jeongApr 8, 2022
cc71bea
feat: fix explaination about `isolatedmodules`
kmin-jeongApr 8, 2022
251f49e
fix: fix explain about `isolatedModules`
kmin-jeongApr 8, 2022
d42a546
fis: modify When no to use it
kmin-jeongApr 9, 2022
f1c3ce4
fix: revert change log
kmin-jeongApr 9, 2022
4246b6b
fix: add lint
kmin-jeongApr 9, 2022
c1af45c
fix: add lint
kmin-jeongApr 10, 2022
42d8958
add: fix code
kmin-jeongApr 10, 2022
efd3668
fix:fix docs splits
kmin-jeongApr 10, 2022
8b4f9de
feat: add lint
kmin-jeongApr 10, 2022
24c0f2e
Update packages/eslint-plugin/docs/rules/consistent-type-exports.md
JoshuaKGoldbergApr 10, 2022
2f2bb8d
Merge branch 'main' into master
kmin-jeongApr 11, 2022
05377bd
Merge branch 'typescript-eslint:main' into master
kmin-jeongApr 12, 2022
b5df9a8
Merge branch 'typescript-eslint:main' into master
kmin-jeongApr 18, 2022
e3e6a0c
Merge branch 'typescript-eslint:main' into master
kmin-jeongJun 14, 2022
d844fe3
Merge branch 'typescript-eslint:main' into master
kmin-jeongJun 27, 2022
4119247
Merge branch 'typescript-eslint:main' into master
kmin-jeongJun 30, 2022
bcccb43
feat:change error message better
kmin-jeongJun 30, 2022
8154c5c
fix:separating message and made types about union
kmin-jeongJun 30, 2022
aeb5cad
fix: separate error message
kmin-jeongJun 30, 2022
ae4ffba
Merge branch 'typescript-eslint:main' into master
kmin-jeongJun 30, 2022
3c531e8
fix:fix mistake type
kmin-jeongJun 30, 2022
af8cede
fix:fix typo
kmin-jeongJun 30, 2022
87f169c
Merge branch 'main' into feat/5255
kmin-jeongJun 30, 2022
f7627e7
fix:fix error message in case of union
kmin-jeongJul 2, 2022
4b24d17
Merge branch 'typescript-eslint:main' into master
kmin-jeongJul 2, 2022
8822312
Merge branch 'main' into feat/5255
kmin-jeongJul 2, 2022
0c452d8
Merge branch 'master' of https://github.com/kmin-jeong/typescript-esl…
kmin-jeongJul 2, 2022
9a9982d
Merge branch 'feat/5255' of https://github.com/kmin-jeong/typescript-…
kmin-jeongJul 2, 2022
dfa5f37
Merge branch 'main' into feat/5255
kmin-jeongJul 6, 2022
3ae90bf
fix:fix error message in InvalidVoidForUnion
kmin-jeongJul 24, 2022
f31f829
Merge branch 'typescript-eslint:main' into feat/5255
kmin-jeongJul 24, 2022
9d4199b
Merge branch 'main' into feat/5255
kmin-jeongAug 18, 2022
369f447
fix: add logic about union
kmin-jeongAug 18, 2022
1a9d56d
feat: add test case
kmin-jeongAug 18, 2022
4329328
Merge branch 'main' into feat/5255
kmin-jeongAug 18, 2022
7bc3031
Merge branch 'main' into feat/5255
kmin-jeongAug 18, 2022
1c48645
Merge branch 'main' into feat/5255
kmin-jeongOct 27, 2022
ad238bc
Switched change to just enhance error message
JoshuaKGoldbergOct 27, 2022
20d46de
oops comment
JoshuaKGoldbergOct 27, 2022
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
23 changes: 17 additions & 6 deletionspackages/eslint-plugin/src/rules/no-invalid-void-type.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,8 @@ type MessageIds =
| 'invalidVoidNotReturnOrGeneric'
| 'invalidVoidNotReturn'
| 'invalidVoidNotReturnOrThisParam'
| 'invalidVoidNotReturnOrThisParamOrGeneric';
| 'invalidVoidNotReturnOrThisParamOrGeneric'
| 'invalidVoidUnionConstituent';

export default util.createRule<[Options], MessageIds>({
name: 'no-invalid-void-type',
Expand All@@ -25,14 +26,16 @@ export default util.createRule<[Options], MessageIds>({
},
messages: {
invalidVoidForGeneric:
'{{ generic }} may not have void as a typevariable.',
'{{ generic }} may not have void as a typeargument.',
invalidVoidNotReturnOrGeneric:
'void is only valid as a return type or generic typevariable.',
'void is only valid as a return type or generic typeargument.',
invalidVoidNotReturn: 'void is only valid as a return type.',
invalidVoidNotReturnOrThisParam:
'void is only valid as return type or type of `this` parameter.',
invalidVoidNotReturnOrThisParamOrGeneric:
'void is only valid as a return type or generic type variable or the type of a `this` parameter.',
'void is only valid as a return type or generic type argument or the type of a `this` parameter.',
invalidVoidUnionConstituent:
'void is not valid as a constituent in a union type',
},
schema: [
{
Expand DownExpand Up@@ -136,7 +139,7 @@ export default util.createRule<[Options], MessageIds>({
): void {
if (parentNode.default !== node) {
context.report({
messageId:'invalidVoidNotReturnOrGeneric',
messageId:getNotReturnOrGenericMessageId(node),
node,
});
}
Expand DownExpand Up@@ -218,7 +221,7 @@ export default util.createRule<[Options], MessageIds>({
allowInGenericTypeArguments && allowAsThisParameter
? 'invalidVoidNotReturnOrThisParamOrGeneric'
: allowInGenericTypeArguments
?'invalidVoidNotReturnOrGeneric'
?getNotReturnOrGenericMessageId(node)
: allowAsThisParameter
? 'invalidVoidNotReturnOrThisParam'
: 'invalidVoidNotReturn',
Expand All@@ -228,3 +231,11 @@ export default util.createRule<[Options], MessageIds>({
};
},
});

function getNotReturnOrGenericMessageId(
node: TSESTree.TSVoidKeyword,
): MessageIds {
return node.parent!.type === AST_NODE_TYPES.TSUnionType
? 'invalidVoidUnionConstituent'
: 'invalidVoidNotReturnOrGeneric';
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -316,7 +316,7 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, {
code: 'type UnionType2 = string | number | void;',
errors: [
{
messageId: 'invalidVoidNotReturnOrGeneric',
messageId: 'invalidVoidUnionConstituent',
line: 1,
column: 37,
},
Expand All@@ -326,12 +326,32 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, {
code: 'type UnionType3 = string | ((number & any) | (string | void));',
errors: [
{
messageId: 'invalidVoidNotReturnOrGeneric',
messageId: 'invalidVoidUnionConstituent',
line: 1,
column: 56,
},
],
},
{
code: 'declare function test(): number | void;',
errors: [
{
messageId: 'invalidVoidUnionConstituent',
line: 1,
column: 35,
},
],
},
{
code: 'declare function test<T extends number | void>(): T;',
errors: [
{
messageId: 'invalidVoidUnionConstituent',
line: 1,
column: 42,
},
],
},
{
code: 'type IntersectionType = string & number & void;',
errors: [
Expand DownExpand Up@@ -394,7 +414,7 @@ ruleTester.run('allowInGenericTypeArguments: true', rule, {
code: 'type invalidVoidUnion = void | Map<string, number>;',
errors: [
{
messageId: 'invalidVoidNotReturnOrGeneric',
messageId: 'invalidVoidUnionConstituent',
line: 1,
column: 25,
},
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp