Skip to content

Commit 0fc4663

Browse files
committed
Revert "optimize: ensure with new fix that we avoid checking back too far"
This reverts commit e13a03a.
1 parent e13a03a commit 0fc4663

3 files changed

Lines changed: 1 addition & 69 deletions

File tree

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10565,13 +10565,6 @@ export class User {
1056510565
}
1056610566
// Options: [{"contexts":["ClassProperty:has(Decorator[expression.callee.name=\"Input\"])"]}]
1056710567
// Message: Missing JSDoc comment.
10568-
10569-
@Input()
10570-
export class UserSettingsState {
10571-
method () {}
10572-
}
10573-
// Options: [{"require":{"MethodDefinition":true}}]
10574-
// Message: Missing JSDoc comment.
1057510568
````
1057610569

1057710570
The following patterns are not considered problems:

src/eslint/getJSDocComment.js

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,23 @@ const isCommentToken = (token) => {
1616

1717
const decoratorMetaTokens = new Map([[')', '('], ['>', '<']]);
1818

19-
// eslint-disable-next-line complexity
2019
const getDecorator = (token, sourceCode) => {
2120
if (!token) {
2221
return false;
2322
}
24-
2523
if (token.type === 'Punctuator') {
2624
const tokenClose = token.value;
2725
const tokenOpen = decoratorMetaTokens.get(tokenClose);
2826
if (tokenOpen) {
2927
let nested = 0;
3028
let tokenBefore = token;
31-
let exitEarlyUnlessTyped = false;
3229
do {
3330
tokenBefore = sourceCode.getTokenBefore(tokenBefore, {includeComments: true});
3431
// istanbul ignore if
3532
if (tokenBefore && tokenBefore.type === 'Punctuator') {
3633
if (tokenBefore.value === tokenClose) {
3734
nested++;
3835
} else if (tokenBefore.value === tokenOpen) {
39-
if (tokenOpen === '(') {
40-
exitEarlyUnlessTyped = true;
41-
}
4236
if (nested) {
4337
nested--;
4438
} else {
@@ -48,33 +42,7 @@ const getDecorator = (token, sourceCode) => {
4842
}
4943
} while (tokenBefore);
5044

51-
// Because our token retrieval doesn't give us as much info as AST, and
52-
// because decorators can be nested and fairly complex, besides finding
53-
// any decorators, we also want to avoid checking backwards indefinitely
54-
// in a potentially large document, so we exit early if parentheses are
55-
// not preceded by a type where we have to keep checking backward for
56-
// now (such as a regular call expression) or if a decorator is found.
57-
if (exitEarlyUnlessTyped) {
58-
// Check for `@someDecorator(`
59-
const identifier = sourceCode.getTokenBefore(tokenBefore, {includeComments: true});
60-
if (identifier && identifier.type === 'Identifier') {
61-
const before = sourceCode.getTokenBefore(identifier, {includeComments: true});
62-
if (before && before.type === 'Punctuator' && before.value === '@') {
63-
// Decorator found
64-
return before;
65-
}
66-
}
67-
68-
// If decorators may have `:`, we might need to check for those as with typed.
69-
if (!identifier || identifier.type !== 'Punctuator' || identifier.value !== '>') {
70-
// Should not be a decorator
71-
return false;
72-
}
73-
74-
// Could be a typed decorator, so keep checking for one
75-
}
76-
77-
return getDecorator(tokenBefore, sourceCode, true);
45+
return getDecorator(tokenBefore, sourceCode);
7846
}
7947
if (token.value === '@') {
8048
return token;

test/rules/assertions/requireJsdoc.js

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,35 +2763,6 @@ function quux (foo) {
27632763
`,
27642764
parser: require.resolve('@typescript-eslint/parser'),
27652765
},
2766-
{
2767-
code: `
2768-
@Input()
2769-
export class UserSettingsState {
2770-
method () {}
2771-
}
2772-
`,
2773-
errors: [
2774-
{
2775-
line: 4,
2776-
message: 'Missing JSDoc comment.',
2777-
},
2778-
],
2779-
options: [{
2780-
require: {
2781-
MethodDefinition: true,
2782-
},
2783-
}],
2784-
output: `
2785-
/**
2786-
*
2787-
*/
2788-
@Input()
2789-
export class UserSettingsState {
2790-
method () {}
2791-
}
2792-
`,
2793-
parser: require.resolve('@typescript-eslint/parser'),
2794-
},
27952766
],
27962767
valid: [{
27972768
code: `

0 commit comments

Comments
 (0)