-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add types #18854
feat: Add types #18854
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
fixes #18845
@@ -93,7 +93,8 @@ module.exports = [ | |||
"tests/performance/**", | |||
"tmp/**", | |||
"**/test.js", | |||
".vscode" | |||
".vscode", | |||
"**/*.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for now. 😄
Looks like the webpack plugin is using an older version of |
I can confirm the |
Yes, I think that's all it would take to make both integration tests pass. I'll give it a shot. |
Okay, I fixed the incorrect type and we now have three integration tests with other projects. |
} | ||
|
||
interface Formatter { | ||
format(results: LintResult[], data?: LintResultData): string | Promise<string>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second argument of LoadedFormatter#format()
is just an object with an optional maxWarningsExceeded
property:
eslint/docs/src/integrate/nodejs-api.md
Lines 469 to 470 in 6e79ac7
* `format` (`(results: LintResult[], resultsMeta: ResultsMeta) => string | Promise<string>`)<br> | |
The method to convert the [LintResult] objects to text. `resultsMeta` is an object that will contain a `maxWarningsExceeded` object if `--max-warnings` was set and the number of warnings exceeded the limit. The `maxWarningsExceeded` object will contain two properties: `maxWarnings`, the value of the `--max-warnings` option, and `foundWarnings`, the number of lint warnings. |
The cwd
and rulesMeta
properties are passed directly to the underlying formatter function:
Lines 1245 to 1255 in 9bde90c
return formatter(results, { | |
...resultsMeta, | |
cwd, | |
get rulesMeta() { | |
if (!rulesMeta) { | |
rulesMeta = eslint.getRulesMetaForResults(results); | |
} | |
return rulesMeta; | |
} | |
}); |
Since that type has been broken for so long and the integration tests are passing now, we can merge this change as it is, and I will try to sort up things in a follow-up PR.
|
||
sourceCode.getAllComments(); | ||
|
||
sourceCode.getJSDocComment(AST); // $ExpectType Comment | null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ExpectType
annotations are not working any more. We should also fix this in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! I'm going to merge this PR now so that it gets included in the ESLint v9.10.0 release.
Per 2024-09-05 TSC meeting, this was released early and we will await feedback from users to make sure it is working as expected. @nzakas added some integration tests for the types. |
thank you for doing this! |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[x] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Added the type definitions from
@types/eslint
to the project:lib/types
tests/lib/types
test:types
script to run type checking testsnpm run test:types
to CI to be run on each PRtypes
entries topackage.json
For simplicity, I did not enable type checking for the whole repo, just for the type tests.
This is intended to be a base for us to build off of. We can look to make improvements in future PRs.
fixes #18845
Is there anything you'd like reviewers to focus on?
The types are copied over as-is without modification (aside from including the license). We don't need to review their contents right now.
Does the testing setup make sense?