-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(parser, typescript-estree): export withoutProjectParserOptions utility #9233
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
Merged
JoshuaKGoldberg
merged 13 commits into
typescript-eslint:main
from
fpapado:8428-export-utility-to-remove-type-info
Jun 6, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3f657cd
feat(typescript-estree): add function to remove parser options
fpapado 62b677e
feat(parser): re-export removeParserOptionsThatPromptTypechecking
fpapado 5d9d6e7
chore: fix lint rule about importing types
fpapado b0319e4
refactor: prefer rest/spread over delete
fpapado f583a3e
refactor: rename to withoutProjectParserOptions
fpapado 4dbeacf
refactor: rename withoutProjectParserOptions file as well
fpapado 4ca0ac0
test: add unit test for withoutProjectParserOptions
fpapado 3f83bf3
docs: add withoutProjectParserOptions
fpapado 30c0e63
refactor: use single unit test for withoutProjectParserOptions
fpapado a1a6282
chore: fix no-unused-vars lint error
fpapado 15d47de
chore: avoid wrapping lines in Parser.mdx
fpapado 8e62e0b
fix: update test with toEqual assertion
fpapado 35a3d4b
Merge branch 'main' into 8428-export-utility-to-remove-type-info
fpapado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/typescript-estree/src/withoutProjectParserOptions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { TSESTreeOptions } from './parser-options'; | ||
|
||
/** | ||
* Removes options that prompt the parser to parse the project with type | ||
* information. In other words, you can use this if you are invoking the parser | ||
* directly, to ensure that one file will be parsed in isolation, which is much, | ||
* much faster. | ||
* | ||
* @see https://github.com/typescript-eslint/typescript-eslint/issues/8428 | ||
*/ | ||
export function withoutProjectParserOptions( | ||
opts: TSESTreeOptions, | ||
): TSESTreeOptions { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- The variables are meant to be omitted | ||
const { EXPERIMENTAL_useProjectService, project, ...rest } = opts; | ||
|
||
return rest; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/typescript-estree/tests/lib/withoutProjectParserOptions.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { withoutProjectParserOptions } from '../../src'; | ||
|
||
describe('withoutProjectParserOptions', () => { | ||
it('removes only project parser options', () => { | ||
const without = withoutProjectParserOptions({ | ||
comment: true, | ||
EXPERIMENTAL_useProjectService: true, | ||
project: true, | ||
}); | ||
expect(without).toEqual({ | ||
comment: true, | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.