Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: split types into their own package (#2229)
As part of the scope analysis work, I want to remove its runtime dependency on `typescript-estree`, so it doesn't need to depend on `typescript`. It only needs a few pieces from the package; AST_NODE_TYPES, and the visitor keys. This moves the following the to a new package, `@typescript-eslint/types`: - `AST_NODE_TYPES` - `AST_TOKEN_TYPES` - `TSESTree` (aka the types for the typescript-estree AST) - `ParserOptions` (moved out of `experimental-utils`) This has the added bonus of getting us very close to removing the need for `parser` to depend on `experimental-utils`, which will reduce its dependency tree significantly.
- Loading branch information
1 parent
ba41680
commit 5f45918
Showing
39 changed files
with
319 additions
and
121 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
49 changes: 6 additions & 43 deletions
49
packages/experimental-utils/src/ts-eslint/ParserOptions.ts
This file contains 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 |
---|---|---|
@@ -1,43 +1,6 @@ | ||
import { TSESTreeOptions } from '@typescript-eslint/typescript-estree'; | ||
|
||
type EcmaVersion = | ||
| 3 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 | ||
| 9 | ||
| 10 | ||
| 11 | ||
| 2015 | ||
| 2016 | ||
| 2017 | ||
| 2018 | ||
| 2019 | ||
| 2020; | ||
|
||
interface ParserOptions { | ||
comment?: boolean; | ||
ecmaFeatures?: { | ||
globalReturn?: boolean; | ||
jsx?: boolean; | ||
}; | ||
ecmaVersion?: EcmaVersion; | ||
// ts-estree specific | ||
debugLevel?: TSESTreeOptions['debugLevel']; | ||
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean; | ||
errorOnUnknownASTType?: boolean; | ||
extraFileExtensions?: string[]; | ||
filePath?: string; | ||
loc?: boolean; | ||
project?: string | string[]; | ||
projectFolderIgnoreList?: (string | RegExp)[]; | ||
range?: boolean; | ||
sourceType?: 'script' | 'module'; | ||
tokens?: boolean; | ||
tsconfigRootDir?: string; | ||
useJSXTextNode?: boolean; | ||
warnOnUnsupportedTypeScriptVersion?: boolean; | ||
} | ||
|
||
export { EcmaVersion, ParserOptions }; | ||
export { | ||
DebugLevel, | ||
EcmaVersion, | ||
ParserOptions, | ||
SourceType, | ||
} from '@typescript-eslint/types'; |
This file contains 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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
// for convenience's sake - export the types directly from here so consumers | ||
// don't need to reference/install both packages in their code | ||
|
||
// NOTE - this uses hard links inside ts-estree to avoid initialization of entire package | ||
// via its main file (which imports typescript at runtime). | ||
// Not every eslint-plugin written in typescript requires typescript at runtime. | ||
export { | ||
AST_NODE_TYPES, | ||
AST_TOKEN_TYPES, | ||
TSESTree, | ||
} from '@typescript-eslint/typescript-estree/dist/ts-estree'; | ||
} from '@typescript-eslint/types'; | ||
|
||
// NOTE - this uses hard links inside ts-estree to avoid initialization of entire package | ||
// via its main file (which imports typescript at runtime). | ||
// Not every eslint-plugin written in typescript requires typescript at runtime. | ||
export { ParserServices } from '@typescript-eslint/typescript-estree/dist/parser-options'; |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,3 +1 @@ | ||
import { TSESLint } from '@typescript-eslint/experimental-utils'; | ||
|
||
export type ParserOptions = TSESLint.ParserOptions; | ||
export { ParserOptions } from '@typescript-eslint/types'; |
This file contains 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 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 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 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 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 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 TypeScript ESLint and other contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,17 @@ | ||
<h1 align="center">TypeScript-ESTree Types</h1> | ||
|
||
<p align="center"> | ||
<img src="https://github.com/typescript-eslint/typescript-eslint/workflows/CI/badge.svg" alt="CI" /> | ||
<a href="https://www.npmjs.com/package/@typescript-eslint/types"><img src="https://img.shields.io/npm/v/@typescript-eslint/types.svg?style=flat-square" alt="NPM Version" /></a> | ||
<a href="https://www.npmjs.com/package/@typescript-eslint/types"><img src="https://img.shields.io/npm/dm/@typescript-eslint/types.svg?style=flat-square" alt="NPM Downloads" /></a> | ||
</p> | ||
|
||
This package exists to help us reduce cycles and provide lighter-weight packages at runtime. | ||
You probably don't want to use it directly. | ||
|
||
If you're building an ESLint plugin, consider using [`@typescript-eslint/experimental-utils`](../experimental-utils). | ||
If you're parsing TypeScript code, consider using [`@typescript-eslint/typescript-estree`](../typescript-estree). | ||
|
||
## Contributing | ||
|
||
[See the contributing guide here](../../CONTRIBUTING.md) |
Oops, something went wrong.