Skip to content

Commit

Permalink
fix(no-undefined-types): allow this; fixes #660
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Dec 19, 2020
1 parent 68eb1c3 commit bda5959
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .README/rules/no-undefined-types.md
Expand Up @@ -27,6 +27,7 @@ The following types are always considered defined.
`function`, `symbol`
- `number`, `bigint`, `NaN`, `Infinity`
- `any`, `*`
- `this`
- `Array`, `Object`, `RegExp`, `Date`, `Function`

Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
Expand Down
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -7026,6 +7026,7 @@ The following types are always considered defined.
`function`, `symbol`
- `number`, `bigint`, `NaN`, `Infinity`
- `any`, `*`
- `this`
- `Array`, `Object`, `RegExp`, `Date`, `Function`
Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
Expand Down Expand Up @@ -7563,6 +7564,17 @@ function quux () {}
* @type {SomeType}
*/
// Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-defining"}}}}
class Test {
/**
* Method.
*
* @returns {this} Return description.
*/
method (): this {
return this;
}
}
````
Expand Down
1 change: 1 addition & 0 deletions src/rules/noUndefinedTypes.js
Expand Up @@ -15,6 +15,7 @@ const extraTypes = [
'function', 'symbol',
'number', 'bigint', 'NaN', 'Infinity',
'any', '*',
'this',
'Array', 'Object', 'RegExp', 'Date', 'Function',
];

Expand Down
15 changes: 15 additions & 0 deletions test/rules/assertions/noUndefinedTypes.js
Expand Up @@ -938,5 +938,20 @@ export default {
},
},
},
{
code: `
class Test {
/**
* Method.
*
* @returns {this} Return description.
*/
method (): this {
return this;
}
}
`,
parser: require.resolve('@typescript-eslint/parser'),
},
],
};

0 comments on commit bda5959

Please sign in to comment.