0.2.0 - Mid migration

This commit is contained in:
Daniel Mason 2022-04-25 14:47:15 +12:00
parent 139e6a915e
commit 7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions

21
web/node_modules/eslint-plugin-testing-library/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Mario Beltrán Alarcón
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.

View file

@ -0,0 +1,236 @@
<div align="center">
<a href="https://eslint.org/">
<img width="150" height="150" src="https://eslint.org/assets/img/logo.svg">
</a>
<a href="https://testing-library.com/">
<img width="150" height="150" src="https://raw.githubusercontent.com/testing-library/dom-testing-library/master/other/octopus.png">
</a>
<h1>eslint-plugin-testing-library</h1>
<p>ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library</p>
</div>
<hr>
[![Build status][build-badge]][build-url]
[![Package version][version-badge]][version-url]
[![MIT License][license-badge]][license-url]
<br>
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
[![PRs Welcome][pr-badge]][pr-url]
<br>
[![Watch on Github][gh-watchers-badge]][gh-watchers-url]
[![Star on Github][gh-stars-badge]][gh-stars-url]
[![Tweet][tweet-badge]][tweet-url]
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-35-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
## Installation
You'll first need to install [ESLint](http://eslint.org):
```
$ npm i eslint --save-dev
```
Next, install `eslint-plugin-testing-library`:
```
$ npm install eslint-plugin-testing-library --save-dev
```
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-testing-library` globally.
## Usage
Add `testing-library` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": ["testing-library"]
}
```
Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"testing-library/await-async-query": "error",
"testing-library/no-await-sync-query": "error",
"testing-library/no-debug": "warn"
}
}
```
## Shareable configurations
### Recommended
This plugin exports a recommended configuration that enforces good
Testing Library practices _(you can find more info about enabled rules in
the [Supported Rules section](#supported-rules) within the `Configurations` column)_.
To enable this configuration use the `extends` property in your
`.eslintrc` config file:
```json
{
"extends": ["plugin:testing-library/recommended"]
}
```
### Frameworks
Starting from the premise that
[DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro)
is the base for the rest of Testing Library frameworks wrappers, this
plugin also exports different configuration for those frameworks that
enforces good practices for specific rules that only apply to them _(you
can find more info about enabled rules in
the [Supported Rules section](#supported-rules) within the `Configurations` column)_.
**Note that frameworks configurations enable their specific rules +
recommended rules.**
Available frameworks configurations are:
#### Angular
To enable this configuration use the `extends` property in your
`.eslintrc` config file:
```json
{
"extends": ["plugin:testing-library/angular"]
}
```
#### React
To enable this configuration use the `extends` property in your
`.eslintrc` config file:
```json
{
"extends": ["plugin:testing-library/react"]
}
```
#### Vue
To enable this configuration use the `extends` property in your
`.eslintrc` config file:
```json
{
"extends": ["plugin:testing-library/vue"]
}
```
## Supported Rules
| Rule | Description | Configurations | Fixable |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------ |
| [await-async-query](docs/rules/await-async-query.md) | Enforce async queries to have proper `await` | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | |
| [await-async-utils](docs/rules/await-async-utils.md) | Enforce async utils to be awaited properly | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | |
| [await-fire-event](docs/rules/await-fire-event.md) | Enforce async fire event methods to be awaited | ![vue-badge][] | |
| [consistent-data-testid](docs/rules/consistent-data-testid.md) | Ensure `data-testid` values match a provided regex. | | |
| [no-await-sync-events](docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | | |
| [no-await-sync-query](docs/rules/no-await-sync-query.md) | Disallow unnecessary `await` for sync queries | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | |
| [no-debug](docs/rules/no-debug.md) | Disallow the use of `debug` | ![angular-badge][] ![react-badge][] ![vue-badge][] | |
| [no-dom-import](docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] |
| [no-manual-cleanup](docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | |
| [no-render-in-setup](docs/rules/no-render-in-setup.md) | Disallow the use of `render` in setup functions | | |
| [no-wait-for-empty-callback](docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | | |
| [no-wait-for-snapshot](docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | |
| [prefer-explicit-assert](docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than just `getBy*` queries | | |
| [prefer-find-by](docs/rules/prefer-find-by.md) | Suggest using `findBy*` methods instead of the `waitFor` + `getBy` queries | ![recommended-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | ![fixable-badge][] |
| [prefer-presence-queries](docs/rules/prefer-presence-queries.md) | Enforce specific queries when checking element is present or not | | |
| [prefer-screen-queries](docs/rules/prefer-screen-queries.md) | Suggest using screen while using queries | | |
| [prefer-wait-for](docs/rules/prefer-wait-for.md) | Use `waitFor` instead of deprecated wait methods | | ![fixable-badge][] |
[build-badge]: https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/pipeline.yml/badge.svg
[build-url]: https://github.com/testing-library/eslint-plugin-testing-library/actions/workflows/pipeline.yml
[version-badge]: https://img.shields.io/npm/v/eslint-plugin-testing-library?style=flat-square
[version-url]: https://www.npmjs.com/package/eslint-plugin-testing-library
[license-badge]: https://img.shields.io/npm/l/eslint-plugin-testing-library?style=flat-square
[license-url]: https://github.com/belco90/eslint-plugin-testing-library/blob/main/license
[pr-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[pr-url]: http://makeapullrequest.com
[gh-watchers-badge]: https://img.shields.io/github/watchers/Belco90/eslint-plugin-testing-library?style=social
[gh-watchers-url]: https://github.com/belco90/eslint-plugin-testing-library/watchers
[gh-stars-badge]: https://img.shields.io/github/stars/Belco90/eslint-plugin-testing-library?style=social
[gh-stars-url]: https://github.com/belco90/eslint-plugin-testing-library/stargazers
[tweet-badge]: https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2FBelco90%2Feslint-plugin-testing-library
[tweet-url]: https://twitter.com/intent/tweet?url=https%3a%2f%2fgithub.com%2fbelco90%2feslint-plugin-testing-library&text=check%20out%20eslint-plugin-testing-library%20by%20@belcodev
[recommended-badge]: https://img.shields.io/badge/recommended-lightgrey?style=flat-square
[fixable-badge]: https://img.shields.io/badge/fixable-success?style=flat-square
[angular-badge]: https://img.shields.io/badge/-Angular-black?style=flat-square&logo=angular&logoColor=white&labelColor=DD0031&color=black
[react-badge]: https://img.shields.io/badge/-React-black?style=flat-square&logo=react&logoColor=white&labelColor=61DAFB&color=black
[vue-badge]: https://img.shields.io/badge/-Vue-black?style=flat-square&logo=vue.js&logoColor=white&labelColor=4FC08D&color=black
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://mario.dev"><img src="https://avatars1.githubusercontent.com/u/2677072?v=4" width="100px;" alt=""/><br /><sub><b>Mario Beltrán Alarcón</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3ABelco90" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Belco90" title="Tests">⚠️</a> <a href="#infra-Belco90" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3ABelco90" title="Bug reports">🐛</a></td>
<td align="center"><a href="http://thomlom.dev"><img src="https://avatars3.githubusercontent.com/u/16003285?v=4" width="100px;" alt=""/><br /><sub><b>Thomas Lombart</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thomlom" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thomlom" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3Athomlom" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thomlom" title="Tests">⚠️</a> <a href="#infra-thomlom" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center"><a href="https://github.com/benmonro"><img src="https://avatars3.githubusercontent.com/u/399236?v=4" width="100px;" alt=""/><br /><sub><b>Ben Monro</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=benmonro" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=benmonro" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=benmonro" title="Tests">⚠️</a></td>
<td align="center"><a href="https://emmenko.org/"><img src="https://avatars2.githubusercontent.com/u/1110551?v=4" width="100px;" alt=""/><br /><sub><b>Nicola Molinari</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=emmenko" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=emmenko" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=emmenko" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3Aemmenko" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://aarongarciah.com"><img src="https://avatars0.githubusercontent.com/u/7225802?v=4" width="100px;" alt=""/><br /><sub><b>Aarón García Hervás</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=aarongarciah" title="Documentation">📖</a></td>
<td align="center"><a href="https://www.matej.snuderl.si/"><img src="https://avatars3.githubusercontent.com/u/8524109?v=4" width="100px;" alt=""/><br /><sub><b>Matej Šnuderl</b></sub></a><br /><a href="#ideas-Meemaw" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Meemaw" title="Documentation">📖</a></td>
<td align="center"><a href="https://afontcu.dev"><img src="https://avatars0.githubusercontent.com/u/9197791?v=4" width="100px;" alt=""/><br /><sub><b>Adrià Fontcuberta</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=afontcu" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=afontcu" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/jonaldinger"><img src="https://avatars1.githubusercontent.com/u/663362?v=4" width="100px;" alt=""/><br /><sub><b>Jon Aldinger</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=jonaldinger" title="Documentation">📖</a></td>
<td align="center"><a href="http://www.thomasknickman.com"><img src="https://avatars1.githubusercontent.com/u/2933988?v=4" width="100px;" alt=""/><br /><sub><b>Thomas Knickman</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=tknickman" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=tknickman" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=tknickman" title="Tests">⚠️</a></td>
<td align="center"><a href="http://exercism.io/profiles/wolverineks/619ce225090a43cb891d2edcbbf50401"><img src="https://avatars2.githubusercontent.com/u/8462274?v=4" width="100px;" alt=""/><br /><sub><b>Kevin Sullivan</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=wolverineks" title="Documentation">📖</a></td>
<td align="center"><a href="https://kubajastrz.com"><img src="https://avatars0.githubusercontent.com/u/6443113?v=4" width="100px;" alt=""/><br /><sub><b>Jakub Jastrzębski</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=KubaJastrz" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=KubaJastrz" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=KubaJastrz" title="Tests">⚠️</a></td>
<td align="center"><a href="http://arvigeus.github.com"><img src="https://avatars2.githubusercontent.com/u/4872470?v=4" width="100px;" alt=""/><br /><sub><b>Nikolay Stoynov</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=arvigeus" title="Documentation">📖</a></td>
<td align="center"><a href="https://marudor.de"><img src="https://avatars0.githubusercontent.com/u/1881725?v=4" width="100px;" alt=""/><br /><sub><b>marudor</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=marudor" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=marudor" title="Tests">⚠️</a></td>
<td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4" width="100px;" alt=""/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=timdeschryver" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=timdeschryver" title="Documentation">📖</a> <a href="#ideas-timdeschryver" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3Atimdeschryver" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=timdeschryver" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Atimdeschryver" title="Bug reports">🐛</a> <a href="#infra-timdeschryver" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-timdeschryver" title="Packaging/porting to new platform">📦</a></td>
</tr>
<tr>
<td align="center"><a href="http://tdeekens.name"><img src="https://avatars3.githubusercontent.com/u/1877073?v=4" width="100px;" alt=""/><br /><sub><b>Tobias Deekens</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Atdeekens" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/victorandcode"><img src="https://avatars0.githubusercontent.com/u/18427801?v=4" width="100px;" alt=""/><br /><sub><b>Victor Cordova</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=victorandcode" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=victorandcode" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Avictorandcode" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/dmitry-lobanov"><img src="https://avatars0.githubusercontent.com/u/7376755?v=4" width="100px;" alt=""/><br /><sub><b>Dmitry Lobanov</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=dmitry-lobanov" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=dmitry-lobanov" title="Tests">⚠️</a></td>
<td align="center"><a href="https://kentcdodds.com"><img src="https://avatars0.githubusercontent.com/u/1500684?v=4" width="100px;" alt=""/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Akentcdodds" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/gndelia"><img src="https://avatars1.githubusercontent.com/u/352474?v=4" width="100px;" alt=""/><br /><sub><b>Gonzalo D'Elia</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=gndelia" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=gndelia" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=gndelia" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3Agndelia" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/jmcriffey"><img src="https://avatars0.githubusercontent.com/u/2831294?v=4" width="100px;" alt=""/><br /><sub><b>Jeff Rifwald</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=jmcriffey" title="Documentation">📖</a></td>
<td align="center"><a href="https://blog.lourenci.com/"><img src="https://avatars3.githubusercontent.com/u/2339362?v=4" width="100px;" alt=""/><br /><sub><b>Leandro Lourenci</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Alourenci" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=lourenci" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=lourenci" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center"><a href="https://xxxl.digital/"><img src="https://avatars2.githubusercontent.com/u/42043025?v=4" width="100px;" alt=""/><br /><sub><b>Miguel Erja González</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Amiguelerja" title="Bug reports">🐛</a></td>
<td align="center"><a href="http://pustovalov.dev"><img src="https://avatars2.githubusercontent.com/u/1568885?v=4" width="100px;" alt=""/><br /><sub><b>Pavel Pustovalov</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Apustovalov" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/jrparish"><img src="https://avatars3.githubusercontent.com/u/5173987?v=4" width="100px;" alt=""/><br /><sub><b>Jacob Parish</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Ajrparish" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=jrparish" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=jrparish" title="Tests">⚠️</a></td>
<td align="center"><a href="https://nickmccurdy.com/"><img src="https://avatars0.githubusercontent.com/u/927220?v=4" width="100px;" alt=""/><br /><sub><b>Nick McCurdy</b></sub></a><br /><a href="#ideas-nickmccurdy" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=nickmccurdy" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/pulls?q=is%3Apr+reviewed-by%3Anickmccurdy" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4" width="100px;" alt=""/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/issues?q=author%3Astefcameron" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://www.linkedin.com/in/mateusfelix/"><img src="https://avatars2.githubusercontent.com/u/4968788?v=4" width="100px;" alt=""/><br /><sub><b>Mateus Felix</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thebinaryfelix" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thebinaryfelix" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=thebinaryfelix" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/renatoagds"><img src="https://avatars2.githubusercontent.com/u/1663717?v=4" width="100px;" alt=""/><br /><sub><b>Renato Augusto Gama dos Santos</b></sub></a><br /><a href="#ideas-renatoagds" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=renatoagds" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=renatoagds" title="Documentation">📖</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=renatoagds" title="Tests">⚠️</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/codecog"><img src="https://avatars0.githubusercontent.com/u/5106076?v=4" width="100px;" alt=""/><br /><sub><b>Josh Kelly</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=codecog" title="Code">💻</a></td>
<td align="center"><a href="http://aless.co"><img src="https://avatars0.githubusercontent.com/u/5139846?v=4" width="100px;" alt=""/><br /><sub><b>Alessia Bellisario</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=alessbell" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=alessbell" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=alessbell" title="Documentation">📖</a></td>
<td align="center"><a href="https://skovy.dev"><img src="https://avatars1.githubusercontent.com/u/5247455?v=4" width="100px;" alt=""/><br /><sub><b>Spencer Miskoviak</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=skovy" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=skovy" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=skovy" title="Documentation">📖</a> <a href="#ideas-skovy" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://twitter.com/Gpx"><img src="https://avatars0.githubusercontent.com/u/767959?v=4" width="100px;" alt=""/><br /><sub><b>Giorgio Polvara</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Gpx" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Gpx" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=Gpx" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/jdanil"><img src="https://avatars0.githubusercontent.com/u/8342105?v=4" width="100px;" alt=""/><br /><sub><b>Josh David</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=jdanil" title="Documentation">📖</a></td>
<td align="center"><a href="https://michaeldeboey.be"><img src="https://avatars3.githubusercontent.com/u/6643991?v=4" width="100px;" alt=""/><br /><sub><b>Michaël De Boey</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=MichaelDeBoey" title="Code">💻</a> <a href="#platform-MichaelDeBoey" title="Packaging/porting to new platform">📦</a> <a href="#maintenance-MichaelDeBoey" title="Maintenance">🚧</a></td>
<td align="center"><a href="https://github.com/J-Huang"><img src="https://avatars0.githubusercontent.com/u/4263459?v=4" width="100px;" alt=""/><br /><sub><b>Jian Huang</b></sub></a><br /><a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=J-Huang" title="Code">💻</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=J-Huang" title="Tests">⚠️</a> <a href="https://github.com/testing-library/eslint-plugin-testing-library/commits?author=J-Huang" title="Documentation">📖</a></td>
</tr>
</table>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

View file

@ -0,0 +1,78 @@
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var await_async_query_1 = __importDefault(require("./rules/await-async-query"));
var await_async_utils_1 = __importDefault(require("./rules/await-async-utils"));
var await_fire_event_1 = __importDefault(require("./rules/await-fire-event"));
var consistent_data_testid_1 = __importDefault(require("./rules/consistent-data-testid"));
var no_await_sync_events_1 = __importDefault(require("./rules/no-await-sync-events"));
var no_await_sync_query_1 = __importDefault(require("./rules/no-await-sync-query"));
var no_debug_1 = __importDefault(require("./rules/no-debug"));
var no_dom_import_1 = __importDefault(require("./rules/no-dom-import"));
var no_manual_cleanup_1 = __importDefault(require("./rules/no-manual-cleanup"));
var no_render_in_setup_1 = __importDefault(require("./rules/no-render-in-setup"));
var no_wait_for_empty_callback_1 = __importDefault(require("./rules/no-wait-for-empty-callback"));
var no_wait_for_snapshot_1 = __importDefault(require("./rules/no-wait-for-snapshot"));
var prefer_explicit_assert_1 = __importDefault(require("./rules/prefer-explicit-assert"));
var prefer_presence_queries_1 = __importDefault(require("./rules/prefer-presence-queries"));
var prefer_screen_queries_1 = __importDefault(require("./rules/prefer-screen-queries"));
var prefer_wait_for_1 = __importDefault(require("./rules/prefer-wait-for"));
var prefer_find_by_1 = __importDefault(require("./rules/prefer-find-by"));
var rules = {
'await-async-query': await_async_query_1.default,
'await-async-utils': await_async_utils_1.default,
'await-fire-event': await_fire_event_1.default,
'consistent-data-testid': consistent_data_testid_1.default,
'no-await-sync-events': no_await_sync_events_1.default,
'no-await-sync-query': no_await_sync_query_1.default,
'no-debug': no_debug_1.default,
'no-dom-import': no_dom_import_1.default,
'no-manual-cleanup': no_manual_cleanup_1.default,
'no-render-in-setup': no_render_in_setup_1.default,
'no-wait-for-empty-callback': no_wait_for_empty_callback_1.default,
'no-wait-for-snapshot': no_wait_for_snapshot_1.default,
'prefer-explicit-assert': prefer_explicit_assert_1.default,
'prefer-find-by': prefer_find_by_1.default,
'prefer-presence-queries': prefer_presence_queries_1.default,
'prefer-screen-queries': prefer_screen_queries_1.default,
'prefer-wait-for': prefer_wait_for_1.default,
};
var recommendedRules = {
'testing-library/await-async-query': 'error',
'testing-library/await-async-utils': 'error',
'testing-library/no-await-sync-query': 'error',
'testing-library/prefer-find-by': 'error',
};
module.exports = {
rules: rules,
configs: {
recommended: {
plugins: ['testing-library'],
rules: recommendedRules,
},
angular: {
plugins: ['testing-library'],
rules: __assign(__assign({}, recommendedRules), { 'testing-library/no-debug': 'warn', 'testing-library/no-dom-import': ['error', 'angular'] }),
},
react: {
plugins: ['testing-library'],
rules: __assign(__assign({}, recommendedRules), { 'testing-library/no-debug': 'warn', 'testing-library/no-dom-import': ['error', 'react'] }),
},
vue: {
plugins: ['testing-library'],
rules: __assign(__assign({}, recommendedRules), { 'testing-library/await-fire-event': 'error', 'testing-library/no-debug': 'warn', 'testing-library/no-dom-import': ['error', 'vue'] }),
},
},
};

View file

@ -0,0 +1,130 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVariableReferences = exports.isPromiseResolved = exports.isAwaited = exports.isArrayExpression = exports.isReturnStatement = exports.isArrowFunctionExpression = exports.isAwaitExpression = exports.hasThenProperty = exports.isObjectExpression = exports.findClosestCallNode = exports.findClosestCallExpressionNode = exports.isJSXAttribute = exports.isProperty = exports.isObjectPattern = exports.isRenderFunction = exports.isVariableDeclarator = exports.isBlockStatement = exports.isImportDefaultSpecifier = exports.isImportNamespaceSpecifier = exports.isImportSpecifier = exports.isLiteral = exports.isMemberExpression = exports.isIdentifier = exports.isCallExpression = void 0;
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
function isCallExpression(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.CallExpression;
}
exports.isCallExpression = isCallExpression;
function isIdentifier(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.Identifier;
}
exports.isIdentifier = isIdentifier;
function isMemberExpression(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.MemberExpression;
}
exports.isMemberExpression = isMemberExpression;
function isLiteral(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.Literal;
}
exports.isLiteral = isLiteral;
function isImportSpecifier(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.ImportSpecifier;
}
exports.isImportSpecifier = isImportSpecifier;
function isImportNamespaceSpecifier(node) {
return (node === null || node === void 0 ? void 0 : node.type) === experimental_utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier;
}
exports.isImportNamespaceSpecifier = isImportNamespaceSpecifier;
function isImportDefaultSpecifier(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.ImportDefaultSpecifier;
}
exports.isImportDefaultSpecifier = isImportDefaultSpecifier;
function isBlockStatement(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.BlockStatement;
}
exports.isBlockStatement = isBlockStatement;
function isVariableDeclarator(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.VariableDeclarator;
}
exports.isVariableDeclarator = isVariableDeclarator;
function isRenderFunction(callNode, renderFunctions) {
return renderFunctions.some(function (name) {
return ((isIdentifier(callNode.callee) && name === callNode.callee.name) ||
(isMemberExpression(callNode.callee) &&
isIdentifier(callNode.callee.property) &&
name === callNode.callee.property.name));
});
}
exports.isRenderFunction = isRenderFunction;
function isObjectPattern(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.ObjectPattern;
}
exports.isObjectPattern = isObjectPattern;
function isProperty(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.Property;
}
exports.isProperty = isProperty;
function isJSXAttribute(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.JSXAttribute;
}
exports.isJSXAttribute = isJSXAttribute;
function findClosestCallExpressionNode(node) {
if (isCallExpression(node)) {
return node;
}
if (!node.parent)
return null;
return findClosestCallExpressionNode(node.parent);
}
exports.findClosestCallExpressionNode = findClosestCallExpressionNode;
function findClosestCallNode(node, name) {
if (!node.parent) {
return null;
}
if (isCallExpression(node) &&
isIdentifier(node.callee) &&
node.callee.name === name) {
return node;
}
else {
return findClosestCallNode(node.parent, name);
}
}
exports.findClosestCallNode = findClosestCallNode;
function isObjectExpression(node) {
return (node === null || node === void 0 ? void 0 : node.type) === experimental_utils_1.AST_NODE_TYPES.ObjectExpression;
}
exports.isObjectExpression = isObjectExpression;
function hasThenProperty(node) {
return (isMemberExpression(node) &&
isIdentifier(node.property) &&
node.property.name === 'then');
}
exports.hasThenProperty = hasThenProperty;
function isAwaitExpression(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.AwaitExpression;
}
exports.isAwaitExpression = isAwaitExpression;
function isArrowFunctionExpression(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression;
}
exports.isArrowFunctionExpression = isArrowFunctionExpression;
function isReturnStatement(node) {
return node && node.type === experimental_utils_1.AST_NODE_TYPES.ReturnStatement;
}
exports.isReturnStatement = isReturnStatement;
function isArrayExpression(node) {
return (node === null || node === void 0 ? void 0 : node.type) === experimental_utils_1.AST_NODE_TYPES.ArrayExpression;
}
exports.isArrayExpression = isArrayExpression;
function isAwaited(node) {
return (isAwaitExpression(node) ||
isArrowFunctionExpression(node) ||
isReturnStatement(node));
}
exports.isAwaited = isAwaited;
function isPromiseResolved(node) {
var parent = node.parent;
if (isCallExpression(parent)) {
return hasThenProperty(parent.parent);
}
return hasThenProperty(parent);
}
exports.isPromiseResolved = isPromiseResolved;
function getVariableReferences(context, node) {
return ((isVariableDeclarator(node) &&
context.getDeclaredVariables(node)[0].references.slice(1)) ||
[]);
}
exports.getVariableReferences = getVariableReferences;

View file

@ -0,0 +1,669 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [3.10.1](https://github.com/typescript-eslint/typescript-eslint/compare/v3.10.0...v3.10.1) (2020-08-25)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.9.1...v3.10.0) (2020-08-24)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [3.9.1](https://github.com/typescript-eslint/typescript-eslint/compare/v3.9.0...v3.9.1) (2020-08-17)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.9.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.8.0...v3.9.0) (2020-08-10)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.8.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.7.1...v3.8.0) (2020-08-03)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [3.7.1](https://github.com/typescript-eslint/typescript-eslint/compare/v3.7.0...v3.7.1) (2020-07-27)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.7.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.6.1...v3.7.0) (2020-07-20)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [3.6.1](https://github.com/typescript-eslint/typescript-eslint/compare/v3.6.0...v3.6.1) (2020-07-13)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.6.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.5.0...v3.6.0) (2020-07-06)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.5.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.4.0...v3.5.0) (2020-06-29)
### Features
* add package scope-manager ([#1939](https://github.com/typescript-eslint/typescript-eslint/issues/1939)) ([682eb7e](https://github.com/typescript-eslint/typescript-eslint/commit/682eb7e009c3f22a542882dfd3602196a60d2a1e))
* split types into their own package ([#2229](https://github.com/typescript-eslint/typescript-eslint/issues/2229)) ([5f45918](https://github.com/typescript-eslint/typescript-eslint/commit/5f4591886f3438329fbf2229b03ac66174334a24))
# [3.4.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.3.0...v3.4.0) (2020-06-22)
### Bug Fixes
* **experimental-utils:** correct types for TS versions older than 3.8 ([#2217](https://github.com/typescript-eslint/typescript-eslint/issues/2217)) ([5e4dda2](https://github.com/typescript-eslint/typescript-eslint/commit/5e4dda264a7d6a6a1626848e7599faea1ac34922))
* **experimental-utils:** getParserServices takes a readonly context ([#2235](https://github.com/typescript-eslint/typescript-eslint/issues/2235)) ([26da8de](https://github.com/typescript-eslint/typescript-eslint/commit/26da8de7fcde9eddec63212d79af781c4bb22991))
# [3.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.2.0...v3.3.0) (2020-06-15)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [3.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.1.0...v3.2.0) (2020-06-08)
### Bug Fixes
* **eslint-plugin:** [prefer-optional-chain] handling first member expression ([#2156](https://github.com/typescript-eslint/typescript-eslint/issues/2156)) ([de18660](https://github.com/typescript-eslint/typescript-eslint/commit/de18660a8cf8f7033798646d8c5b0938d1accb12))
# [3.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v3.0.2...v3.1.0) (2020-06-01)
### Bug Fixes
* **experimental-utils:** downlevel type declarations for versions older than 3.8 ([#2133](https://github.com/typescript-eslint/typescript-eslint/issues/2133)) ([7925823](https://github.com/typescript-eslint/typescript-eslint/commit/792582326a8065270b69a0ffcaad5a7b4b103ff3))
### Features
* **eslint-plugin:** [explicit-module-boundary-types] improve accuracy and coverage ([#2135](https://github.com/typescript-eslint/typescript-eslint/issues/2135)) ([caaa859](https://github.com/typescript-eslint/typescript-eslint/commit/caaa8599284d02ab3341e282cad35a52d0fb86c7))
## [3.0.2](https://github.com/typescript-eslint/typescript-eslint/compare/v3.0.1...v3.0.2) (2020-05-27)
### Bug Fixes
* regression for eslint v6 ([#2105](https://github.com/typescript-eslint/typescript-eslint/issues/2105)) ([31fc503](https://github.com/typescript-eslint/typescript-eslint/commit/31fc5039ed919e1515fda673c186d5c83eb5beb3))
## [3.0.1](https://github.com/typescript-eslint/typescript-eslint/compare/v3.0.0...v3.0.1) (2020-05-25)
### Bug Fixes
* **experimental-utils:** export `CLIEngine` & `ESLint` ([#2083](https://github.com/typescript-eslint/typescript-eslint/issues/2083)) ([014341b](https://github.com/typescript-eslint/typescript-eslint/commit/014341bb23261f609fc2a6fe7fece191466a084a))
# [3.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.34.0...v3.0.0) (2020-05-21)
## [Please see the release notes for v3.0.0](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v3.0.0)
### Bug Fixes
* **experimental-utils:** add back SourceCode.isSpaceBetweenTokens ([ae82ea4](https://github.com/typescript-eslint/typescript-eslint/commit/ae82ea4a85a4ca332ebe6104e96c59dba30411be))
* **typescript-estree:** remove now defunct `Import` node type ([f199cbd](https://github.com/typescript-eslint/typescript-eslint/commit/f199cbdbbd892b5ba03bfff66f463f3d9c92ee9b))
### Features
* **experimental-utils:** upgrade eslint types for v7 ([#2023](https://github.com/typescript-eslint/typescript-eslint/issues/2023)) ([06869c9](https://github.com/typescript-eslint/typescript-eslint/commit/06869c9656fa37936126666845aee40aad546ebd))
* drop support for node v8 ([#1997](https://github.com/typescript-eslint/typescript-eslint/issues/1997)) ([b6c3b7b](https://github.com/typescript-eslint/typescript-eslint/commit/b6c3b7b84b8d199fa75a46432febd4a364a63217))
* upgrade to ESLint v7 ([#2022](https://github.com/typescript-eslint/typescript-eslint/issues/2022)) ([208de71](https://github.com/typescript-eslint/typescript-eslint/commit/208de71059746bf38e94bd460346ffb2698a3e12))
* **eslint-plugin:** [ban-types] rework default options ([#848](https://github.com/typescript-eslint/typescript-eslint/issues/848)) ([8e31d5d](https://github.com/typescript-eslint/typescript-eslint/commit/8e31d5dbe9fe5227fdbefcecfd50ce5dd51360c3))
* **typescript-estree:** always return parserServices ([#716](https://github.com/typescript-eslint/typescript-eslint/issues/716)) ([5b23443](https://github.com/typescript-eslint/typescript-eslint/commit/5b23443c48f3f62424db3e742243f3568080b946))
# [2.34.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.33.0...v2.34.0) (2020-05-18)
### Features
* **experimental-utils:** add `suggestion` property for rule modules ([#2033](https://github.com/typescript-eslint/typescript-eslint/issues/2033)) ([f42a5b0](https://github.com/typescript-eslint/typescript-eslint/commit/f42a5b09ebfa173f418a99c552b0cbe221567194))
# [2.33.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.32.0...v2.33.0) (2020-05-12)
### Bug Fixes
* **experimental-utils:** remove accidental dep on json-schema ([#2010](https://github.com/typescript-eslint/typescript-eslint/issues/2010)) ([1875fba](https://github.com/typescript-eslint/typescript-eslint/commit/1875fbad41f2a3dda8f610f5dcd180c6205b73d3))
# [2.32.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.31.0...v2.32.0) (2020-05-11)
### Features
* bump dependencies and align AST ([#2007](https://github.com/typescript-eslint/typescript-eslint/issues/2007)) ([18668b7](https://github.com/typescript-eslint/typescript-eslint/commit/18668b78fd7d1e5281af7fc26c76e0ca53297f69))
# [2.31.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.30.0...v2.31.0) (2020-05-04)
### Features
* **experimental-utils:** expose our RuleTester extension ([#1948](https://github.com/typescript-eslint/typescript-eslint/issues/1948)) ([2dd1638](https://github.com/typescript-eslint/typescript-eslint/commit/2dd1638aaa2658ba99b2341861146b586f489121))
# [2.30.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.29.0...v2.30.0) (2020-04-27)
### Features
* **experimental-utils:** allow rule options to be a readonly tuple ([#1924](https://github.com/typescript-eslint/typescript-eslint/issues/1924)) ([4ef6788](https://github.com/typescript-eslint/typescript-eslint/commit/4ef67884962b6aac61cc895aaa3ba16aa892ecf4))
# [2.29.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.28.0...v2.29.0) (2020-04-20)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.28.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.27.0...v2.28.0) (2020-04-13)
### Features
* **eslint-plugin:** add rule `prefer-reduce-type-parameter` ([#1707](https://github.com/typescript-eslint/typescript-eslint/issues/1707)) ([c92d240](https://github.com/typescript-eslint/typescript-eslint/commit/c92d240e49113779053eac32038382b282812afc))
# [2.27.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.26.0...v2.27.0) (2020-04-06)
### Features
* **experimental-utils:** add types for suggestions from CLIEngine ([#1844](https://github.com/typescript-eslint/typescript-eslint/issues/1844)) ([7c11bd6](https://github.com/typescript-eslint/typescript-eslint/commit/7c11bd66f2d0e5ea9d3943e6b8c66e6ddff50862))
* **experimental-utils:** update eslint types to match v6.8 ([#1846](https://github.com/typescript-eslint/typescript-eslint/issues/1846)) ([16ce74d](https://github.com/typescript-eslint/typescript-eslint/commit/16ce74d247781ac890dc0baa30c384f97e581b6b))
# [2.26.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.25.0...v2.26.0) (2020-03-30)
### Features
* **typescript-estree:** add option to ignore certain folders from glob resolution ([#1802](https://github.com/typescript-eslint/typescript-eslint/issues/1802)) ([1e29e69](https://github.com/typescript-eslint/typescript-eslint/commit/1e29e69b289d61107a7de67592beae331ba50222))
# [2.25.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.24.0...v2.25.0) (2020-03-23)
### Features
* **experimental-utils:** expose ast utility functions ([#1670](https://github.com/typescript-eslint/typescript-eslint/issues/1670)) ([3eb5d45](https://github.com/typescript-eslint/typescript-eslint/commit/3eb5d4525e95c8ab990f55588b8d830a02ce5a9c))
# [2.24.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.23.0...v2.24.0) (2020-03-16)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.23.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.22.0...v2.23.0) (2020-03-09)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.22.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.21.0...v2.22.0) (2020-03-02)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.21.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.20.0...v2.21.0) (2020-02-24)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.20.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.19.2...v2.20.0) (2020-02-17)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [2.19.2](https://github.com/typescript-eslint/typescript-eslint/compare/v2.19.1...v2.19.2) (2020-02-10)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [2.19.1](https://github.com/typescript-eslint/typescript-eslint/compare/v2.19.0...v2.19.1) (2020-02-10)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.19.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.18.0...v2.19.0) (2020-02-03)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.18.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.17.0...v2.18.0) (2020-01-27)
### Bug Fixes
* improve token types and add missing type guards ([#1497](https://github.com/typescript-eslint/typescript-eslint/issues/1497)) ([ce41d7d](https://github.com/typescript-eslint/typescript-eslint/commit/ce41d7de33bcb7ccf96c03ac1438304c5a49ff54))
* **experimental-utils:** widen type of `settings` property ([#1527](https://github.com/typescript-eslint/typescript-eslint/issues/1527)) ([b515e47](https://github.com/typescript-eslint/typescript-eslint/commit/b515e47af2bc914c7ebcfa4be813409dcd86b1c3))
### Features
* **experimental-utils:** make RuleMetaData.docs optional ([#1462](https://github.com/typescript-eslint/typescript-eslint/issues/1462)) ([cde97ac](https://github.com/typescript-eslint/typescript-eslint/commit/cde97aca24df5a0f28f37006ed130ebc217fb2ad))
* **parser:** clean up scope-analysis types ([#1481](https://github.com/typescript-eslint/typescript-eslint/issues/1481)) ([4a727fa](https://github.com/typescript-eslint/typescript-eslint/commit/4a727fa083d749dba9eaf39322856f5f69c28cd8))
# [2.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.16.0...v2.17.0) (2020-01-20)
### Features
* **experimental-utils:** expose getParserServices from utils ([#1448](https://github.com/typescript-eslint/typescript-eslint/issues/1448)) ([982c8bc](https://github.com/typescript-eslint/typescript-eslint/commit/982c8bc))
# [2.16.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.15.0...v2.16.0) (2020-01-13)
### Features
* **typescript-estree:** add parserOption to turn on debug logs ([#1413](https://github.com/typescript-eslint/typescript-eslint/issues/1413)) ([25092fd](https://github.com/typescript-eslint/typescript-eslint/commit/25092fd))
* **typescript-estree:** add strict type mapping to esTreeNodeToTSNodeMap ([#1382](https://github.com/typescript-eslint/typescript-eslint/issues/1382)) ([d3d70a3](https://github.com/typescript-eslint/typescript-eslint/commit/d3d70a3))
# [2.15.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.14.0...v2.15.0) (2020-01-06)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.14.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.13.0...v2.14.0) (2019-12-30)
### Features
* add internal eslint plugin for repo-specific lint rules ([#1373](https://github.com/typescript-eslint/typescript-eslint/issues/1373)) ([3a15413](https://github.com/typescript-eslint/typescript-eslint/commit/3a15413))
# [2.13.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.12.0...v2.13.0) (2019-12-23)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.11.0...v2.12.0) (2019-12-16)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.10.0...v2.11.0) (2019-12-09)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.9.0...v2.10.0) (2019-12-02)
### Features
* **eslint-plugin:** [no-non-null-assert] add suggestion fixer ([#1260](https://github.com/typescript-eslint/typescript-eslint/issues/1260)) ([e350a21](https://github.com/typescript-eslint/typescript-eslint/commit/e350a21))
* **experimental-utils:** add isSpaceBetween declaration to Sou… ([#1268](https://github.com/typescript-eslint/typescript-eslint/issues/1268)) ([f83f04b](https://github.com/typescript-eslint/typescript-eslint/commit/f83f04b))
# [2.9.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.8.0...v2.9.0) (2019-11-25)
### Features
* suggestion types, suggestions for no-explicit-any ([#1250](https://github.com/typescript-eslint/typescript-eslint/issues/1250)) ([b16a4b6](https://github.com/typescript-eslint/typescript-eslint/commit/b16a4b6))
* **eslint-plugin:** add prefer-nullish-coalescing ([#1069](https://github.com/typescript-eslint/typescript-eslint/issues/1069)) ([a9cd399](https://github.com/typescript-eslint/typescript-eslint/commit/a9cd399))
* **eslint-plugin:** add rule prefer-optional-chain ([#1213](https://github.com/typescript-eslint/typescript-eslint/issues/1213)) ([ad7e1a7](https://github.com/typescript-eslint/typescript-eslint/commit/ad7e1a7))
# [2.8.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.7.0...v2.8.0) (2019-11-18)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.7.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.6.1...v2.7.0) (2019-11-11)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [2.6.1](https://github.com/typescript-eslint/typescript-eslint/compare/v2.6.0...v2.6.1) (2019-11-04)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.6.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.5.0...v2.6.0) (2019-10-28)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.5.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.4.0...v2.5.0) (2019-10-21)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.4.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.3.3...v2.4.0) (2019-10-14)
### Bug Fixes
* support long running "watch" lint sessions ([#973](https://github.com/typescript-eslint/typescript-eslint/issues/973)) ([854620e](https://github.com/typescript-eslint/typescript-eslint/commit/854620e))
### Features
* **typescript-estree:** support for parsing 3.7 features ([#1045](https://github.com/typescript-eslint/typescript-eslint/issues/1045)) ([623febf](https://github.com/typescript-eslint/typescript-eslint/commit/623febf))
## [2.3.3](https://github.com/typescript-eslint/typescript-eslint/compare/v2.3.2...v2.3.3) (2019-10-07)
### Bug Fixes
* **experimental-utils:** remove Rule.meta.extraDescription ([#1036](https://github.com/typescript-eslint/typescript-eslint/issues/1036)) ([192e23d](https://github.com/typescript-eslint/typescript-eslint/commit/192e23d))
## [2.3.2](https://github.com/typescript-eslint/typescript-eslint/compare/v2.3.1...v2.3.2) (2019-09-30)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [2.3.1](https://github.com/typescript-eslint/typescript-eslint/compare/v2.3.0...v2.3.1) (2019-09-23)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.3.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.2.0...v2.3.0) (2019-09-16)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.2.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.1.0...v2.2.0) (2019-09-09)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.1.0](https://github.com/typescript-eslint/typescript-eslint/compare/v2.0.0...v2.1.0) (2019-09-02)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [2.0.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.13.0...v2.0.0) (2019-08-13)
### Bug Fixes
* **eslint-plugin:** add `Literal` to `RuleListener` types ([#824](https://github.com/typescript-eslint/typescript-eslint/issues/824)) ([3c902a1](https://github.com/typescript-eslint/typescript-eslint/commit/3c902a1))
* **utils:** add ES2019 as valid `ecmaVersion` ([#746](https://github.com/typescript-eslint/typescript-eslint/issues/746)) ([d11fbbe](https://github.com/typescript-eslint/typescript-eslint/commit/d11fbbe))
### Features
* explicitly support eslint v6 ([#645](https://github.com/typescript-eslint/typescript-eslint/issues/645)) ([34a7cf6](https://github.com/typescript-eslint/typescript-eslint/commit/34a7cf6))
* feat(eslint-plugin)!: recommended-requiring-type-checking config (#846) ([d3470c9](https://github.com/typescript-eslint/typescript-eslint/commit/d3470c9)), closes [#846](https://github.com/typescript-eslint/typescript-eslint/issues/846)
* feat(eslint-plugin)!: change recommended config (#729) ([428567d](https://github.com/typescript-eslint/typescript-eslint/commit/428567d)), closes [#729](https://github.com/typescript-eslint/typescript-eslint/issues/729)
* feat(eslint-plugin)!: add rule `consistent-type-assertions` (#731) ([92e98de](https://github.com/typescript-eslint/typescript-eslint/commit/92e98de)), closes [#731](https://github.com/typescript-eslint/typescript-eslint/issues/731)
### BREAKING CHANGES
* removed some rules from recommended config
* recommended config changes are considered breaking
* Merges both no-angle-bracket-type-assertion and no-object-literal-type-assertion into one rule
* Node 6 is no longer supported
# [1.13.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.12.0...v1.13.0) (2019-07-21)
### Bug Fixes
* Correct `@types/json-schema` dependency ([#675](https://github.com/typescript-eslint/typescript-eslint/issues/675)) ([a5398ce](https://github.com/typescript-eslint/typescript-eslint/commit/a5398ce))
* **utils:** move `typescript` from peer dep to dev dep ([#712](https://github.com/typescript-eslint/typescript-eslint/issues/712)) ([f949355](https://github.com/typescript-eslint/typescript-eslint/commit/f949355))
* **utils:** RuleTester should not require a parser ([#713](https://github.com/typescript-eslint/typescript-eslint/issues/713)) ([158a417](https://github.com/typescript-eslint/typescript-eslint/commit/158a417))
### Features
* **eslint-plugin:** add new rule no-misused-promises ([#612](https://github.com/typescript-eslint/typescript-eslint/issues/612)) ([28a131d](https://github.com/typescript-eslint/typescript-eslint/commit/28a131d))
# [1.12.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.11.0...v1.12.0) (2019-07-12)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [1.11.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.2...v1.11.0) (2019-06-23)
### Bug Fixes
* **eslint-plugin:** Remove duplicated code ([#611](https://github.com/typescript-eslint/typescript-eslint/issues/611)) ([c4df4ff](https://github.com/typescript-eslint/typescript-eslint/commit/c4df4ff))
### Features
* **eslint-plugin:** add `consistent-type-definitions` rule ([#463](https://github.com/typescript-eslint/typescript-eslint/issues/463)) ([ec87d06](https://github.com/typescript-eslint/typescript-eslint/commit/ec87d06))
## [1.10.2](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.1...v1.10.2) (2019-06-10)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
## [1.10.1](https://github.com/typescript-eslint/typescript-eslint/compare/v1.10.0...v1.10.1) (2019-06-09)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [1.10.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.9.0...v1.10.0) (2019-06-09)
### Bug Fixes
- **experimental-utils:** add `endLine` and `endColumn` ([#517](https://github.com/typescript-eslint/typescript-eslint/issues/517)) ([d9e5f15](https://github.com/typescript-eslint/typescript-eslint/commit/d9e5f15))
- **experimental-utils:** Avoid typescript import at runtime ([#584](https://github.com/typescript-eslint/typescript-eslint/issues/584)) ([fac5c7d](https://github.com/typescript-eslint/typescript-eslint/commit/fac5c7d)), closes [/github.com/typescript-eslint/typescript-eslint/pull/425#issuecomment-498162293](https://github.com//github.com/typescript-eslint/typescript-eslint/pull/425/issues/issuecomment-498162293)
### Features
- make utils/TSESLint export typed classes instead of just types ([#526](https://github.com/typescript-eslint/typescript-eslint/issues/526)) ([370ac72](https://github.com/typescript-eslint/typescript-eslint/commit/370ac72))
- support TypeScript versions >=3.2.1 <3.6.0 ([#597](https://github.com/typescript-eslint/typescript-eslint/issues/597)) ([5d2b962](https://github.com/typescript-eslint/typescript-eslint/commit/5d2b962))
# [1.9.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.8.0...v1.9.0) (2019-05-12)
**Note:** Version bump only for package @typescript-eslint/experimental-utils
# [1.8.0](https://github.com/typescript-eslint/typescript-eslint/compare/v1.7.0...v1.8.0) (2019-05-10)
### Features
- Move shared types into their own package ([#425](https://github.com/typescript-eslint/typescript-eslint/issues/425)) ([a7a03ce](https://github.com/typescript-eslint/typescript-eslint/commit/a7a03ce))

View file

@ -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.

View file

@ -0,0 +1,37 @@
<h1 align="center">Utils for ESLint Plugins</h1>
<p align="center">Utilities for working with TypeScript + ESLint together.</p>
<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/eslint-plugin"><img src="https://img.shields.io/npm/v/@typescript-eslint/eslint-plugin.svg?style=flat-square" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/package/@typescript-eslint/eslint-plugin"><img src="https://img.shields.io/npm/dm/@typescript-eslint/eslint-plugin.svg?style=flat-square" alt="NPM Downloads" /></a>
</p>
## Note
This package has inherited its version number from the `@typescript-eslint` project.
Meaning that even though this package is `2.x.y`, you shouldn't expect 100% stability between minor version bumps.
i.e. treat it as a `0.x.y` package.
Feel free to use it now, and let us know what utilities you need or send us PRs with utilities you build on top of it.
Once it is stable, it will be renamed to `@typescript-eslint/util` for a `4.0.0` release.
## Exports
| Name | Description |
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`ASTUtils`](./src/ast-utils) | Tools for operating on the ESTree AST. Also includes the [`eslint-utils`](https://www.npmjs.com/package/eslint-utils) package, correctly typed to work with the types found in `TSESTree` |
| [`ESLintUtils`](./src/eslint-utils) | Tools for creating ESLint rules with TypeScript. |
| `JSONSchema` | Types from the [`@types/json-schema`](https://www.npmjs.com/package/@types/json-schema) package, re-exported to save you having to manually import them. Also ensures you're using the same version of the types as this package. |
| [`TSESLint`](./src/ts-eslint) | Types for ESLint, correctly typed to work with the types found in `TSESTree`. |
| [`TSESLintScope`](./src/ts-eslint-scope) | The [`eslint-scope`](https://www.npmjs.com/package/eslint-scope) package, correctly typed to work with the types found in both `TSESTree` and `TSESLint` |
| [`TSESTree`](../types/src/ts-estree.ts) | Types for the TypeScript flavor of ESTree created by `@typescript-eslint/typescript-estree`. |
| [`AST_NODE_TYPES`](../types/src/ast-node-types.ts) | An enum with the names of every single _node_ found in `TSESTree`. |
| [`AST_TOKEN_TYPES`](../types/src/ast-token-types.ts) | An enum with the names of every single _token_ found in `TSESTree`. |
| [`ParserServices`](../typescript-estree/src/parser-options.ts) | Typing for the parser services provided when parsing a file using `@typescript-eslint/typescript-estree`. |
## Contributing
[See the contributing guide here](../../CONTRIBUTING.md)

View file

@ -0,0 +1,48 @@
interface PatternMatcher {
/**
* Iterate all matched parts in a given string.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-execall}
*/
execAll(str: string): IterableIterator<RegExpExecArray>;
/**
* Check whether this pattern matches a given string or not.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-test}
*/
test(str: string): boolean;
/**
* Replace all matched parts by a given replacer.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-symbol-replace}
* @example
* const { PatternMatcher } = require("eslint-utils")
* const matcher = new PatternMatcher(/\\p{Script=Greek}/g)
*
* module.exports = {
* meta: {},
* create(context) {
* return {
* "Literal[regex]"(node) {
* const replacedPattern = node.regex.pattern.replace(
* matcher,
* "[\\u0370-\\u0373\\u0375-\\u0377\\u037A-\\u037D\\u037F\\u0384\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03E1\\u03F0-\\u03FF\\u1D26-\\u1D2A\\u1D5D-\\u1D61\\u1D66-\\u1D6A\\u1DBF\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FC4\\u1FC6-\\u1FD3\\u1FD6-\\u1FDB\\u1FDD-\\u1FEF\\u1FF2-\\u1FF4\\u1FF6-\\u1FFE\\u2126\\uAB65]|\\uD800[\\uDD40-\\uDD8E\\uDDA0]|\\uD834[\\uDE00-\\uDE45]"
* )
* },
* }
* },
* }
*/
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
}
/**
* The class to find a pattern in strings as handling escape sequences.
* It ignores the found pattern if it's escaped with `\`.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#patternmatcher-class}
*/
declare const PatternMatcher: new (pattern: RegExp, options?: {
escaped?: boolean | undefined;
} | undefined) => PatternMatcher;
export { PatternMatcher };
//# sourceMappingURL=PatternMatcher.d.ts.map

View file

@ -0,0 +1,72 @@
import { TSESTree } from '../../ts-estree';
import * as TSESLint from '../../ts-eslint';
declare const ReferenceTrackerREAD: unique symbol;
declare const ReferenceTrackerCALL: unique symbol;
declare const ReferenceTrackerCONSTRUCT: unique symbol;
interface ReferenceTracker {
/**
* Iterate the references that the given `traceMap` determined.
* This method starts to search from global variables.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iterateglobalreferences}
*/
iterateGlobalReferences<T>(traceMap: ReferenceTracker.TraceMap<T>): IterableIterator<ReferenceTracker.FoundReference<T>>;
/**
* Iterate the references that the given `traceMap` determined.
* This method starts to search from `require()` expression.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iteratecjsreferences}
*/
iterateCjsReferences<T>(traceMap: ReferenceTracker.TraceMap<T>): IterableIterator<ReferenceTracker.FoundReference<T>>;
/**
* Iterate the references that the given `traceMap` determined.
* This method starts to search from `import`/`export` declarations.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iterateesmreferences}
*/
iterateEsmReferences<T>(traceMap: ReferenceTracker.TraceMap<T>): IterableIterator<ReferenceTracker.FoundReference<T>>;
}
interface ReferenceTrackerStatic {
new (globalScope: TSESLint.Scope.Scope, options?: {
/**
* The mode which determines how the `tracker.iterateEsmReferences()` method scans CommonJS modules.
* If this is `"strict"`, the method binds CommonJS modules to the default export. Otherwise, the method binds
* CommonJS modules to both the default export and named exports. Optional. Default is `"strict"`.
*/
mode: 'strict' | 'legacy';
/**
* The name list of Global Object. Optional. Default is `["global", "globalThis", "self", "window"]`.
*/
globalObjectNames: readonly string[];
}): ReferenceTracker;
readonly READ: typeof ReferenceTrackerREAD;
readonly CALL: typeof ReferenceTrackerCALL;
readonly CONSTRUCT: typeof ReferenceTrackerCONSTRUCT;
}
declare namespace ReferenceTracker {
type READ = ReferenceTrackerStatic['READ'];
type CALL = ReferenceTrackerStatic['CALL'];
type CONSTRUCT = ReferenceTrackerStatic['CONSTRUCT'];
type ReferenceType = READ | CALL | CONSTRUCT;
type TraceMap<T = any> = Record<string, TraceMapElement<T>>;
interface TraceMapElement<T> {
[ReferenceTrackerREAD]?: T;
[ReferenceTrackerCALL]?: T;
[ReferenceTrackerCONSTRUCT]?: T;
[key: string]: TraceMapElement<T>;
}
interface FoundReference<T = any> {
node: TSESTree.Node;
path: readonly string[];
type: ReferenceType;
entry: T;
}
}
/**
* The tracker for references. This provides reference tracking for global variables, CommonJS modules, and ES modules.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#referencetracker-class}
*/
declare const ReferenceTracker: ReferenceTrackerStatic;
export { ReferenceTracker };
//# sourceMappingURL=ReferenceTracker.d.ts.map

View file

@ -0,0 +1,82 @@
import { TSESTree } from '../../ts-estree';
import * as TSESLint from '../../ts-eslint';
/**
* Get the proper location of a given function node to report.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionheadlocation}
*/
declare const getFunctionHeadLocation: (node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression, sourceCode: TSESLint.SourceCode) => TSESTree.SourceLocation;
/**
* Get the name and kind of a given function node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionnamewithkind}
*/
declare const getFunctionNameWithKind: (node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression) => string;
/**
* Get the property name of a given property node.
* If the node is a computed property, this tries to compute the property name by the getStringIfConstant function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getpropertyname}
* @returns The property name of the node. If the property name is not constant then it returns `null`.
*/
declare const getPropertyName: (node: TSESTree.MemberExpression | TSESTree.OptionalMemberExpression | TSESTree.Property | TSESTree.MethodDefinition, initialScope?: TSESLint.Scope.Scope | undefined) => string | null;
/**
* Get the value of a given node if it can decide the value statically.
* If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
* given node as much as possible. In the resolving way, it does on the assumption that built-in global objects have
* not been modified.
* For example, it considers `Symbol.iterator`, ` String.raw``hello`` `, and `Object.freeze({a: 1}).a` as static.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstaticvalue}
* @returns The `{ value: any }` shaped object. The `value` property is the static value. If it couldn't compute the
* static value of the node, it returns `null`.
*/
declare const getStaticValue: (node: TSESTree.Node, initialScope?: TSESLint.Scope.Scope | undefined) => {
value: unknown;
} | null;
/**
* Get the string value of a given node.
* This function is a tiny wrapper of the getStaticValue function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstringifconstant}
*/
declare const getStringIfConstant: (node: TSESTree.Node, initialScope?: TSESLint.Scope.Scope | undefined) => string | null;
/**
* Check whether a given node has any side effect or not.
* The side effect means that it may modify a certain variable or object member. This function considers the node which
* contains the following types as the node which has side effects:
* - `AssignmentExpression`
* - `AwaitExpression`
* - `CallExpression`
* - `ImportExpression`
* - `NewExpression`
* - `UnaryExpression([operator = "delete"])`
* - `UpdateExpression`
* - `YieldExpression`
* - When `options.considerGetters` is `true`:
* - `MemberExpression`
* - When `options.considerImplicitTypeConversion` is `true`:
* - `BinaryExpression([operator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in"])`
* - `MemberExpression([computed = true])`
* - `MethodDefinition([computed = true])`
* - `Property([computed = true])`
* - `UnaryExpression([operator = "-" | "+" | "!" | "~"])`
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#hassideeffect}
*/
declare const hasSideEffect: (node: TSESTree.Node, sourceCode: TSESLint.SourceCode, options?: {
considerGetters?: boolean | undefined;
considerImplicitTypeConversion?: boolean | undefined;
} | undefined) => boolean;
/**
* Check whether a given node is parenthesized or not.
* This function detects it correctly even if it's parenthesized by specific syntax.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#isparenthesized}
* @returns `true` if the node is parenthesized.
* If `times` was given, it returns `true` only if the node is parenthesized the `times` times.
* For example, `isParenthesized(2, node, sourceCode)` returns true for `((foo))`, but not for `(foo)`.
*/
declare const isParenthesized: (node: TSESTree.Node, sourceCode: TSESLint.SourceCode) => boolean;
export { getFunctionHeadLocation, getFunctionNameWithKind, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isParenthesized, };
//# sourceMappingURL=astUtilities.d.ts.map

View file

@ -0,0 +1,6 @@
export * from './astUtilities';
export * from './PatternMatcher';
export * from './predicates';
export * from './ReferenceTracker';
export * from './scopeAnalysis';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,45 @@
import { TSESTree } from '../../ts-estree';
declare const isArrowToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '=>';
};
declare const isNotArrowToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isClosingBraceToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '}';
};
declare const isNotClosingBraceToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isClosingBracketToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ']';
};
declare const isNotClosingBracketToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isClosingParenToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ')';
};
declare const isNotClosingParenToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isColonToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ':';
};
declare const isNotColonToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isCommaToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ',';
};
declare const isNotCommaToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isCommentToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.Comment;
declare const isNotCommentToken: <T extends TSESTree.Token>(token: T) => token is Exclude<T, TSESTree.Comment>;
declare const isOpeningBraceToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '{';
};
declare const isNotOpeningBraceToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isOpeningBracketToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '[';
};
declare const isNotOpeningBracketToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isOpeningParenToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '(';
};
declare const isNotOpeningParenToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isSemicolonToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ';';
};
declare const isNotSemicolonToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
export { isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isSemicolonToken, };
//# sourceMappingURL=predicates.d.ts.map

View file

@ -0,0 +1,18 @@
import { TSESTree } from '../../ts-estree';
import * as TSESLint from '../../ts-eslint';
/**
* Get the variable of a given name.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#findvariable}
*/
declare const findVariable: (initialScope: TSESLint.Scope.Scope, name: string) => TSESLint.Scope.Variable | null;
/**
* Get the innermost scope which contains a given node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#getinnermostscope}
* @returns The innermost scope which contains the given node.
* If such scope doesn't exist then it returns the 1st argument `initialScope`.
*/
declare const getInnermostScope: (initialScope: TSESLint.Scope.Scope, node: TSESTree.Node) => TSESLint.Scope.Scope;
export { findVariable, getInnermostScope };
//# sourceMappingURL=scopeAnalysis.d.ts.map

View file

@ -0,0 +1,4 @@
export * from './misc';
export * from './predicates';
export * from './eslint-utils';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,8 @@
import { TSESTree } from '../ts-estree';
declare const LINEBREAK_MATCHER: RegExp;
/**
* Determines whether two adjacent tokens are on the same line
*/
declare function isTokenOnSameLine(left: TSESTree.Token | TSESTree.Comment, right: TSESTree.Token | TSESTree.Comment): boolean;
export { isTokenOnSameLine, LINEBREAK_MATCHER };
//# sourceMappingURL=misc.d.ts.map

View file

@ -0,0 +1,58 @@
import { TSESTree } from '../ts-estree';
declare function isOptionalChainPunctuator(token: TSESTree.Token | TSESTree.Comment): token is TSESTree.PunctuatorToken & {
value: '?.';
};
declare function isNotOptionalChainPunctuator(token: TSESTree.Token | TSESTree.Comment): boolean;
declare function isNonNullAssertionPunctuator(token: TSESTree.Token | TSESTree.Comment): token is TSESTree.PunctuatorToken & {
value: '!';
};
declare function isNotNonNullAssertionPunctuator(token: TSESTree.Token | TSESTree.Comment): boolean;
/**
* Returns true if and only if the node represents: foo?.() or foo.bar?.()
*/
declare function isOptionalOptionalCallExpression(node: TSESTree.Node): node is TSESTree.OptionalCallExpression & {
optional: true;
};
/**
* Returns true if and only if the node represents logical OR
*/
declare function isLogicalOrOperator(node: TSESTree.Node): node is TSESTree.LogicalExpression & {
operator: '||';
};
/**
* Checks if a node is a type assertion:
* ```
* x as foo
* <foo>x
* ```
*/
declare function isTypeAssertion(node: TSESTree.Node | undefined | null): node is TSESTree.TSAsExpression | TSESTree.TSTypeAssertion;
declare function isVariableDeclarator(node: TSESTree.Node | undefined): node is TSESTree.VariableDeclarator;
declare function isFunction(node: TSESTree.Node | undefined): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
declare function isFunctionType(node: TSESTree.Node | undefined): node is TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature;
declare function isFunctionOrFunctionType(node: TSESTree.Node | undefined): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature;
declare function isTSFunctionType(node: TSESTree.Node | undefined): node is TSESTree.TSFunctionType;
declare function isTSConstructorType(node: TSESTree.Node | undefined): node is TSESTree.TSConstructorType;
declare function isClassOrTypeElement(node: TSESTree.Node | undefined): node is TSESTree.ClassElement | TSESTree.TypeElement;
/**
* Checks if a node is a constructor method.
*/
declare function isConstructor(node: TSESTree.Node | undefined): node is TSESTree.MethodDefinition;
/**
* Checks if a node is a setter method.
*/
declare function isSetter(node: TSESTree.Node | undefined): node is TSESTree.MethodDefinition | TSESTree.Property;
declare function isIdentifier(node: TSESTree.Node | undefined): node is TSESTree.Identifier;
/**
* Checks if a node represents an `await …` expression.
*/
declare function isAwaitExpression(node: TSESTree.Node | undefined | null): node is TSESTree.AwaitExpression;
/**
* Checks if a possible token is the `await` keyword.
*/
declare function isAwaitKeyword(node: TSESTree.Token | TSESTree.Comment | undefined | null): node is TSESTree.KeywordToken & {
value: 'await';
};
declare function isMemberOrOptionalMemberExpression(node: TSESTree.Node): node is TSESTree.MemberExpression | TSESTree.OptionalMemberExpression;
export { isAwaitExpression, isAwaitKeyword, isConstructor, isClassOrTypeElement, isFunction, isFunctionOrFunctionType, isFunctionType, isIdentifier, isLogicalOrOperator, isMemberOrOptionalMemberExpression, isNonNullAssertionPunctuator, isNotNonNullAssertionPunctuator, isNotOptionalChainPunctuator, isOptionalChainPunctuator, isOptionalOptionalCallExpression, isSetter, isTSConstructorType, isTSFunctionType, isTypeAssertion, isVariableDeclarator, };
//# sourceMappingURL=predicates.d.ts.map

View file

@ -0,0 +1,12 @@
import { RuleModule } from '../ts-eslint';
declare type InferOptionsTypeFromRuleNever<T> = T extends RuleModule<never, infer TOptions> ? TOptions : unknown;
/**
* Uses type inference to fetch the TOptions type from the given RuleModule
*/
declare type InferOptionsTypeFromRule<T> = T extends RuleModule<string, infer TOptions> ? TOptions : InferOptionsTypeFromRuleNever<T>;
/**
* Uses type inference to fetch the TMessageIds type from the given RuleModule
*/
declare type InferMessageIdsTypeFromRule<T> = T extends RuleModule<infer TMessageIds, unknown[]> ? TMessageIds : unknown;
export { InferOptionsTypeFromRule, InferMessageIdsTypeFromRule };
//# sourceMappingURL=InferTypesFromRule.d.ts.map

View file

@ -0,0 +1,13 @@
import { RuleMetaData, RuleMetaDataDocs, RuleListener, RuleContext, RuleModule } from '../ts-eslint/Rule';
declare type CreateRuleMetaDocs = Pick<RuleMetaDataDocs, Exclude<keyof RuleMetaDataDocs, 'url'>>;
declare type CreateRuleMeta<TMessageIds extends string> = {
docs: CreateRuleMetaDocs;
} & Pick<RuleMetaData<TMessageIds>, Exclude<keyof RuleMetaData<TMessageIds>, 'docs'>>;
declare function RuleCreator(urlCreator: (ruleName: string) => string): <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener = RuleListener>({ name, meta, defaultOptions, create, }: Readonly<{
name: string;
meta: CreateRuleMeta<TMessageIds>;
defaultOptions: Readonly<TOptions>;
create: (context: Readonly<RuleContext<TMessageIds, TOptions>>, optionsWithDefault: Readonly<TOptions>) => TRuleListener;
}>) => RuleModule<TMessageIds, TOptions, TRuleListener>;
export { RuleCreator };
//# sourceMappingURL=RuleCreator.d.ts.map

View file

@ -0,0 +1,18 @@
import * as TSESLint from '../ts-eslint';
declare const parser = "@typescript-eslint/parser";
declare type RuleTesterConfig = Pick<TSESLint.RuleTesterConfig, Exclude<keyof TSESLint.RuleTesterConfig, 'parser'>> & {
parser: typeof parser;
};
declare class RuleTester extends TSESLint.RuleTester {
private "RuleTester.#private";
constructor(options: RuleTesterConfig);
private getFilename;
run<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(name: string, rule: TSESLint.RuleModule<TMessageIds, TOptions>, testsReadonly: TSESLint.RunTests<TMessageIds, TOptions>): void;
}
/**
* Simple no-op tag to mark code samples as "should not format with prettier"
* for the internal/plugin-test-formatting lint rule
*/
declare function noFormat(strings: TemplateStringsArray, ...keys: string[]): string;
export { noFormat, RuleTester };
//# sourceMappingURL=RuleTester.d.ts.map

View file

@ -0,0 +1,10 @@
/**
* Pure function - doesn't mutate either parameter!
* Uses the default options and overrides with the options provided by the user
* @param defaultOptions the defaults
* @param userOptions the user opts
* @returns the options with defaults
*/
declare function applyDefault<TUser extends readonly unknown[], TDefault extends TUser>(defaultOptions: TDefault, userOptions: TUser | null): TDefault;
export { applyDefault };
//# sourceMappingURL=applyDefault.d.ts.map

View file

@ -0,0 +1,24 @@
import { ValidTestCase, InvalidTestCase } from '../ts-eslint';
/**
* Converts a batch of single line tests into a number of separate test cases.
* This makes it easier to write tests which use the same options.
*
* Why wouldn't you just leave them as one test?
* Because it makes the test error messages harder to decipher.
* This way each line will fail separately, instead of them all failing together.
*/
declare function batchedSingleLineTests<TOptions extends Readonly<unknown[]>>(test: ValidTestCase<TOptions>): ValidTestCase<TOptions>[];
/**
* Converts a batch of single line tests into a number of separate test cases.
* This makes it easier to write tests which use the same options.
*
* Why wouldn't you just leave them as one test?
* Because it makes the test error messages harder to decipher.
* This way each line will fail separately, instead of them all failing together.
*
* Make sure you have your line numbers correct for error reporting, as it will match
* the line numbers up with the split tests!
*/
declare function batchedSingleLineTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(test: InvalidTestCase<TMessageIds, TOptions>): InvalidTestCase<TMessageIds, TOptions>[];
export { batchedSingleLineTests };
//# sourceMappingURL=batchedSingleLineTests.d.ts.map

View file

@ -0,0 +1,17 @@
declare type ObjectLike<T = unknown> = Record<string, T>;
/**
* Check if the variable contains an object strictly rejecting arrays
* @param obj an object
* @returns `true` if obj is an object
*/
declare function isObjectNotArray<T extends ObjectLike>(obj: unknown | unknown[]): obj is T;
/**
* Pure function - doesn't mutate either parameter!
* Merges two objects together deeply, overwriting the properties in first with the properties in second
* @param first The first object
* @param second The second object
* @returns a new object
*/
export declare function deepMerge(first?: ObjectLike, second?: ObjectLike): Record<string, unknown>;
export { isObjectNotArray };
//# sourceMappingURL=deepMerge.d.ts.map

View file

@ -0,0 +1,8 @@
import * as TSESLint from '../ts-eslint';
import { ParserServices } from '../ts-estree';
/**
* Try to retrieve typescript parser service from context
*/
declare function getParserServices<TMessageIds extends string, TOptions extends readonly unknown[]>(context: Readonly<TSESLint.RuleContext<TMessageIds, TOptions>>, allowWithoutFullTypeInformation?: boolean): ParserServices;
export { getParserServices };
//# sourceMappingURL=getParserServices.d.ts.map

View file

@ -0,0 +1,8 @@
export * from './applyDefault';
export * from './batchedSingleLineTests';
export * from './getParserServices';
export * from './InferTypesFromRule';
export * from './RuleCreator';
export * from './RuleTester';
export * from './deepMerge';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,8 @@
import * as ASTUtils from './ast-utils';
import * as ESLintUtils from './eslint-utils';
import * as JSONSchema from './json-schema';
import * as TSESLint from './ts-eslint';
import * as TSESLintScope from './ts-eslint-scope';
export { ASTUtils, ESLintUtils, JSONSchema, TSESLint, TSESLintScope };
export * from './ts-estree';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,2 @@
export { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName, JSONSchema4Version, JSONSchema6, JSONSchema6Definition, JSONSchema6Type, JSONSchema6TypeName, JSONSchema6Version, JSONSchema7, JSONSchema7Array, JSONSchema7Definition, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version, ValidationError, ValidationResult, } from 'json-schema';
//# sourceMappingURL=json-schema.d.ts.map

View file

@ -0,0 +1,19 @@
import { TSESTree } from '../ts-estree';
interface Definition {
type: string;
name: TSESTree.BindingName;
node: TSESTree.Node;
parent?: TSESTree.Node | null;
index?: number | null;
kind?: string | null;
rest?: boolean;
}
interface DefinitionConstructor {
new (type: string, name: TSESTree.BindingName | TSESTree.PropertyName, node: TSESTree.Node, parent?: TSESTree.Node | null, index?: number | null, kind?: string | null): Definition;
}
declare const Definition: DefinitionConstructor;
interface ParameterDefinition extends Definition {
}
declare const ParameterDefinition: DefinitionConstructor & (new (name: TSESTree.Node, node: TSESTree.Node, index?: number | null | undefined, rest?: boolean | undefined) => ParameterDefinition);
export { Definition, ParameterDefinition };
//# sourceMappingURL=Definition.d.ts.map

View file

@ -0,0 +1,15 @@
import { TSESTree } from '../ts-estree';
declare type PatternVisitorCallback = (pattern: TSESTree.Identifier, info: {
rest: boolean;
topLevel: boolean;
assignments: TSESTree.AssignmentPattern[];
}) => void;
interface PatternVisitorOptions {
processRightHandNodes?: boolean;
}
interface Visitor {
visitChildren<T extends TSESTree.BaseNode | undefined | null>(node?: T): void;
visit<T extends TSESTree.BaseNode | undefined | null>(node?: T): void;
}
export { PatternVisitorCallback, PatternVisitorOptions, Visitor };
//# sourceMappingURL=Options.d.ts.map

View file

@ -0,0 +1,25 @@
import { TSESTree } from '../ts-estree';
import { ScopeManager } from './ScopeManager';
import { PatternVisitorCallback, PatternVisitorOptions, Visitor } from './Options';
interface PatternVisitor extends Visitor {
options: PatternVisitorOptions;
scopeManager: ScopeManager;
parent?: TSESTree.Node;
rightHandNodes: TSESTree.Node[];
Identifier(pattern: TSESTree.Node): void;
Property(property: TSESTree.Node): void;
ArrayPattern(pattern: TSESTree.Node): void;
AssignmentPattern(pattern: TSESTree.Node): void;
RestElement(pattern: TSESTree.Node): void;
MemberExpression(node: TSESTree.Node): void;
SpreadElement(node: TSESTree.Node): void;
ArrayExpression(node: TSESTree.Node): void;
AssignmentExpression(node: TSESTree.Node): void;
CallExpression(node: TSESTree.Node): void;
}
declare const PatternVisitor: {
new (options: PatternVisitorOptions, rootPattern: TSESTree.BaseNode, callback: PatternVisitorCallback): PatternVisitor;
isPattern(node: TSESTree.Node): boolean;
};
export { PatternVisitor };
//# sourceMappingURL=PatternVisitor.d.ts.map

View file

@ -0,0 +1,55 @@
import { TSESTree } from '../ts-estree';
import { PatternVisitorCallback, PatternVisitorOptions, Visitor } from './Options';
import { Scope } from './Scope';
import { ScopeManager } from './ScopeManager';
interface Referencer<SM extends ScopeManager> extends Visitor {
isInnerMethodDefinition: boolean;
options: any;
scopeManager: SM;
parent?: TSESTree.Node;
currentScope(): Scope;
close(node: TSESTree.Node): void;
pushInnerMethodDefinition(isInnerMethodDefinition: boolean): boolean;
popInnerMethodDefinition(isInnerMethodDefinition: boolean): void;
referencingDefaultValue(pattern: any, assignments: any, maybeImplicitGlobal: any, init: boolean): void;
visitPattern(node: TSESTree.Node, options: PatternVisitorOptions, callback: PatternVisitorCallback): void;
visitFunction(node: TSESTree.Node): void;
visitClass(node: TSESTree.Node): void;
visitProperty(node: TSESTree.Node): void;
visitForIn(node: TSESTree.Node): void;
visitVariableDeclaration(variableTargetScope: any, type: any, node: TSESTree.Node, index: any): void;
AssignmentExpression(node: TSESTree.Node): void;
CatchClause(node: TSESTree.Node): void;
Program(node: TSESTree.Program): void;
Identifier(node: TSESTree.Identifier): void;
UpdateExpression(node: TSESTree.Node): void;
MemberExpression(node: TSESTree.Node): void;
Property(node: TSESTree.Node): void;
MethodDefinition(node: TSESTree.Node): void;
BreakStatement(): void;
ContinueStatement(): void;
LabeledStatement(node: TSESTree.Node): void;
ForStatement(node: TSESTree.Node): void;
ClassExpression(node: TSESTree.Node): void;
ClassDeclaration(node: TSESTree.Node): void;
CallExpression(node: TSESTree.Node): void;
BlockStatement(node: TSESTree.Node): void;
ThisExpression(): void;
WithStatement(node: TSESTree.Node): void;
VariableDeclaration(node: TSESTree.Node): void;
SwitchStatement(node: TSESTree.Node): void;
FunctionDeclaration(node: TSESTree.Node): void;
FunctionExpression(node: TSESTree.Node): void;
ForOfStatement(node: TSESTree.Node): void;
ForInStatement(node: TSESTree.Node): void;
ArrowFunctionExpression(node: TSESTree.Node): void;
ImportDeclaration(node: TSESTree.Node): void;
visitExportDeclaration(node: TSESTree.Node): void;
ExportDeclaration(node: TSESTree.Node): void;
ExportNamedDeclaration(node: TSESTree.Node): void;
ExportSpecifier(node: TSESTree.Node): void;
MetaProperty(): void;
}
declare const Referencer: new <SM extends ScopeManager>(options: any, scopeManager: SM) => Referencer<SM>;
export { Referencer };
//# sourceMappingURL=Referencer.d.ts.map

View file

@ -0,0 +1,103 @@
import { TSESTree } from '../ts-estree';
import { Definition } from './Definition';
import { Reference, ReferenceFlag } from './Reference';
import { ScopeManager } from './ScopeManager';
import { Variable } from './Variable';
declare type ScopeType = 'block' | 'catch' | 'class' | 'for' | 'function' | 'function-expression-name' | 'global' | 'module' | 'switch' | 'with' | 'TDZ' | 'enum' | 'empty-function';
interface Scope {
type: ScopeType;
isStrict: boolean;
upper: Scope | null;
childScopes: Scope[];
variableScope: Scope;
block: TSESTree.Node;
variables: Variable[];
set: Map<string, Variable>;
references: Reference[];
through: Reference[];
thisFound?: boolean;
taints: Map<string, boolean>;
functionExpressionScope: boolean;
__left: Reference[];
__shouldStaticallyClose(scopeManager: ScopeManager): boolean;
__shouldStaticallyCloseForGlobal(ref: any): boolean;
__staticCloseRef(ref: any): void;
__dynamicCloseRef(ref: any): void;
__globalCloseRef(ref: any): void;
__close(scopeManager: ScopeManager): Scope;
__isValidResolution(ref: any, variable: any): variable is Variable;
__resolve(ref: Reference): boolean;
__delegateToUpperScope(ref: any): void;
__addDeclaredVariablesOfNode(variable: any, node: TSESTree.Node): void;
__defineGeneric(name: string, set: Map<string, Variable>, variables: Variable[], node: TSESTree.Identifier, def: Definition): void;
__define(node: TSESTree.Node, def: Definition): void;
__referencing(node: TSESTree.Node, assign?: ReferenceFlag, writeExpr?: TSESTree.Node, maybeImplicitGlobal?: any, partial?: any, init?: any): void;
__detectEval(): void;
__detectThis(): void;
__isClosed(): boolean;
/**
* returns resolved {Reference}
* @method Scope#resolve
* @param {Espree.Identifier} ident - identifier to be resolved.
* @returns {Reference} reference
*/
resolve(ident: TSESTree.Node): Reference;
/**
* returns this scope is static
* @method Scope#isStatic
* @returns {boolean} static
*/
isStatic(): boolean;
/**
* returns this scope has materialized arguments
* @method Scope#isArgumentsMaterialized
* @returns {boolean} arguments materialized
*/
isArgumentsMaterialized(): boolean;
/**
* returns this scope has materialized `this` reference
* @method Scope#isThisMaterialized
* @returns {boolean} this materialized
*/
isThisMaterialized(): boolean;
isUsedName(name: any): boolean;
}
interface ScopeConstructor {
new (scopeManager: ScopeManager, type: ScopeType, upperScope: Scope | null, block: TSESTree.Node | null, isMethodDefinition: boolean): Scope;
}
declare const Scope: ScopeConstructor;
interface ScopeChildConstructorWithUpperScope<T> {
new (scopeManager: ScopeManager, upperScope: Scope, block: TSESTree.Node | null): T;
}
interface GlobalScope extends Scope {
}
declare const GlobalScope: ScopeConstructor & (new (scopeManager: ScopeManager, block: TSESTree.Node | null) => GlobalScope);
interface ModuleScope extends Scope {
}
declare const ModuleScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<ModuleScope>;
interface FunctionExpressionNameScope extends Scope {
}
declare const FunctionExpressionNameScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<FunctionExpressionNameScope>;
interface CatchScope extends Scope {
}
declare const CatchScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<CatchScope>;
interface WithScope extends Scope {
}
declare const WithScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<WithScope>;
interface BlockScope extends Scope {
}
declare const BlockScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<BlockScope>;
interface SwitchScope extends Scope {
}
declare const SwitchScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<SwitchScope>;
interface FunctionScope extends Scope {
}
declare const FunctionScope: ScopeConstructor & (new (scopeManager: ScopeManager, upperScope: Scope, block: TSESTree.Node | null, isMethodDefinition: boolean) => FunctionScope);
interface ForScope extends Scope {
}
declare const ForScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<ForScope>;
interface ClassScope extends Scope {
}
declare const ClassScope: ScopeConstructor & ScopeChildConstructorWithUpperScope<ClassScope>;
export { ScopeType, Scope, GlobalScope, ModuleScope, FunctionExpressionNameScope, CatchScope, WithScope, BlockScope, SwitchScope, FunctionScope, ForScope, ClassScope, };
//# sourceMappingURL=Scope.d.ts.map

View file

@ -0,0 +1,50 @@
import { TSESTree } from '../ts-estree';
import { EcmaVersion } from '../ts-eslint';
import { Scope } from './Scope';
import { Variable } from './Variable';
interface ScopeManagerOptions {
directive?: boolean;
optimistic?: boolean;
ignoreEval?: boolean;
nodejsScope?: boolean;
sourceType?: 'module' | 'script';
impliedStrict?: boolean;
ecmaVersion?: EcmaVersion;
}
interface ScopeManager {
__options: ScopeManagerOptions;
__currentScope: Scope;
__nodeToScope: WeakMap<TSESTree.Node, Scope[]>;
__declaredVariables: WeakMap<TSESTree.Node, Variable[]>;
scopes: Scope[];
globalScope: Scope;
__useDirective(): boolean;
__isOptimistic(): boolean;
__ignoreEval(): boolean;
__isNodejsScope(): boolean;
isModule(): boolean;
isImpliedStrict(): boolean;
isStrictModeSupported(): boolean;
__get(node: TSESTree.Node): Scope | undefined;
getDeclaredVariables(node: TSESTree.Node): Variable[];
acquire(node: TSESTree.Node, inner?: boolean): Scope | null;
acquireAll(node: TSESTree.Node): Scope | null;
release(node: TSESTree.Node, inner?: boolean): Scope | null;
attach(): void;
detach(): void;
__nestScope<T extends Scope>(scope: T): T;
__nestGlobalScope(node: TSESTree.Node): Scope;
__nestBlockScope(node: TSESTree.Node): Scope;
__nestFunctionScope(node: TSESTree.Node, isMethodDefinition: boolean): Scope;
__nestForScope(node: TSESTree.Node): Scope;
__nestCatchScope(node: TSESTree.Node): Scope;
__nestWithScope(node: TSESTree.Node): Scope;
__nestClassScope(node: TSESTree.Node): Scope;
__nestSwitchScope(node: TSESTree.Node): Scope;
__nestModuleScope(node: TSESTree.Node): Scope;
__nestFunctionExpressionNameScope(node: TSESTree.Node): Scope;
__isES6(): boolean;
}
declare const ScopeManager: new (options: ScopeManagerOptions) => ScopeManager;
export { ScopeManager, ScopeManagerOptions };
//# sourceMappingURL=ScopeManager.d.ts.map

View file

@ -0,0 +1,17 @@
import { TSESTree } from '../ts-estree';
import { Reference } from './Reference';
import { Definition } from './Definition';
import { Scope } from './Scope';
interface Variable {
name: string;
identifiers: TSESTree.Identifier[];
references: Reference[];
defs: Definition[];
eslintUsed?: boolean;
stack?: unknown;
tainted?: boolean;
scope?: Scope;
}
declare const Variable: new () => Variable;
export { Variable };
//# sourceMappingURL=Variable.d.ts.map

View file

@ -0,0 +1,16 @@
import { EcmaVersion } from '../ts-eslint';
import { TSESTree } from '../ts-estree';
import { ScopeManager } from './ScopeManager';
interface AnalysisOptions {
optimistic?: boolean;
directive?: boolean;
ignoreEval?: boolean;
nodejsScope?: boolean;
impliedStrict?: boolean;
fallback?: string | ((node: TSESTree.Node) => string[]);
sourceType?: 'script' | 'module';
ecmaVersion?: EcmaVersion;
}
declare const analyze: (ast: TSESTree.Node, options?: AnalysisOptions | undefined) => ScopeManager;
export { analyze, AnalysisOptions };
//# sourceMappingURL=analyze.d.ts.map

View file

@ -0,0 +1,11 @@
export * from './analyze';
export * from './Definition';
export * from './Options';
export * from './PatternVisitor';
export * from './Reference';
export * from './Referencer';
export * from './Scope';
export * from './ScopeManager';
export * from './Variable';
export declare const version: string;
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,9 @@
import { TSESTree, AST_TOKEN_TYPES } from '../ts-estree';
declare namespace AST {
type TokenType = AST_TOKEN_TYPES;
type Token = TSESTree.Token;
type SourceLocation = TSESTree.SourceLocation;
type Range = TSESTree.Range;
}
export { AST };
//# sourceMappingURL=AST.d.ts.map

View file

@ -0,0 +1,143 @@
import { Linter } from './Linter';
import { RuleListener, RuleMetaData, RuleModule } from './Rule';
declare class CLIEngineBase {
/**
* Creates a new instance of the core CLI engine.
* @param providedOptions The options for this instance.
*/
constructor(options: CLIEngine.Options);
/**
* Add a plugin by passing its configuration
* @param name Name of the plugin.
* @param pluginObject Plugin configuration object.
*/
addPlugin(name: string, pluginObject: Linter.Plugin): void;
/**
* Executes the current configuration on an array of file and directory names.
* @param patterns An array of file and directory names.
* @returns The results for all files that were linted.
*/
executeOnFiles(patterns: string[]): CLIEngine.LintReport;
/**
* Executes the current configuration on text.
* @param text A string of JavaScript code to lint.
* @param filename An optional string representing the texts filename.
* @param warnIgnored Always warn when a file is ignored
* @returns The results for the linting.
*/
executeOnText(text: string, filename?: string, warnIgnored?: boolean): CLIEngine.LintReport;
/**
* Returns a configuration object for the given file based on the CLI options.
* This is the same logic used by the ESLint CLI executable to determine configuration for each file it processes.
* @param filePath The path of the file to retrieve a config object for.
* @returns A configuration object for the file.
*/
getConfigForFile(filePath: string): Linter.Config;
/**
* Returns the formatter representing the given format.
* @param format The name of the format to load or the path to a custom formatter.
* @returns The formatter function.
*/
getFormatter(format?: string): CLIEngine.Formatter;
/**
* Checks if a given path is ignored by ESLint.
* @param filePath The path of the file to check.
* @returns Whether or not the given path is ignored.
*/
isPathIgnored(filePath: string): boolean;
/**
* Resolves the patterns passed into `executeOnFiles()` into glob-based patterns for easier handling.
* @param patterns The file patterns passed on the command line.
* @returns The equivalent glob patterns.
*/
resolveFileGlobPatterns(patterns: string[]): string[];
getRules<TMessageIds extends string = string, TOptions extends readonly unknown[] = unknown[], TRuleListener extends RuleListener = RuleListener>(): Map<string, RuleModule<TMessageIds, TOptions, TRuleListener>>;
/**
* Returns results that only contains errors.
* @param results The results to filter.
* @returns The filtered results.
*/
static getErrorResults(results: CLIEngine.LintResult[]): CLIEngine.LintResult[];
/**
* Returns the formatter representing the given format or null if the `format` is not a string.
* @param format The name of the format to load or the path to a custom formatter.
* @returns The formatter function.
*/
static getFormatter(format?: string): CLIEngine.Formatter;
/**
* Outputs fixes from the given results to files.
* @param report The report object created by CLIEngine.
*/
static outputFixes(report: CLIEngine.LintReport): void;
static version: string;
}
declare namespace CLIEngine {
interface Options {
allowInlineConfig?: boolean;
baseConfig?: false | {
[name: string]: unknown;
};
cache?: boolean;
cacheFile?: string;
cacheLocation?: string;
configFile?: string;
cwd?: string;
envs?: string[];
errorOnUnmatchedPattern?: boolean;
extensions?: string[];
fix?: boolean;
globals?: string[];
ignore?: boolean;
ignorePath?: string;
ignorePattern?: string | string[];
useEslintrc?: boolean;
parser?: string;
parserOptions?: Linter.ParserOptions;
plugins?: string[];
resolvePluginsRelativeTo?: string;
rules?: {
[name: string]: Linter.RuleLevel | Linter.RuleLevelAndOptions;
};
rulePaths?: string[];
reportUnusedDisableDirectives?: boolean;
}
interface LintResult {
filePath: string;
messages: Linter.LintMessage[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
fixableWarningCount: number;
output?: string;
source?: string;
}
interface LintReport {
results: LintResult[];
errorCount: number;
warningCount: number;
fixableErrorCount: number;
fixableWarningCount: number;
usedDeprecatedRules: DeprecatedRuleUse[];
}
interface DeprecatedRuleUse {
ruleId: string;
replacedBy: string[];
}
interface LintResultData<TMessageIds extends string> {
rulesMeta: {
[ruleId: string]: RuleMetaData<TMessageIds>;
};
}
type Formatter = <TMessageIds extends string>(results: LintResult[], data?: LintResultData<TMessageIds>) => string;
}
declare const CLIEngine_base: typeof CLIEngineBase;
/**
* The underlying utility that runs the ESLint command line interface. This object will read the filesystem for
* configuration and file information but will not output any results. Instead, it allows you direct access to the
* important information so you can deal with the output yourself.
* @deprecated use the ESLint class instead
*/
declare class CLIEngine extends CLIEngine_base {
}
export { CLIEngine };
//# sourceMappingURL=CLIEngine.d.ts.map

View file

@ -0,0 +1,341 @@
import { Linter } from './Linter';
declare class ESLintBase {
/**
* Creates a new instance of the main ESLint API.
* @param options The options for this instance.
*/
constructor(options?: ESLint.ESLintOptions);
/**
* This method calculates the configuration for a given file, which can be useful for debugging purposes.
* - It resolves and merges extends and overrides settings into the top level configuration.
* - It resolves the parser setting to absolute paths.
* - It normalizes the plugins setting to align short names. (e.g., eslint-plugin-foo foo)
* - It adds the processor setting if a legacy file extension processor is matched.
* - It doesn't interpret the env setting to the globals and parserOptions settings, so the result object contains
* the env setting as is.
* @param filePath The path to the file whose configuration you would like to calculate. Directory paths are forbidden
* because ESLint cannot handle the overrides setting.
* @returns The promise that will be fulfilled with a configuration object.
*/
calculateConfigForFile(filePath: string): Promise<Linter.Config>;
/**
* This method checks if a given file is ignored by your configuration.
* @param filePath The path to the file you want to check.
* @returns The promise that will be fulfilled with whether the file is ignored or not. If the file is ignored, then
* it will return true.
*/
isPathIgnored(filePath: string): Promise<boolean>;
/**
* This method lints the files that match the glob patterns and then returns the results.
* @param patterns The lint target files. This can contain any of file paths, directory paths, and glob patterns.
* @returns The promise that will be fulfilled with an array of LintResult objects.
*/
lintFiles(patterns: string | string[]): Promise<ESLint.LintResult[]>;
/**
* This method lints the given source code text and then returns the results.
*
* By default, this method uses the configuration that applies to files in the current working directory (the cwd
* constructor option). If you want to use a different configuration, pass options.filePath, and ESLint will load the
* same configuration that eslint.lintFiles() would use for a file at options.filePath.
*
* If the options.filePath value is configured to be ignored, this method returns an empty array. If the
* options.warnIgnored option is set along with the options.filePath option, this method returns a LintResult object.
* In that case, the result may contain a warning that indicates the file was ignored.
* @param code The source code text to check.
* @param options The options.
* @returns The promise that will be fulfilled with an array of LintResult objects. This is an array (despite there
* being only one lint result) in order to keep the interfaces between this and the eslint.lintFiles()
* method similar.
*/
lintText(code: string, options?: ESLint.LintTextOptions): Promise<ESLint.LintResult[]>;
/**
* This method loads a formatter. Formatters convert lint results to a human- or machine-readable string.
* @param name TThe path to the file you want to check.
* The following values are allowed:
* - undefined. In this case, loads the "stylish" built-in formatter.
* - A name of built-in formatters.
* - A name of third-party formatters. For examples:
* -- `foo` will load eslint-formatter-foo.
* -- `@foo` will load `@foo/eslint-formatter`.
* -- `@foo/bar` will load `@foo/eslint-formatter-bar`.
* - A path to the file that defines a formatter. The path must contain one or more path separators (/) in order to distinguish if it's a path or not. For example, start with ./.
* @returns The promise that will be fulfilled with a Formatter object.
*/
loadFormatter(name?: string): Promise<ESLint.Formatter>;
/**
* This method copies the given results and removes warnings. The returned value contains only errors.
* @param results The LintResult objects to filter.
* @returns The filtered LintResult objects.
*/
static getErrorResults(results: ESLint.LintResult): ESLint.LintResult;
/**
* This method writes code modified by ESLint's autofix feature into its respective file. If any of the modified
* files don't exist, this method does nothing.
* @param results The LintResult objects to write.
* @returns The promise that will be fulfilled after all files are written.
*/
static outputFixes(results: ESLint.LintResult): Promise<void>;
/**
* The version text.
*/
static readonly version: string;
}
declare namespace ESLint {
interface ESLintOptions {
/**
* If false is present, ESLint suppresses directive comments in source code.
* If this option is false, it overrides the noInlineConfig setting in your configurations.
*/
allowInlineConfig?: boolean;
/**
* Configuration object, extended by all configurations used with this instance.
* You can use this option to define the default settings that will be used if your configuration files don't
* configure it.
*/
baseConfig?: Linter.Config | null;
/**
* If true is present, the eslint.lintFiles() method caches lint results and uses it if each target file is not
* changed. Please mind that ESLint doesn't clear the cache when you upgrade ESLint plugins. In that case, you have
* to remove the cache file manually. The eslint.lintText() method doesn't use caches even if you pass the
* options.filePath to the method.
*/
cache?: boolean;
/**
* The eslint.lintFiles() method writes caches into this file.
*/
cacheLocation?: string;
/**
* The working directory. This must be an absolute path.
*/
cwd?: string;
/**
* Unless set to false, the eslint.lintFiles() method will throw an error when no target files are found.
*/
errorOnUnmatchedPattern?: boolean;
/**
* If you pass directory paths to the eslint.lintFiles() method, ESLint checks the files in those directories that
* have the given extensions. For example, when passing the src/ directory and extensions is [".js", ".ts"], ESLint
* will lint *.js and *.ts files in src/. If extensions is null, ESLint checks *.js files and files that match
* overrides[].files patterns in your configuration.
* Note: This option only applies when you pass directory paths to the eslint.lintFiles() method.
* If you pass glob patterns, ESLint will lint all files matching the glob pattern regardless of extension.
*/
extensions?: string[] | null;
/**
* If true is present, the eslint.lintFiles() and eslint.lintText() methods work in autofix mode.
* If a predicate function is present, the methods pass each lint message to the function, then use only the
* lint messages for which the function returned true.
*/
fix?: boolean | ((message: LintMessage) => boolean);
/**
* The types of the rules that the eslint.lintFiles() and eslint.lintText() methods use for autofix.
*/
fixTypes?: string[];
/**
* If false is present, the eslint.lintFiles() method doesn't interpret glob patterns.
*/
globInputPaths?: boolean;
/**
* If false is present, the eslint.lintFiles() method doesn't respect `.eslintignore` files or ignorePatterns in
* your configuration.
*/
ignore?: boolean;
/**
* The path to a file ESLint uses instead of `$CWD/.eslintignore`.
* If a path is present and the file doesn't exist, this constructor will throw an error.
*/
ignorePath?: string;
/**
* Configuration object, overrides all configurations used with this instance.
* You can use this option to define the settings that will be used even if your configuration files configure it.
*/
overrideConfig?: Linter.ConfigOverride | null;
/**
* The path to a configuration file, overrides all configurations used with this instance.
* The options.overrideConfig option is applied after this option is applied.
*/
overrideConfigFile?: string | null;
/**
* The plugin implementations that ESLint uses for the plugins setting of your configuration.
* This is a map-like object. Those keys are plugin IDs and each value is implementation.
*/
plugins?: Record<string, Linter.Plugin> | null;
/**
* The severity to report unused eslint-disable directives.
* If this option is a severity, it overrides the reportUnusedDisableDirectives setting in your configurations.
*/
reportUnusedDisableDirectives?: Linter.SeverityString | null;
/**
* The path to a directory where plugins should be resolved from.
* If null is present, ESLint loads plugins from the location of the configuration file that contains the plugin
* setting.
* If a path is present, ESLint loads all plugins from there.
*/
resolvePluginsRelativeTo?: string | null;
/**
* An array of paths to directories to load custom rules from.
*/
rulePaths?: string[];
/**
* If false is present, ESLint doesn't load configuration files (.eslintrc.* files).
* Only the configuration of the constructor options is valid.
*/
useEslintrc?: boolean;
}
interface DeprecatedRuleInfo {
/**
* The rule ID.
*/
ruleId: string;
/**
* The rule IDs that replace this deprecated rule.
*/
replacedBy: string[];
}
/**
* The LintResult value is the information of the linting result of each file.
*/
interface LintResult {
/**
* The number of errors. This includes fixable errors.
*/
errorCount: number;
/**
* The absolute path to the file of this result. This is the string "<text>" if the file path is unknown (when you
* didn't pass the options.filePath option to the eslint.lintText() method).
*/
filePath: string;
/**
* The number of errors that can be fixed automatically by the fix constructor option.
*/
fixableErrorCount: number;
/**
* The number of warnings that can be fixed automatically by the fix constructor option.
*/
fixableWarningCount: number;
/**
* The array of LintMessage objects.
*/
messages: Linter.LintMessage[];
/**
* The source code of the file that was linted, with as many fixes applied as possible.
*/
output?: string;
/**
* The original source code text. This property is undefined if any messages didn't exist or the output
* property exists.
*/
source?: string;
/**
* The information about the deprecated rules that were used to check this file.
*/
usedDeprecatedRules: DeprecatedRuleInfo[];
/**
* The number of warnings. This includes fixable warnings.
*/
warningCount: number;
}
interface LintTextOptions {
/**
* The path to the file of the source code text. If omitted, the result.filePath becomes the string "<text>".
*/
filePath?: string;
/**
* If true is present and the options.filePath is a file ESLint should ignore, this method returns a lint result
* contains a warning message.
*/
warnIgnored?: boolean;
}
/**
* The LintMessage value is the information of each linting error.
*/
interface LintMessage {
/**
* The 1-based column number of the begin point of this message.
*/
column: number;
/**
* The 1-based column number of the end point of this message. This property is undefined if this message
* is not a range.
*/
endColumn: number | undefined;
/**
* The 1-based line number of the end point of this message. This property is undefined if this
* message is not a range.
*/
endLine: number | undefined;
/**
* The EditInfo object of autofix. This property is undefined if this message is not fixable.
*/
fix: EditInfo | undefined;
/**
* The 1-based line number of the begin point of this message.
*/
line: number;
/**
* The error message
*/
message: string;
/**
* The rule name that generates this lint message. If this message is generated by the ESLint core rather than
* rules, this is null.
*/
ruleId: string | null;
/**
* The severity of this message. 1 means warning and 2 means error.
*/
severity: 1 | 2;
/**
* The list of suggestions. Each suggestion is the pair of a description and an EditInfo object to fix code. API
* users such as editor integrations can choose one of them to fix the problem of this message. This property is
* undefined if this message doesn't have any suggestions.
*/
suggestions: {
desc: string;
fix: EditInfo;
}[] | undefined;
}
/**
* The EditInfo value is information to edit text.
*
* This edit information means replacing the range of the range property by the text property value. It's like
* sourceCodeText.slice(0, edit.range[0]) + edit.text + sourceCodeText.slice(edit.range[1]). Therefore, it's an add
* if the range[0] and range[1] property values are the same value, and it's removal if the text property value is
* empty string.
*/
interface EditInfo {
/**
* The pair of 0-based indices in source code text to remove.
*/
range: [
number,
number
];
/**
* The text to add.
*/
text: string;
}
/**
* The Formatter value is the object to convert the LintResult objects to text.
*/
interface Formatter {
/**
* The method to convert the LintResult objects to text
*/
format(results: LintResult[]): string;
}
}
declare const _ESLint: typeof ESLintBase;
/**
* The ESLint class is the primary class to use in Node.js applications.
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
*
* If you want to lint code on browsers, use the Linter class instead.
*
* @since 7.0.0
*/
declare class ESLint extends _ESLint {
}
export { ESLint };
//# sourceMappingURL=ESLint.d.ts.map

View file

@ -0,0 +1,327 @@
import { TSESTree, ParserServices } from '../ts-estree';
import { ParserOptions as TSParserOptions } from './ParserOptions';
import { RuleCreateFunction, RuleFix, RuleModule } from './Rule';
import { Scope } from './Scope';
import { SourceCode } from './SourceCode';
declare class LinterBase {
/**
* Initialize the Linter.
* @param config the config object
*/
constructor(config?: Linter.LinterOptions);
/**
* Define a new parser module
* @param parserId Name of the parser
* @param parserModule The parser object
*/
defineParser(parserId: string, parserModule: Linter.ParserModule): void;
/**
* Defines a new linting rule.
* @param ruleId A unique rule identifier
* @param ruleModule Function from context to object mapping AST node types to event handlers
*/
defineRule<TMessageIds extends string, TOptions extends readonly unknown[]>(ruleId: string, ruleModule: RuleModule<TMessageIds, TOptions> | RuleCreateFunction): void;
/**
* Defines many new linting rules.
* @param rulesToDefine map from unique rule identifier to rule
*/
defineRules<TMessageIds extends string, TOptions extends readonly unknown[]>(rulesToDefine: Record<string, RuleModule<TMessageIds, TOptions> | RuleCreateFunction>): void;
/**
* Gets an object with all loaded rules.
* @returns All loaded rules
*/
getRules(): Map<string, RuleModule<string, unknown[]>>;
/**
* Gets the `SourceCode` object representing the parsed source.
* @returns The `SourceCode` object.
*/
getSourceCode(): SourceCode;
/**
* Verifies the text against the rules specified by the second argument.
* @param textOrSourceCode The text to parse or a SourceCode object.
* @param config An ESLintConfig instance to configure everything.
* @param filenameOrOptions The optional filename of the file being checked.
* If this is not set, the filename will default to '<input>' in the rule context.
* If this is an object, then it has "filename", "allowInlineConfig", and some properties.
* @returns The results as an array of messages or an empty array if no messages.
*/
verify(textOrSourceCode: SourceCode | string, config: Linter.Config, filenameOrOptions?: string | Linter.VerifyOptions): Linter.LintMessage[];
/**
* Performs multiple autofix passes over the text until as many fixes as possible have been applied.
* @param text The source text to apply fixes to.
* @param config The ESLint config object to use.
* @param options The ESLint options object to use.
* @returns The result of the fix operation as returned from the SourceCodeFixer.
*/
verifyAndFix(code: string, config: Linter.Config, options: Linter.FixOptions): Linter.FixReport;
/**
* The version from package.json.
*/
readonly version: string;
/**
* The version from package.json.
*/
static readonly version: string;
}
declare namespace Linter {
export interface LinterOptions {
/**
* path to a directory that should be considered as the current working directory.
*/
cwd?: string;
}
export type Severity = 0 | 1 | 2;
export type SeverityString = 'off' | 'warn' | 'error';
export type RuleLevel = Severity | SeverityString;
export type RuleLevelAndOptions = [
RuleLevel,
...unknown[]
];
export type RuleEntry = RuleLevel | RuleLevelAndOptions;
export type RulesRecord = Partial<Record<string, RuleEntry>>;
interface BaseConfig {
$schema?: string;
/**
* The environment settings.
*/
env?: {
[name: string]: boolean;
};
/**
* The path to other config files or the package name of shareable configs.
*/
extends?: string | string[];
/**
* The global variable settings.
*/
globals?: {
[name: string]: boolean;
};
/**
* The flag that disables directive comments.
*/
noInlineConfig?: boolean;
/**
* The override settings per kind of files.
*/
overrides?: ConfigOverride[];
/**
* The path to a parser or the package name of a parser.
*/
parser?: string;
/**
* The parser options.
*/
parserOptions?: ParserOptions;
/**
* The plugin specifiers.
*/
plugins?: string[];
/**
* The processor specifier.
*/
processor?: string;
/**
* The flag to report unused `eslint-disable` comments.
*/
reportUnusedDisableDirectives?: boolean;
/**
* The rule settings.
*/
rules?: RulesRecord;
/**
* The shared settings.
*/
settings?: {
[name: string]: unknown;
};
}
export interface ConfigOverride extends BaseConfig {
excludedFiles?: string | string[];
files: string | string[];
}
export interface Config extends BaseConfig {
/**
* The glob patterns that ignore to lint.
*/
ignorePatterns?: string | string[];
/**
* The root flag.
*/
root?: boolean;
}
export type ParserOptions = TSParserOptions;
export interface VerifyOptions {
/**
* Allow/disallow inline comments' ability to change config once it is set. Defaults to true if not supplied.
* Useful if you want to validate JS without comments overriding rules.
*/
allowInlineConfig?: boolean;
/**
* if `true` then the linter doesn't make `fix` properties into the lint result.
*/
disableFixes?: boolean;
/**
* the filename of the source code.
*/
filename?: string;
/**
* the predicate function that selects adopt code blocks.
*/
filterCodeBlock?: (filename: string, text: string) => boolean;
/**
* postprocessor for report messages.
* If provided, this should accept an array of the message lists
* for each code block returned from the preprocessor, apply a mapping to
* the messages as appropriate, and return a one-dimensional array of
* messages.
*/
postprocess?: Processor['postprocess'];
/**
* preprocessor for source text.
* If provided, this should accept a string of source text, and return an array of code blocks to lint.
*/
preprocess?: Processor['preprocess'];
/**
* Adds reported errors for unused `eslint-disable` directives.
*/
reportUnusedDisableDirectives?: boolean | SeverityString;
}
export interface FixOptions extends VerifyOptions {
/**
* Determines whether fixes should be applied.
*/
fix?: boolean;
}
export interface LintSuggestion {
desc: string;
fix: RuleFix;
messageId?: string;
}
export interface LintMessage {
/**
* The 1-based column number.
*/
column: number;
/**
* The 1-based column number of the end location.
*/
endColumn?: number;
/**
* The 1-based line number of the end location.
*/
endLine?: number;
/**
* If `true` then this is a fatal error.
*/
fatal?: true;
/**
* Information for autofix.
*/
fix?: RuleFix;
/**
* The 1-based line number.
*/
line: number;
/**
* The error message.
*/
message: string;
messageId?: string;
nodeType: string;
/**
* The ID of the rule which makes this message.
*/
ruleId: string | null;
/**
* The severity of this message.
*/
severity: Severity;
source: string | null;
/**
* Information for suggestions
*/
suggestions?: LintSuggestion[];
}
export interface FixReport {
/**
* True, if the code was fixed
*/
fixed: boolean;
/**
* Fixed code text (might be the same as input if no fixes were applied).
*/
output: string;
/**
* Collection of all messages for the given code
*/
messages: LintMessage[];
}
export type ParserModule = {
parse(text: string, options?: ParserOptions): TSESTree.Program;
} | {
parseForESLint(text: string, options?: ParserOptions): ESLintParseResult;
};
export interface ESLintParseResult {
ast: TSESTree.Program;
parserServices?: ParserServices;
scopeManager?: Scope.ScopeManager;
visitorKeys?: SourceCode.VisitorKeys;
}
export interface Processor {
/**
* The function to extract code blocks.
*/
preprocess?: (text: string, filename: string) => Array<string | {
text: string;
filename: string;
}>;
/**
* The function to merge messages.
*/
postprocess?: (messagesList: Linter.LintMessage[][], filename: string) => Linter.LintMessage[];
/**
* If `true` then it means the processor supports autofix.
*/
supportsAutofix?: boolean;
}
export interface Environment {
/**
* The definition of global variables.
*/
globals?: Record<string, Linter.Config>;
/**
* The parser options that will be enabled under this environment.
*/
parserOptions?: ParserOptions;
}
export interface Plugin {
/**
* The definition of plugin configs.
*/
configs?: Record<string, Linter.Config>;
/**
* The definition of plugin environments.
*/
environments?: Record<string, Environment>;
/**
* The definition of plugin processors.
*/
processors?: Record<string, Processor>;
/**
* The definition of plugin rules.
*/
rules?: Record<string, RuleCreateFunction | RuleModule<string, unknown[]>>;
}
export {};
}
declare const Linter_base: typeof LinterBase;
/**
* The Linter object does the actual evaluation of the JavaScript code. It doesn't do any filesystem operations, it
* simply parses and reports on the code. In particular, the Linter object does not process configuration objects
* or files.
*/
declare class Linter extends Linter_base {
}
export { Linter };
//# sourceMappingURL=Linter.d.ts.map

View file

@ -0,0 +1,2 @@
export { DebugLevel, EcmaVersion, ParserOptions, SourceType, } from '@typescript-eslint/types';
//# sourceMappingURL=ParserOptions.d.ts.map

View file

@ -0,0 +1,370 @@
import { JSONSchema4 } from '../json-schema';
import { ParserServices, TSESTree } from '../ts-estree';
import { AST } from './AST';
import { Linter } from './Linter';
import { Scope } from './Scope';
import { SourceCode } from './SourceCode';
interface RuleMetaDataDocs {
/**
* The general category the rule falls within
*/
category: 'Best Practices' | 'Stylistic Issues' | 'Variables' | 'Possible Errors';
/**
* Concise description of the rule
*/
description: string;
/**
* The recommendation level for the rule.
* Used by the build tools to generate the recommended config.
* Set to false to not include it as a recommendation
*/
recommended: 'error' | 'warn' | false;
/**
* The URL of the rule's docs
*/
url: string;
/**
* Specifies whether the rule can return suggestions.
*/
suggestion?: boolean;
/**
* Does the rule require us to create a full TypeScript Program in order for it
* to type-check code. This is only used for documentation purposes.
*/
requiresTypeChecking?: boolean;
/**
* Does the rule extend (or is it based off of) an ESLint code rule?
* Alternately accepts the name of the base rule, in case the rule has been renamed.
* This is only used for documentation purposes.
*/
extendsBaseRule?: boolean | string;
}
interface RuleMetaData<TMessageIds extends string> {
/**
* True if the rule is deprecated, false otherwise
*/
deprecated?: boolean;
/**
* Documentation for the rule, unnecessary for custom rules/plugins
*/
docs?: RuleMetaDataDocs;
/**
* The fixer category. Omit if there is no fixer
*/
fixable?: 'code' | 'whitespace';
/**
* A map of messages which the rule can report.
* The key is the messageId, and the string is the parameterised error string.
* See: https://eslint.org/docs/developer-guide/working-with-rules#messageids
*/
messages: Record<TMessageIds, string>;
/**
* The type of rule.
* - `"problem"` means the rule is identifying code that either will cause an error or may cause a confusing behavior. Developers should consider this a high priority to resolve.
* - `"suggestion"` means the rule is identifying something that could be done in a better way but no errors will occur if the code isnt changed.
* - `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses, all the parts of the program that determine how the code looks rather than how it executes. These rules work on parts of the code that arent specified in the AST.
*/
type: 'suggestion' | 'problem' | 'layout';
/**
* The name of the rule this rule was replaced by, if it was deprecated.
*/
replacedBy?: string[];
/**
* The options schema. Supply an empty array if there are no options.
*/
schema: JSONSchema4 | JSONSchema4[];
}
interface RuleFix {
range: AST.Range;
text: string;
}
interface RuleFixer {
insertTextAfter(nodeOrToken: TSESTree.Node | TSESTree.Token, text: string): RuleFix;
insertTextAfterRange(range: AST.Range, text: string): RuleFix;
insertTextBefore(nodeOrToken: TSESTree.Node | TSESTree.Token, text: string): RuleFix;
insertTextBeforeRange(range: AST.Range, text: string): RuleFix;
remove(nodeOrToken: TSESTree.Node | TSESTree.Token): RuleFix;
removeRange(range: AST.Range): RuleFix;
replaceText(nodeOrToken: TSESTree.Node | TSESTree.Token, text: string): RuleFix;
replaceTextRange(range: AST.Range, text: string): RuleFix;
}
declare type ReportFixFunction = (fixer: RuleFixer) => null | RuleFix | RuleFix[] | IterableIterator<RuleFix>;
declare type ReportSuggestionArray<TMessageIds extends string> = ReportDescriptorBase<TMessageIds>[];
interface ReportDescriptorBase<TMessageIds extends string> {
/**
* The parameters for the message string associated with `messageId`.
*/
readonly data?: Readonly<Record<string, unknown>>;
/**
* The fixer function.
*/
readonly fix?: ReportFixFunction | null;
/**
* The messageId which is being reported.
*/
readonly messageId: TMessageIds;
}
interface ReportDescriptorWithSuggestion<TMessageIds extends string> extends ReportDescriptorBase<TMessageIds> {
/**
* 6.7's Suggestions API
*/
readonly suggest?: Readonly<ReportSuggestionArray<TMessageIds>> | null;
}
interface ReportDescriptorNodeOptionalLoc {
/**
* The Node or AST Token which the report is being attached to
*/
readonly node: TSESTree.Node | TSESTree.Comment | TSESTree.Token;
/**
* An override of the location of the report
*/
readonly loc?: Readonly<TSESTree.SourceLocation> | Readonly<TSESTree.LineAndColumnData>;
}
interface ReportDescriptorLocOnly {
/**
* An override of the location of the report
*/
loc: Readonly<TSESTree.SourceLocation> | Readonly<TSESTree.LineAndColumnData>;
}
declare type ReportDescriptor<TMessageIds extends string> = ReportDescriptorWithSuggestion<TMessageIds> & (ReportDescriptorNodeOptionalLoc | ReportDescriptorLocOnly);
interface RuleContext<TMessageIds extends string, TOptions extends readonly unknown[]> {
/**
* The rule ID.
*/
id: string;
/**
* An array of the configured options for this rule.
* This array does not include the rule severity.
*/
options: TOptions;
/**
* The name of the parser from configuration.
*/
parserPath: string;
/**
* The parser options configured for this run
*/
parserOptions: Linter.ParserOptions;
/**
* An object containing parser-provided services for rules
*/
parserServices?: ParserServices;
/**
* The shared settings from configuration.
* We do not have any shared settings in this plugin.
*/
settings: Record<string, unknown>;
/**
* Returns an array of the ancestors of the currently-traversed node, starting at
* the root of the AST and continuing through the direct parent of the current node.
* This array does not include the currently-traversed node itself.
*/
getAncestors(): TSESTree.Node[];
/**
* Returns a list of variables declared by the given node.
* This information can be used to track references to variables.
*/
getDeclaredVariables(node: TSESTree.Node): Scope.Variable[];
/**
* Returns the filename associated with the source.
*/
getFilename(): string;
/**
* Returns the scope of the currently-traversed node.
* This information can be used track references to variables.
*/
getScope(): Scope.Scope;
/**
* Returns a SourceCode object that you can use to work with the source that
* was passed to ESLint.
*/
getSourceCode(): Readonly<SourceCode>;
/**
* Marks a variable with the given name in the current scope as used.
* This affects the no-unused-vars rule.
*/
markVariableAsUsed(name: string): boolean;
/**
* Reports a problem in the code.
*/
report(descriptor: ReportDescriptor<TMessageIds>): void;
}
declare type RuleFunction<T extends TSESTree.BaseNode = never> = (node: T) => void;
interface RuleListener {
[nodeSelector: string]: RuleFunction | undefined;
ArrayExpression?: RuleFunction<TSESTree.ArrayExpression>;
ArrayPattern?: RuleFunction<TSESTree.ArrayPattern>;
ArrowFunctionExpression?: RuleFunction<TSESTree.ArrowFunctionExpression>;
AssignmentPattern?: RuleFunction<TSESTree.AssignmentPattern>;
AssignmentExpression?: RuleFunction<TSESTree.AssignmentExpression>;
AwaitExpression?: RuleFunction<TSESTree.AwaitExpression>;
BigIntLiteral?: RuleFunction<TSESTree.BigIntLiteral>;
BinaryExpression?: RuleFunction<TSESTree.BinaryExpression>;
BlockStatement?: RuleFunction<TSESTree.BlockStatement>;
BreakStatement?: RuleFunction<TSESTree.BreakStatement>;
CallExpression?: RuleFunction<TSESTree.CallExpression>;
CatchClause?: RuleFunction<TSESTree.CatchClause>;
ClassBody?: RuleFunction<TSESTree.ClassBody>;
ClassDeclaration?: RuleFunction<TSESTree.ClassDeclaration>;
ClassExpression?: RuleFunction<TSESTree.ClassExpression>;
ClassProperty?: RuleFunction<TSESTree.ClassProperty>;
Comment?: RuleFunction<TSESTree.Comment>;
ConditionalExpression?: RuleFunction<TSESTree.ConditionalExpression>;
ContinueStatement?: RuleFunction<TSESTree.ContinueStatement>;
DebuggerStatement?: RuleFunction<TSESTree.DebuggerStatement>;
Decorator?: RuleFunction<TSESTree.Decorator>;
DoWhileStatement?: RuleFunction<TSESTree.DoWhileStatement>;
EmptyStatement?: RuleFunction<TSESTree.EmptyStatement>;
ExportAllDeclaration?: RuleFunction<TSESTree.ExportAllDeclaration>;
ExportDefaultDeclaration?: RuleFunction<TSESTree.ExportDefaultDeclaration>;
ExportNamedDeclaration?: RuleFunction<TSESTree.ExportNamedDeclaration>;
ExportSpecifier?: RuleFunction<TSESTree.ExportSpecifier>;
ExpressionStatement?: RuleFunction<TSESTree.ExpressionStatement>;
ForInStatement?: RuleFunction<TSESTree.ForInStatement>;
ForOfStatement?: RuleFunction<TSESTree.ForOfStatement>;
ForStatement?: RuleFunction<TSESTree.ForStatement>;
FunctionDeclaration?: RuleFunction<TSESTree.FunctionDeclaration>;
FunctionExpression?: RuleFunction<TSESTree.FunctionExpression>;
Identifier?: RuleFunction<TSESTree.Identifier>;
IfStatement?: RuleFunction<TSESTree.IfStatement>;
ImportDeclaration?: RuleFunction<TSESTree.ImportDeclaration>;
ImportDefaultSpecifier?: RuleFunction<TSESTree.ImportDefaultSpecifier>;
ImportExpression?: RuleFunction<TSESTree.ImportExpression>;
ImportNamespaceSpecifier?: RuleFunction<TSESTree.ImportNamespaceSpecifier>;
ImportSpecifier?: RuleFunction<TSESTree.ImportSpecifier>;
JSXAttribute?: RuleFunction<TSESTree.JSXAttribute>;
JSXClosingElement?: RuleFunction<TSESTree.JSXClosingElement>;
JSXClosingFragment?: RuleFunction<TSESTree.JSXClosingFragment>;
JSXElement?: RuleFunction<TSESTree.JSXElement>;
JSXEmptyExpression?: RuleFunction<TSESTree.JSXEmptyExpression>;
JSXExpressionContainer?: RuleFunction<TSESTree.JSXExpressionContainer>;
JSXFragment?: RuleFunction<TSESTree.JSXFragment>;
JSXIdentifier?: RuleFunction<TSESTree.JSXIdentifier>;
JSXMemberExpression?: RuleFunction<TSESTree.JSXMemberExpression>;
JSXOpeningElement?: RuleFunction<TSESTree.JSXOpeningElement>;
JSXOpeningFragment?: RuleFunction<TSESTree.JSXOpeningFragment>;
JSXSpreadAttribute?: RuleFunction<TSESTree.JSXSpreadAttribute>;
JSXSpreadChild?: RuleFunction<TSESTree.JSXSpreadChild>;
JSXText?: RuleFunction<TSESTree.JSXText>;
LabeledStatement?: RuleFunction<TSESTree.LabeledStatement>;
Literal?: RuleFunction<TSESTree.Literal>;
LogicalExpression?: RuleFunction<TSESTree.LogicalExpression>;
MemberExpression?: RuleFunction<TSESTree.MemberExpression>;
MetaProperty?: RuleFunction<TSESTree.MetaProperty>;
MethodDefinition?: RuleFunction<TSESTree.MethodDefinition>;
NewExpression?: RuleFunction<TSESTree.NewExpression>;
ObjectExpression?: RuleFunction<TSESTree.ObjectExpression>;
ObjectPattern?: RuleFunction<TSESTree.ObjectPattern>;
OptionalCallExpression?: RuleFunction<TSESTree.OptionalCallExpression>;
OptionalMemberExpression?: RuleFunction<TSESTree.OptionalMemberExpression>;
Program?: RuleFunction<TSESTree.Program>;
Property?: RuleFunction<TSESTree.Property>;
RestElement?: RuleFunction<TSESTree.RestElement>;
ReturnStatement?: RuleFunction<TSESTree.ReturnStatement>;
SequenceExpression?: RuleFunction<TSESTree.SequenceExpression>;
SpreadElement?: RuleFunction<TSESTree.SpreadElement>;
Super?: RuleFunction<TSESTree.Super>;
SwitchCase?: RuleFunction<TSESTree.SwitchCase>;
SwitchStatement?: RuleFunction<TSESTree.SwitchStatement>;
TaggedTemplateExpression?: RuleFunction<TSESTree.TaggedTemplateExpression>;
TemplateElement?: RuleFunction<TSESTree.TemplateElement>;
TemplateLiteral?: RuleFunction<TSESTree.TemplateLiteral>;
ThisExpression?: RuleFunction<TSESTree.ThisExpression>;
ThrowStatement?: RuleFunction<TSESTree.ThrowStatement>;
Token?: RuleFunction<TSESTree.Token>;
TryStatement?: RuleFunction<TSESTree.TryStatement>;
TSAbstractClassProperty?: RuleFunction<TSESTree.TSAbstractClassProperty>;
TSAbstractKeyword?: RuleFunction<TSESTree.TSAbstractKeyword>;
TSAbstractMethodDefinition?: RuleFunction<TSESTree.TSAbstractMethodDefinition>;
TSAnyKeyword?: RuleFunction<TSESTree.TSAnyKeyword>;
TSArrayType?: RuleFunction<TSESTree.TSArrayType>;
TSAsExpression?: RuleFunction<TSESTree.TSAsExpression>;
TSAsyncKeyword?: RuleFunction<TSESTree.TSAsyncKeyword>;
TSBigIntKeyword?: RuleFunction<TSESTree.TSBigIntKeyword>;
TSBooleanKeyword?: RuleFunction<TSESTree.TSBooleanKeyword>;
TSCallSignatureDeclaration?: RuleFunction<TSESTree.TSCallSignatureDeclaration>;
TSClassImplements?: RuleFunction<TSESTree.TSClassImplements>;
TSConditionalType?: RuleFunction<TSESTree.TSConditionalType>;
TSConstructorType?: RuleFunction<TSESTree.TSConstructorType>;
TSConstructSignatureDeclaration?: RuleFunction<TSESTree.TSConstructSignatureDeclaration>;
TSDeclareKeyword?: RuleFunction<TSESTree.TSDeclareKeyword>;
TSDeclareFunction?: RuleFunction<TSESTree.TSDeclareFunction>;
TSEmptyBodyFunctionExpression?: RuleFunction<TSESTree.TSEmptyBodyFunctionExpression>;
TSEnumDeclaration?: RuleFunction<TSESTree.TSEnumDeclaration>;
TSEnumMember?: RuleFunction<TSESTree.TSEnumMember>;
TSExportAssignment?: RuleFunction<TSESTree.TSExportAssignment>;
TSExportKeyword?: RuleFunction<TSESTree.TSExportKeyword>;
TSExternalModuleReference?: RuleFunction<TSESTree.TSExternalModuleReference>;
TSFunctionType?: RuleFunction<TSESTree.TSFunctionType>;
TSImportEqualsDeclaration?: RuleFunction<TSESTree.TSImportEqualsDeclaration>;
TSImportType?: RuleFunction<TSESTree.TSImportType>;
TSIndexedAccessType?: RuleFunction<TSESTree.TSIndexedAccessType>;
TSIndexSignature?: RuleFunction<TSESTree.TSIndexSignature>;
TSInferType?: RuleFunction<TSESTree.TSInferType>;
TSInterfaceBody?: RuleFunction<TSESTree.TSInterfaceBody>;
TSInterfaceDeclaration?: RuleFunction<TSESTree.TSInterfaceDeclaration>;
TSInterfaceHeritage?: RuleFunction<TSESTree.TSInterfaceHeritage>;
TSIntersectionType?: RuleFunction<TSESTree.TSIntersectionType>;
TSLiteralType?: RuleFunction<TSESTree.TSLiteralType>;
TSMappedType?: RuleFunction<TSESTree.TSMappedType>;
TSMethodSignature?: RuleFunction<TSESTree.TSMethodSignature>;
TSModuleBlock?: RuleFunction<TSESTree.TSModuleBlock>;
TSModuleDeclaration?: RuleFunction<TSESTree.TSModuleDeclaration>;
TSNamespaceExportDeclaration?: RuleFunction<TSESTree.TSNamespaceExportDeclaration>;
TSNeverKeyword?: RuleFunction<TSESTree.TSNeverKeyword>;
TSNonNullExpression?: RuleFunction<TSESTree.TSNonNullExpression>;
TSNullKeyword?: RuleFunction<TSESTree.TSNullKeyword>;
TSNumberKeyword?: RuleFunction<TSESTree.TSNumberKeyword>;
TSObjectKeyword?: RuleFunction<TSESTree.TSObjectKeyword>;
TSOptionalType?: RuleFunction<TSESTree.TSOptionalType>;
TSParameterProperty?: RuleFunction<TSESTree.TSParameterProperty>;
TSParenthesizedType?: RuleFunction<TSESTree.TSParenthesizedType>;
TSPrivateKeyword?: RuleFunction<TSESTree.TSPrivateKeyword>;
TSPropertySignature?: RuleFunction<TSESTree.TSPropertySignature>;
TSProtectedKeyword?: RuleFunction<TSESTree.TSProtectedKeyword>;
TSPublicKeyword?: RuleFunction<TSESTree.TSPublicKeyword>;
TSQualifiedName?: RuleFunction<TSESTree.TSQualifiedName>;
TSReadonlyKeyword?: RuleFunction<TSESTree.TSReadonlyKeyword>;
TSRestType?: RuleFunction<TSESTree.TSRestType>;
TSStaticKeyword?: RuleFunction<TSESTree.TSStaticKeyword>;
TSStringKeyword?: RuleFunction<TSESTree.TSStringKeyword>;
TSSymbolKeyword?: RuleFunction<TSESTree.TSSymbolKeyword>;
TSThisType?: RuleFunction<TSESTree.TSThisType>;
TSTupleType?: RuleFunction<TSESTree.TSTupleType>;
TSTypeAliasDeclaration?: RuleFunction<TSESTree.TSTypeAliasDeclaration>;
TSTypeAnnotation?: RuleFunction<TSESTree.TSTypeAnnotation>;
TSTypeAssertion?: RuleFunction<TSESTree.TSTypeAssertion>;
TSTypeLiteral?: RuleFunction<TSESTree.TSTypeLiteral>;
TSTypeOperator?: RuleFunction<TSESTree.TSTypeOperator>;
TSTypeParameter?: RuleFunction<TSESTree.TSTypeParameter>;
TSTypeParameterDeclaration?: RuleFunction<TSESTree.TSTypeParameterDeclaration>;
TSTypeParameterInstantiation?: RuleFunction<TSESTree.TSTypeParameterInstantiation>;
TSTypePredicate?: RuleFunction<TSESTree.TSTypePredicate>;
TSTypeQuery?: RuleFunction<TSESTree.TSTypeQuery>;
TSTypeReference?: RuleFunction<TSESTree.TSTypeReference>;
TSUndefinedKeyword?: RuleFunction<TSESTree.TSUndefinedKeyword>;
TSUnionType?: RuleFunction<TSESTree.TSUnionType>;
TSUnknownKeyword?: RuleFunction<TSESTree.TSUnknownKeyword>;
TSVoidKeyword?: RuleFunction<TSESTree.TSVoidKeyword>;
UnaryExpression?: RuleFunction<TSESTree.UnaryExpression>;
UpdateExpression?: RuleFunction<TSESTree.UpdateExpression>;
VariableDeclaration?: RuleFunction<TSESTree.VariableDeclaration>;
VariableDeclarator?: RuleFunction<TSESTree.VariableDeclarator>;
WhileStatement?: RuleFunction<TSESTree.WhileStatement>;
WithStatement?: RuleFunction<TSESTree.WithStatement>;
YieldExpression?: RuleFunction<TSESTree.YieldExpression>;
}
interface RuleModule<TMessageIds extends string, TOptions extends readonly unknown[], TRuleListener extends RuleListener = RuleListener> {
/**
* Metadata about the rule
*/
meta: RuleMetaData<TMessageIds>;
/**
* Function which returns an object with methods that ESLint calls to visit
* nodes while traversing the abstract syntax tree.
*/
create(context: Readonly<RuleContext<TMessageIds, TOptions>>): TRuleListener;
}
declare type RuleCreateFunction = (context: Readonly<RuleContext<never, unknown[]>>) => RuleListener;
export { ReportDescriptor, ReportFixFunction, ReportSuggestionArray, RuleContext, RuleCreateFunction, RuleFix, RuleFixer, RuleFunction, RuleListener, RuleMetaData, RuleMetaDataDocs, RuleModule, };
//# sourceMappingURL=Rule.d.ts.map

View file

@ -0,0 +1,137 @@
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from '../ts-estree';
import { ParserOptions } from './ParserOptions';
import { RuleModule } from './Rule';
interface ValidTestCase<TOptions extends Readonly<unknown[]>> {
/**
* Code for the test case.
*/
readonly code: string;
/**
* Environments for the test case.
*/
readonly env?: Readonly<Record<string, boolean>>;
/**
* The fake filename for the test case. Useful for rules that make assertion about filenames.
*/
readonly filename?: string;
/**
* The additional global variables.
*/
readonly globals?: Record<string, 'readonly' | 'writable' | 'off'>;
/**
* Options for the test case.
*/
readonly options?: Readonly<TOptions>;
/**
* The absolute path for the parser.
*/
readonly parser?: string;
/**
* Options for the parser.
*/
readonly parserOptions?: Readonly<ParserOptions>;
/**
* Settings for the test case.
*/
readonly settings?: Readonly<Record<string, unknown>>;
}
interface SuggestionOutput<TMessageIds extends string> {
/**
* Reported message ID.
*/
readonly messageId: TMessageIds;
/**
* The data used to fill the message template.
*/
readonly data?: Readonly<Record<string, unknown>>;
/**
* NOTE: Suggestions will be applied as a stand-alone change, without triggering multi-pass fixes.
* Each individual error has its own suggestion, so you have to show the correct, _isolated_ output for each suggestion.
*/
readonly output: string;
}
interface InvalidTestCase<TMessageIds extends string, TOptions extends Readonly<unknown[]>> extends ValidTestCase<TOptions> {
/**
* Expected errors.
*/
readonly errors: TestCaseError<TMessageIds>[];
/**
* The expected code after autofixes are applied. If set to `null`, the test runner will assert that no autofix is suggested.
*/
readonly output?: string | null;
}
interface TestCaseError<TMessageIds extends string> {
/**
* The 1-based column number of the reported start location.
*/
readonly column?: number;
/**
* The data used to fill the message template.
*/
readonly data?: Readonly<Record<string, unknown>>;
/**
* The 1-based column number of the reported end location.
*/
readonly endColumn?: number;
/**
* The 1-based line number of the reported end location.
*/
readonly endLine?: number;
/**
* The 1-based line number of the reported start location.
*/
readonly line?: number;
/**
* Reported message ID.
*/
readonly messageId: TMessageIds;
/**
* Reported suggestions.
*/
readonly suggestions?: SuggestionOutput<TMessageIds>[] | null;
/**
* The type of the reported AST node.
*/
readonly type?: AST_NODE_TYPES | AST_TOKEN_TYPES;
}
interface RunTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>> {
readonly valid: (ValidTestCase<TOptions> | string)[];
readonly invalid: InvalidTestCase<TMessageIds, TOptions>[];
}
interface RuleTesterConfig {
readonly parser: string;
readonly parserOptions?: Readonly<ParserOptions>;
}
declare class RuleTesterBase {
/**
* Creates a new instance of RuleTester.
* @param testerConfig extra configuration for the tester
*/
constructor(testerConfig?: RuleTesterConfig);
/**
* Adds a new rule test to execute.
* @param ruleName The name of the rule to run.
* @param rule The rule to test.
* @param test The collection of tests to run.
*/
run<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(ruleName: string, rule: RuleModule<TMessageIds, TOptions>, tests: RunTests<TMessageIds, TOptions>): void;
/**
* If you supply a value to this property, the rule tester will call this instead of using the version defined on
* the global namespace.
* @param text a string describing the rule
* @param callback the test callback
*/
static describe?: (text: string, callback: () => void) => void;
/**
* If you supply a value to this property, the rule tester will call this instead of using the version defined on
* the global namespace.
* @param text a string describing the test case
* @param callback the test callback
*/
static it?: (text: string, callback: () => void) => void;
}
declare const RuleTester_base: typeof RuleTesterBase;
declare class RuleTester extends RuleTester_base {
}
export { InvalidTestCase, SuggestionOutput, RuleTester, RuleTesterConfig, RunTests, TestCaseError, ValidTestCase, };
//# sourceMappingURL=RuleTester.d.ts.map

View file

@ -0,0 +1,76 @@
import { TSESTree } from '../ts-estree';
declare namespace Scope {
interface ScopeManager {
scopes: Scope[];
globalScope: Scope | null;
acquire(node: TSESTree.Node, inner?: boolean): Scope | null;
getDeclaredVariables(node: TSESTree.Node): Variable[];
}
interface Reference {
identifier: TSESTree.Identifier;
from: Scope;
resolved: Variable | null;
writeExpr: TSESTree.Node | null;
init: boolean;
isWrite(): boolean;
isRead(): boolean;
isWriteOnly(): boolean;
isReadOnly(): boolean;
isReadWrite(): boolean;
}
interface Variable {
name: string;
identifiers: TSESTree.Identifier[];
references: Reference[];
defs: Definition[];
scope: Scope;
eslintUsed?: boolean;
}
interface Scope {
type: 'block' | 'catch' | 'class' | 'for' | 'function' | 'function-expression-name' | 'global' | 'module' | 'switch' | 'with' | 'TDZ';
isStrict: boolean;
upper: Scope | null;
childScopes: Scope[];
variableScope: Scope;
block: TSESTree.Node;
variables: Variable[];
set: Map<string, Variable>;
references: Reference[];
through: Reference[];
functionExpressionScope: boolean;
}
type DefinitionType = {
type: 'CatchClause';
node: TSESTree.CatchClause;
parent: null;
} | {
type: 'ClassName';
node: TSESTree.ClassDeclaration | TSESTree.ClassExpression;
parent: null;
} | {
type: 'FunctionName';
node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
parent: null;
} | {
type: 'ImplicitGlobalVariable';
node: TSESTree.Program;
parent: null;
} | {
type: 'ImportBinding';
node: TSESTree.ImportSpecifier | TSESTree.ImportDefaultSpecifier | TSESTree.ImportNamespaceSpecifier;
parent: TSESTree.ImportDeclaration;
} | {
type: 'Parameter';
node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression;
parent: null;
} | {
type: 'Variable';
node: TSESTree.VariableDeclarator;
parent: TSESTree.VariableDeclaration;
};
type Definition = DefinitionType & {
name: TSESTree.Identifier;
};
}
export { Scope };
//# sourceMappingURL=Scope.d.ts.map

View file

@ -0,0 +1,350 @@
import { ParserServices, TSESTree } from '../ts-estree';
import { Scope } from './Scope';
declare class TokenStore {
/**
* Checks whether any comments exist or not between the given 2 nodes.
* @param left The node to check.
* @param right The node to check.
* @returns `true` if one or more comments exist.
*/
commentsExistBetween(left: TSESTree.Node | TSESTree.Token, right: TSESTree.Node | TSESTree.Token): boolean;
/**
* Gets all comment tokens directly after the given node or token.
* @param nodeOrToken The AST node or token to check for adjacent comment tokens.
* @returns An array of comments in occurrence order.
*/
getCommentsAfter(nodeOrToken: TSESTree.Node | TSESTree.Token): TSESTree.Comment[];
/**
* Gets all comment tokens directly before the given node or token.
* @param nodeOrToken The AST node or token to check for adjacent comment tokens.
* @returns An array of comments in occurrence order.
*/
getCommentsBefore(nodeOrToken: TSESTree.Node | TSESTree.Token): TSESTree.Comment[];
/**
* Gets all comment tokens inside the given node.
* @param node The AST node to get the comments for.
* @returns An array of comments in occurrence order.
*/
getCommentsInside(node: TSESTree.Node): TSESTree.Comment[];
/**
* Gets the first token of the given node.
* @param node The AST node.
* @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @returns An object representing the token.
*/
getFirstToken<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets the first token between two non-overlapping nodes.
* @param left Node before the desired token range.
* @param right Node after the desired token range.
* @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @returns An object representing the token.
*/
getFirstTokenBetween<T extends SourceCode.CursorWithSkipOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets the first `count` tokens of the given node.
* @param node The AST node.
* @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @returns Tokens.
*/
getFirstTokens<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets the first `count` tokens between two non-overlapping nodes.
* @param left Node before the desired token range.
* @param right Node after the desired token range.
* @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @returns Tokens between left and right.
*/
getFirstTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets the last token of the given node.
* @param node The AST node.
* @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @returns An object representing the token.
*/
getLastToken<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets the last token between two non-overlapping nodes.
* @param left Node before the desired token range.
* @param right Node after the desired token range.
* @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @returns An object representing the token.
*/
getLastTokenBetween<T extends SourceCode.CursorWithSkipOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets the last `count` tokens of the given node.
* @param node The AST node.
* @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @returns Tokens.
*/
getLastTokens<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node, options?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets the last `count` tokens between two non-overlapping nodes.
* @param left Node before the desired token range.
* @param right Node after the desired token range.
* @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @returns Tokens between left and right.
*/
getLastTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets the token that follows a given node or token.
* @param node The AST node or token.
* @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @returns An object representing the token.
*/
getTokenAfter<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets the token that precedes a given node or token.
* @param node The AST node or token.
* @param options The option object
* @returns An object representing the token.
*/
getTokenBefore<T extends SourceCode.CursorWithSkipOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets the token starting at the specified index.
* @param offset Index of the start of the token's range.
* @param option The option object. If this is a number then it's `options.skip`. If this is a function then it's `options.filter`.
* @returns The token starting at index, or null if no such token.
*/
getTokenByRangeStart<T extends {
includeComments?: boolean;
}>(offset: number, options?: T): SourceCode.ReturnTypeFromOptions<T> | null;
/**
* Gets all tokens that are related to the given node.
* @param node The AST node.
* @param beforeCount The number of tokens before the node to retrieve.
* @param afterCount The number of tokens after the node to retrieve.
* @returns Array of objects representing tokens.
*/
getTokens(node: TSESTree.Node, beforeCount?: number, afterCount?: number): TSESTree.Token[];
/**
* Gets all tokens that are related to the given node.
* @param node The AST node.
* @param options The option object. If this is a function then it's `options.filter`.
* @returns Array of objects representing tokens.
*/
getTokens<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node, options: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets the `count` tokens that follows a given node or token.
* @param node The AST node.
* @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @returns Tokens.
*/
getTokensAfter<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets the `count` tokens that precedes a given node or token.
* @param node The AST node.
* @param options The option object. If this is a number then it's `options.count`. If this is a function then it's `options.filter`.
* @returns Tokens.
*/
getTokensBefore<T extends SourceCode.CursorWithCountOptions>(node: TSESTree.Node | TSESTree.Token | TSESTree.Comment, options?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets all of the tokens between two non-overlapping nodes.
* @param left Node before the desired token range.
* @param right Node after the desired token range.
* @param options The option object. If this is a function then it's `options.filter`.
* @returns Tokens between left and right.
*/
getTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, padding?: T): SourceCode.ReturnTypeFromOptions<T>[];
/**
* Gets all of the tokens between two non-overlapping nodes.
* @param left Node before the desired token range.
* @param right Node after the desired token range.
* @param padding Number of extra tokens on either side of center.
* @returns Tokens between left and right.
*/
getTokensBetween<T extends SourceCode.CursorWithCountOptions>(left: TSESTree.Node | TSESTree.Token | TSESTree.Comment, right: TSESTree.Node | TSESTree.Token | TSESTree.Comment, padding?: number): SourceCode.ReturnTypeFromOptions<T>[];
}
declare class SourceCodeBase extends TokenStore {
/**
* Represents parsed source code.
* @param text The source code text.
* @param ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
*/
constructor(text: string, ast: SourceCode.Program);
/**
* Represents parsed source code.
* @param config The config object.
*/
constructor(config: SourceCode.SourceCodeConfig);
/**
* The parsed AST for the source code.
*/
ast: SourceCode.Program;
/**
* Retrieves an array containing all comments in the source code.
* @returns An array of comment nodes.
*/
getAllComments(): TSESTree.Comment[];
/**
* Gets all comments for the given node.
* @param node The AST node to get the comments for.
* @returns An object containing a leading and trailing array of comments indexed by their position.
*/
getComments(node: TSESTree.Node): {
leading: TSESTree.Comment[];
trailing: TSESTree.Comment[];
};
/**
* Converts a (line, column) pair into a range index.
* @param loc A line/column location
* @returns The range index of the location in the file.
*/
getIndexFromLoc(location: TSESTree.LineAndColumnData): number;
/**
* Gets the entire source text split into an array of lines.
* @returns The source text as an array of lines.
*/
getLines(): string[];
/**
* Converts a source text index into a (line, column) pair.
* @param index The index of a character in a file
* @returns A {line, column} location object with a 0-indexed column
*/
getLocFromIndex(index: number): TSESTree.LineAndColumnData;
/**
* Gets the deepest node containing a range index.
* @param index Range index of the desired node.
* @returns The node if found or `null` if not found.
*/
getNodeByRangeIndex(index: number): TSESTree.Node | null;
/**
* Gets the source code for the given node.
* @param node The AST node to get the text for.
* @param beforeCount The number of characters before the node to retrieve.
* @param afterCount The number of characters after the node to retrieve.
* @returns The text representing the AST node.
*/
getText(node?: TSESTree.Node, beforeCount?: number, afterCount?: number): string;
/**
* The flag to indicate that the source code has Unicode BOM.
*/
hasBOM: boolean;
/**
* Determines if two nodes or tokens have at least one whitespace character
* between them. Order does not matter. Returns false if the given nodes or
* tokens overlap.
* This was added in v6.7.0.
* @since 6.7.0
* @param first The first node or token to check between.
* @param second The second node or token to check between.
* @returns True if there is a whitespace character between any of the tokens found between the two given nodes or tokens.
*/
isSpaceBetween?(first: TSESTree.Token | TSESTree.Comment | TSESTree.Node, second: TSESTree.Token | TSESTree.Comment | TSESTree.Node): boolean;
/**
* Determines if two nodes or tokens have at least one whitespace character
* between them. Order does not matter. Returns false if the given nodes or
* tokens overlap.
* For backward compatibility, this method returns true if there are
* `JSXText` tokens that contain whitespace between the two.
* @param first The first node or token to check between.
* @param second The second node or token to check between.
* @returns {boolean} True if there is a whitespace character between
* any of the tokens found between the two given nodes or tokens.
* @deprecated in favor of isSpaceBetween
*/
isSpaceBetweenTokens(first: TSESTree.Token, second: TSESTree.Token): boolean;
/**
* The source code split into lines according to ECMA-262 specification.
* This is done to avoid each rule needing to do so separately.
*/
lines: string[];
/**
* The indexes in `text` that each line starts
*/
lineStartIndices: number[];
/**
* The parser services of this source code.
*/
parserServices: ParserServices;
/**
* The scope of this source code.
*/
scopeManager: Scope.ScopeManager | null;
/**
* The original text source code. BOM was stripped from this text.
*/
text: string;
/**
* All of the tokens and comments in the AST.
*/
tokensAndComments: (TSESTree.Comment | TSESTree.Token)[];
/**
* The visitor keys to traverse AST.
*/
visitorKeys: SourceCode.VisitorKeys;
/**
* Split the source code into multiple lines based on the line delimiters.
* @param text Source code as a string.
* @returns Array of source code lines.
*/
static splitLines(text: string): string[];
}
declare namespace SourceCode {
interface Program extends TSESTree.Program {
comments: TSESTree.Comment[];
tokens: TSESTree.Token[];
}
interface SourceCodeConfig {
/**
* The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
*/
ast: Program;
/**
* The parser services.
*/
parserServices: ParserServices | null;
/**
* The scope of this source code.
*/
scopeManager: Scope.ScopeManager | null;
/**
* The source code text.
*/
text: string;
/**
* The visitor keys to traverse AST.
*/
visitorKeys: VisitorKeys | null;
}
interface VisitorKeys {
[nodeType: string]: string[];
}
type FilterPredicate = (tokenOrComment: TSESTree.Token | TSESTree.Comment) => boolean;
type ReturnTypeFromOptions<T> = T extends {
includeComments: true;
} ? TSESTree.Token : Exclude<TSESTree.Token, TSESTree.Comment>;
type CursorWithSkipOptions = number | FilterPredicate | {
/**
* The predicate function to choose tokens.
*/
filter?: FilterPredicate;
/**
* The flag to iterate comments as well.
*/
includeComments?: boolean;
/**
* The count of tokens the cursor skips.
*/
skip?: number;
};
type CursorWithCountOptions = number | FilterPredicate | {
/**
* The predicate function to choose tokens.
*/
filter?: FilterPredicate;
/**
* The flag to iterate comments as well.
*/
includeComments?: boolean;
/**
* The maximum count of tokens the cursor iterates.
*/
count?: number;
};
}
declare const SourceCode_base: typeof SourceCodeBase;
declare class SourceCode extends SourceCode_base {
}
export { SourceCode };
//# sourceMappingURL=SourceCode.d.ts.map

View file

@ -0,0 +1,10 @@
export * from './AST';
export * from './CLIEngine';
export * from './ESLint';
export * from './Linter';
export * from './ParserOptions';
export * from './Rule';
export * from './RuleTester';
export * from './Scope';
export * from './SourceCode';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1,3 @@
export { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree, } from '@typescript-eslint/types';
export { ParserServices } from '@typescript-eslint/typescript-estree/dist/parser-options';
//# sourceMappingURL=ts-estree.d.ts.map

View file

@ -0,0 +1,48 @@
interface PatternMatcher {
/**
* Iterate all matched parts in a given string.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-execall}
*/
execAll(str: string): IterableIterator<RegExpExecArray>;
/**
* Check whether this pattern matches a given string or not.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-test}
*/
test(str: string): boolean;
/**
* Replace all matched parts by a given replacer.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#matcher-symbol-replace}
* @example
* const { PatternMatcher } = require("eslint-utils")
* const matcher = new PatternMatcher(/\\p{Script=Greek}/g)
*
* module.exports = {
* meta: {},
* create(context) {
* return {
* "Literal[regex]"(node) {
* const replacedPattern = node.regex.pattern.replace(
* matcher,
* "[\\u0370-\\u0373\\u0375-\\u0377\\u037A-\\u037D\\u037F\\u0384\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03E1\\u03F0-\\u03FF\\u1D26-\\u1D2A\\u1D5D-\\u1D61\\u1D66-\\u1D6A\\u1DBF\\u1F00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FC4\\u1FC6-\\u1FD3\\u1FD6-\\u1FDB\\u1FDD-\\u1FEF\\u1FF2-\\u1FF4\\u1FF6-\\u1FFE\\u2126\\uAB65]|\\uD800[\\uDD40-\\uDD8E\\uDDA0]|\\uD834[\\uDE00-\\uDE45]"
* )
* },
* }
* },
* }
*/
[Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
}
/**
* The class to find a pattern in strings as handling escape sequences.
* It ignores the found pattern if it's escaped with `\`.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#patternmatcher-class}
*/
declare const PatternMatcher: new (pattern: RegExp, options?: {
escaped?: boolean | undefined;
} | undefined) => PatternMatcher;
export { PatternMatcher };
//# sourceMappingURL=PatternMatcher.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"PatternMatcher.d.ts","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/PatternMatcher.ts"],"names":[],"mappings":"AAEA,UAAU,cAAc;IACtB;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAExD;;;;OAIG;IACH,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAE3B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,CACd,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,GACjD,MAAM,CAAC;CACX;AAED;;;;;GAKG;AACH,QAAA,MAAM,cAAc,gBACJ,MAAM;;kBAAoC,cACzD,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}

View file

@ -0,0 +1,32 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatternMatcher = void 0;
const eslintUtils = __importStar(require("eslint-utils"));
/**
* The class to find a pattern in strings as handling escape sequences.
* It ignores the found pattern if it's escaped with `\`.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#patternmatcher-class}
*/
const PatternMatcher = eslintUtils.PatternMatcher;
exports.PatternMatcher = PatternMatcher;
//# sourceMappingURL=PatternMatcher.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"PatternMatcher.js","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/PatternMatcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AA6C5C;;;;;GAKG;AACH,MAAM,cAAc,GAAG,WAAW,CAAC,cAElC,CAAC;AAEO,wCAAc"}

View file

@ -0,0 +1,72 @@
import { TSESTree } from '../../ts-estree';
import * as TSESLint from '../../ts-eslint';
declare const ReferenceTrackerREAD: unique symbol;
declare const ReferenceTrackerCALL: unique symbol;
declare const ReferenceTrackerCONSTRUCT: unique symbol;
interface ReferenceTracker {
/**
* Iterate the references that the given `traceMap` determined.
* This method starts to search from global variables.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iterateglobalreferences}
*/
iterateGlobalReferences<T>(traceMap: ReferenceTracker.TraceMap<T>): IterableIterator<ReferenceTracker.FoundReference<T>>;
/**
* Iterate the references that the given `traceMap` determined.
* This method starts to search from `require()` expression.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iteratecjsreferences}
*/
iterateCjsReferences<T>(traceMap: ReferenceTracker.TraceMap<T>): IterableIterator<ReferenceTracker.FoundReference<T>>;
/**
* Iterate the references that the given `traceMap` determined.
* This method starts to search from `import`/`export` declarations.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#tracker-iterateesmreferences}
*/
iterateEsmReferences<T>(traceMap: ReferenceTracker.TraceMap<T>): IterableIterator<ReferenceTracker.FoundReference<T>>;
}
interface ReferenceTrackerStatic {
new (globalScope: TSESLint.Scope.Scope, options?: {
/**
* The mode which determines how the `tracker.iterateEsmReferences()` method scans CommonJS modules.
* If this is `"strict"`, the method binds CommonJS modules to the default export. Otherwise, the method binds
* CommonJS modules to both the default export and named exports. Optional. Default is `"strict"`.
*/
mode: 'strict' | 'legacy';
/**
* The name list of Global Object. Optional. Default is `["global", "globalThis", "self", "window"]`.
*/
globalObjectNames: readonly string[];
}): ReferenceTracker;
readonly READ: typeof ReferenceTrackerREAD;
readonly CALL: typeof ReferenceTrackerCALL;
readonly CONSTRUCT: typeof ReferenceTrackerCONSTRUCT;
}
declare namespace ReferenceTracker {
type READ = ReferenceTrackerStatic['READ'];
type CALL = ReferenceTrackerStatic['CALL'];
type CONSTRUCT = ReferenceTrackerStatic['CONSTRUCT'];
type ReferenceType = READ | CALL | CONSTRUCT;
type TraceMap<T = any> = Record<string, TraceMapElement<T>>;
interface TraceMapElement<T> {
[ReferenceTrackerREAD]?: T;
[ReferenceTrackerCALL]?: T;
[ReferenceTrackerCONSTRUCT]?: T;
[key: string]: TraceMapElement<T>;
}
interface FoundReference<T = any> {
node: TSESTree.Node;
path: readonly string[];
type: ReferenceType;
entry: T;
}
}
/**
* The tracker for references. This provides reference tracking for global variables, CommonJS modules, and ES modules.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#referencetracker-class}
*/
declare const ReferenceTracker: ReferenceTrackerStatic;
export { ReferenceTracker };
//# sourceMappingURL=ReferenceTracker.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"ReferenceTracker.d.ts","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/ReferenceTracker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,QAAA,MAAM,oBAAoB,EAAE,OAAO,MAA0C,CAAC;AAC9E,QAAA,MAAM,oBAAoB,EAAE,OAAO,MAA0C,CAAC;AAC9E,QAAA,MAAM,yBAAyB,EAAE,OAAO,MACA,CAAC;AAEzC,UAAU,gBAAgB;IACxB;;;;;OAKG;IACH,uBAAuB,CAAC,CAAC,EACvB,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,GACrC,gBAAgB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAExD;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,EACpB,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,GACrC,gBAAgB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAExD;;;;;OAKG;IACH,oBAAoB,CAAC,CAAC,EACpB,QAAQ,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,GACrC,gBAAgB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;CACzD;AACD,UAAU,sBAAsB;IAC9B,KACE,WAAW,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,EACjC,OAAO,CAAC,EAAE;QACR;;;;WAIG;QACH,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;QAC1B;;WAEG;QACH,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;KACtC,GACA,gBAAgB,CAAC;IAEpB,QAAQ,CAAC,IAAI,EAAE,OAAO,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,OAAO,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,SAAS,EAAE,OAAO,yBAAyB,CAAC;CACtD;AAED,kBAAU,gBAAgB,CAAC;IACzB,KAAY,IAAI,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAClD,KAAY,IAAI,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAClD,KAAY,SAAS,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC5D,KAAY,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;IAEpD,KAAY,QAAQ,CAAC,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,UAAiB,eAAe,CAAC,CAAC;QAChC,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3B,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3B,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC,CAAC;QAChC,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;KACnC;IAED,UAAiB,cAAc,CAAC,CAAC,GAAG,GAAG;QACrC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;QACpB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;QACxB,IAAI,EAAE,aAAa,CAAC;QACpB,KAAK,EAAE,CAAC,CAAC;KACV;CACF;AAED;;;;GAIG;AACH,QAAA,MAAM,gBAAgB,wBAAyD,CAAC;AAEhF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}

View file

@ -0,0 +1,35 @@
"use strict";
/* eslint-disable @typescript-eslint/no-namespace */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReferenceTracker = void 0;
const eslintUtils = __importStar(require("eslint-utils"));
const ReferenceTrackerREAD = eslintUtils.ReferenceTracker.READ;
const ReferenceTrackerCALL = eslintUtils.ReferenceTracker.CALL;
const ReferenceTrackerCONSTRUCT = eslintUtils.ReferenceTracker.CONSTRUCT;
/**
* The tracker for references. This provides reference tracking for global variables, CommonJS modules, and ES modules.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#referencetracker-class}
*/
const ReferenceTracker = eslintUtils.ReferenceTracker;
exports.ReferenceTracker = ReferenceTracker;
//# sourceMappingURL=ReferenceTracker.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"ReferenceTracker.js","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/ReferenceTracker.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;;;;;;;;;;;;;;;;;AAEpD,0DAA4C;AAI5C,MAAM,oBAAoB,GAAkB,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC;AAC9E,MAAM,oBAAoB,GAAkB,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC;AAC9E,MAAM,yBAAyB,GAC7B,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC;AA6EzC;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,WAAW,CAAC,gBAA0C,CAAC;AAEvE,4CAAgB"}

View file

@ -0,0 +1,82 @@
import { TSESTree } from '../../ts-estree';
import * as TSESLint from '../../ts-eslint';
/**
* Get the proper location of a given function node to report.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionheadlocation}
*/
declare const getFunctionHeadLocation: (node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression, sourceCode: TSESLint.SourceCode) => TSESTree.SourceLocation;
/**
* Get the name and kind of a given function node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionnamewithkind}
*/
declare const getFunctionNameWithKind: (node: TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression) => string;
/**
* Get the property name of a given property node.
* If the node is a computed property, this tries to compute the property name by the getStringIfConstant function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getpropertyname}
* @returns The property name of the node. If the property name is not constant then it returns `null`.
*/
declare const getPropertyName: (node: TSESTree.MemberExpression | TSESTree.OptionalMemberExpression | TSESTree.Property | TSESTree.MethodDefinition, initialScope?: TSESLint.Scope.Scope | undefined) => string | null;
/**
* Get the value of a given node if it can decide the value statically.
* If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
* given node as much as possible. In the resolving way, it does on the assumption that built-in global objects have
* not been modified.
* For example, it considers `Symbol.iterator`, ` String.raw``hello`` `, and `Object.freeze({a: 1}).a` as static.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstaticvalue}
* @returns The `{ value: any }` shaped object. The `value` property is the static value. If it couldn't compute the
* static value of the node, it returns `null`.
*/
declare const getStaticValue: (node: TSESTree.Node, initialScope?: TSESLint.Scope.Scope | undefined) => {
value: unknown;
} | null;
/**
* Get the string value of a given node.
* This function is a tiny wrapper of the getStaticValue function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstringifconstant}
*/
declare const getStringIfConstant: (node: TSESTree.Node, initialScope?: TSESLint.Scope.Scope | undefined) => string | null;
/**
* Check whether a given node has any side effect or not.
* The side effect means that it may modify a certain variable or object member. This function considers the node which
* contains the following types as the node which has side effects:
* - `AssignmentExpression`
* - `AwaitExpression`
* - `CallExpression`
* - `ImportExpression`
* - `NewExpression`
* - `UnaryExpression([operator = "delete"])`
* - `UpdateExpression`
* - `YieldExpression`
* - When `options.considerGetters` is `true`:
* - `MemberExpression`
* - When `options.considerImplicitTypeConversion` is `true`:
* - `BinaryExpression([operator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in"])`
* - `MemberExpression([computed = true])`
* - `MethodDefinition([computed = true])`
* - `Property([computed = true])`
* - `UnaryExpression([operator = "-" | "+" | "!" | "~"])`
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#hassideeffect}
*/
declare const hasSideEffect: (node: TSESTree.Node, sourceCode: TSESLint.SourceCode, options?: {
considerGetters?: boolean | undefined;
considerImplicitTypeConversion?: boolean | undefined;
} | undefined) => boolean;
/**
* Check whether a given node is parenthesized or not.
* This function detects it correctly even if it's parenthesized by specific syntax.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#isparenthesized}
* @returns `true` if the node is parenthesized.
* If `times` was given, it returns `true` only if the node is parenthesized the `times` times.
* For example, `isParenthesized(2, node, sourceCode)` returns true for `((foo))`, but not for `(foo)`.
*/
declare const isParenthesized: (node: TSESTree.Node, sourceCode: TSESLint.SourceCode) => boolean;
export { getFunctionHeadLocation, getFunctionNameWithKind, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isParenthesized, };
//# sourceMappingURL=astUtilities.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"astUtilities.d.ts","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/astUtilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,QAAA,MAAM,uBAAuB,SAEvB,SAAS,mBAAmB,GAC5B,SAAS,kBAAkB,GAC3B,SAAS,uBAAuB,cACxB,SAAS,UAAU,KAC5B,SAAS,cAAc,CAAC;AAE7B;;;;GAIG;AACH,QAAA,MAAM,uBAAuB,SAEvB,SAAS,mBAAmB,GAC5B,SAAS,kBAAkB,GAC3B,SAAS,uBAAuB,KACjC,MAAM,CAAC;AAEZ;;;;;;GAMG;AACH,QAAA,MAAM,eAAe,SAEf,SAAS,gBAAgB,GACzB,SAAS,wBAAwB,GACjC,SAAS,QAAQ,GACjB,SAAS,gBAAgB,sDAE1B,MAAM,GAAG,IAAI,CAAC;AAEnB;;;;;;;;;;GAUG;AACH,QAAA,MAAM,cAAc,SACZ,SAAS,IAAI,sDAEhB;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE/B;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB,SACjB,SAAS,IAAI,sDAEhB,MAAM,GAAG,IAAI,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,QAAA,MAAM,aAAa,SACX,SAAS,IAAI,cACP,SAAS,UAAU;;;kBAK5B,OAAO,CAAC;AAEb;;;;;;;;GAQG;AACH,QAAA,MAAM,eAAe,SACb,SAAS,IAAI,cACP,SAAS,UAAU,KAC5B,OAAO,CAAC;AAEb,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,eAAe,GAChB,CAAC"}

View file

@ -0,0 +1,104 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isParenthesized = exports.hasSideEffect = exports.getStringIfConstant = exports.getStaticValue = exports.getPropertyName = exports.getFunctionNameWithKind = exports.getFunctionHeadLocation = void 0;
const eslintUtils = __importStar(require("eslint-utils"));
/**
* Get the proper location of a given function node to report.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionheadlocation}
*/
const getFunctionHeadLocation = eslintUtils.getFunctionHeadLocation;
exports.getFunctionHeadLocation = getFunctionHeadLocation;
/**
* Get the name and kind of a given function node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getfunctionnamewithkind}
*/
const getFunctionNameWithKind = eslintUtils.getFunctionNameWithKind;
exports.getFunctionNameWithKind = getFunctionNameWithKind;
/**
* Get the property name of a given property node.
* If the node is a computed property, this tries to compute the property name by the getStringIfConstant function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getpropertyname}
* @returns The property name of the node. If the property name is not constant then it returns `null`.
*/
const getPropertyName = eslintUtils.getPropertyName;
exports.getPropertyName = getPropertyName;
/**
* Get the value of a given node if it can decide the value statically.
* If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
* given node as much as possible. In the resolving way, it does on the assumption that built-in global objects have
* not been modified.
* For example, it considers `Symbol.iterator`, ` String.raw``hello`` `, and `Object.freeze({a: 1}).a` as static.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstaticvalue}
* @returns The `{ value: any }` shaped object. The `value` property is the static value. If it couldn't compute the
* static value of the node, it returns `null`.
*/
const getStaticValue = eslintUtils.getStaticValue;
exports.getStaticValue = getStaticValue;
/**
* Get the string value of a given node.
* This function is a tiny wrapper of the getStaticValue function.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstringifconstant}
*/
const getStringIfConstant = eslintUtils.getStringIfConstant;
exports.getStringIfConstant = getStringIfConstant;
/**
* Check whether a given node has any side effect or not.
* The side effect means that it may modify a certain variable or object member. This function considers the node which
* contains the following types as the node which has side effects:
* - `AssignmentExpression`
* - `AwaitExpression`
* - `CallExpression`
* - `ImportExpression`
* - `NewExpression`
* - `UnaryExpression([operator = "delete"])`
* - `UpdateExpression`
* - `YieldExpression`
* - When `options.considerGetters` is `true`:
* - `MemberExpression`
* - When `options.considerImplicitTypeConversion` is `true`:
* - `BinaryExpression([operator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "<<" | ">>" | ">>>" | "+" | "-" | "*" | "/" | "%" | "|" | "^" | "&" | "in"])`
* - `MemberExpression([computed = true])`
* - `MethodDefinition([computed = true])`
* - `Property([computed = true])`
* - `UnaryExpression([operator = "-" | "+" | "!" | "~"])`
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#hassideeffect}
*/
const hasSideEffect = eslintUtils.hasSideEffect;
exports.hasSideEffect = hasSideEffect;
/**
* Check whether a given node is parenthesized or not.
* This function detects it correctly even if it's parenthesized by specific syntax.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/ast-utils.html#isparenthesized}
* @returns `true` if the node is parenthesized.
* If `times` was given, it returns `true` only if the node is parenthesized the `times` times.
* For example, `isParenthesized(2, node, sourceCode)` returns true for `((foo))`, but not for `(foo)`.
*/
const isParenthesized = eslintUtils.isParenthesized;
exports.isParenthesized = isParenthesized;
//# sourceMappingURL=astUtilities.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"astUtilities.js","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/astUtilities.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAI5C;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,WAAW,CAAC,uBAMhB,CAAC;AAwG3B,0DAAuB;AAtGzB;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,WAAW,CAAC,uBAKjC,CAAC;AA6FV,0DAAuB;AA3FzB;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,WAAW,CAAC,eAOlB,CAAC;AA8EjB,0CAAe;AA5EjB;;;;;;;;;;GAUG;AACH,MAAM,cAAc,GAAG,WAAW,CAAC,cAGL,CAAC;AA+D7B,wCAAc;AA7DhB;;;;;GAKG;AACH,MAAM,mBAAmB,GAAG,WAAW,CAAC,mBAGtB,CAAC;AAqDjB,kDAAmB;AAnDrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,aAAa,GAAG,WAAW,CAAC,aAOtB,CAAC;AAsBX,sCAAa;AApBf;;;;;;;;GAQG;AACH,MAAM,eAAe,GAAG,WAAW,CAAC,eAGxB,CAAC;AASX,0CAAe"}

View file

@ -0,0 +1,6 @@
export * from './astUtilities';
export * from './PatternMatcher';
export * from './predicates';
export * from './ReferenceTracker';
export * from './scopeAnalysis';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}

View file

@ -0,0 +1,18 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./astUtilities"), exports);
__exportStar(require("./PatternMatcher"), exports);
__exportStar(require("./predicates"), exports);
__exportStar(require("./ReferenceTracker"), exports);
__exportStar(require("./scopeAnalysis"), exports);
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,mDAAiC;AACjC,+CAA6B;AAC7B,qDAAmC;AACnC,kDAAgC"}

View file

@ -0,0 +1,45 @@
import { TSESTree } from '../../ts-estree';
declare const isArrowToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '=>';
};
declare const isNotArrowToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isClosingBraceToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '}';
};
declare const isNotClosingBraceToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isClosingBracketToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ']';
};
declare const isNotClosingBracketToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isClosingParenToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ')';
};
declare const isNotClosingParenToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isColonToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ':';
};
declare const isNotColonToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isCommaToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ',';
};
declare const isNotCommaToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isCommentToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.Comment;
declare const isNotCommentToken: <T extends TSESTree.Token>(token: T) => token is Exclude<T, TSESTree.Comment>;
declare const isOpeningBraceToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '{';
};
declare const isNotOpeningBraceToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isOpeningBracketToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '[';
};
declare const isNotOpeningBracketToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isOpeningParenToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: '(';
};
declare const isNotOpeningParenToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
declare const isSemicolonToken: (token: TSESTree.Token | TSESTree.Comment) => token is TSESTree.PunctuatorToken & {
value: ';';
};
declare const isNotSemicolonToken: (token: TSESTree.Token | TSESTree.Comment) => boolean;
export { isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isSemicolonToken, };
//# sourceMappingURL=predicates.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/predicates.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,QAAA,MAAM,YAAY,UACT,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,IAAI;CAAE,CAAC;AACzD,QAAA,MAAM,eAAe,UACZ,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,mBAAmB,UAChB,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,sBAAsB,UACnB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,qBAAqB,UAClB,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,wBAAwB,UACrB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,mBAAmB,UAChB,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,sBAAsB,UACnB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,YAAY,UACT,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,eAAe,UACZ,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,YAAY,UACT,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,eAAe,UACZ,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,cAAc,UACX,SAAS,KAAK,GAAG,SAAS,OAAO,8BACZ,CAAC;AAC/B,QAAA,MAAM,iBAAiB,+EAImB,CAAC;AAE3C,QAAA,MAAM,mBAAmB,UAChB,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,sBAAsB,UACnB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,qBAAqB,UAClB,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,wBAAwB,UACrB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,mBAAmB,UAChB,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,sBAAsB,UACnB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,QAAA,MAAM,gBAAgB,UACb,SAAS,KAAK,GAAG,SAAS,OAAO;WACQ,GAAG;CAAE,CAAC;AACxD,QAAA,MAAM,mBAAmB,UAChB,SAAS,KAAK,GAAG,SAAS,OAAO,KACrC,OAAO,CAAC;AAEb,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,CAAC"}

View file

@ -0,0 +1,68 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSemicolonToken = exports.isOpeningParenToken = exports.isOpeningBracketToken = exports.isOpeningBraceToken = exports.isNotSemicolonToken = exports.isNotOpeningParenToken = exports.isNotOpeningBracketToken = exports.isNotOpeningBraceToken = exports.isNotCommentToken = exports.isNotCommaToken = exports.isNotColonToken = exports.isNotClosingParenToken = exports.isNotClosingBracketToken = exports.isNotClosingBraceToken = exports.isNotArrowToken = exports.isCommentToken = exports.isCommaToken = exports.isColonToken = exports.isClosingParenToken = exports.isClosingBracketToken = exports.isClosingBraceToken = exports.isArrowToken = void 0;
const eslintUtils = __importStar(require("eslint-utils"));
const isArrowToken = eslintUtils.isArrowToken;
exports.isArrowToken = isArrowToken;
const isNotArrowToken = eslintUtils.isNotArrowToken;
exports.isNotArrowToken = isNotArrowToken;
const isClosingBraceToken = eslintUtils.isClosingBraceToken;
exports.isClosingBraceToken = isClosingBraceToken;
const isNotClosingBraceToken = eslintUtils.isNotClosingBraceToken;
exports.isNotClosingBraceToken = isNotClosingBraceToken;
const isClosingBracketToken = eslintUtils.isClosingBracketToken;
exports.isClosingBracketToken = isClosingBracketToken;
const isNotClosingBracketToken = eslintUtils.isNotClosingBracketToken;
exports.isNotClosingBracketToken = isNotClosingBracketToken;
const isClosingParenToken = eslintUtils.isClosingParenToken;
exports.isClosingParenToken = isClosingParenToken;
const isNotClosingParenToken = eslintUtils.isNotClosingParenToken;
exports.isNotClosingParenToken = isNotClosingParenToken;
const isColonToken = eslintUtils.isColonToken;
exports.isColonToken = isColonToken;
const isNotColonToken = eslintUtils.isNotColonToken;
exports.isNotColonToken = isNotColonToken;
const isCommaToken = eslintUtils.isCommaToken;
exports.isCommaToken = isCommaToken;
const isNotCommaToken = eslintUtils.isNotCommaToken;
exports.isNotCommaToken = isNotCommaToken;
const isCommentToken = eslintUtils.isCommentToken;
exports.isCommentToken = isCommentToken;
const isNotCommentToken = eslintUtils.isNotCommentToken;
exports.isNotCommentToken = isNotCommentToken;
const isOpeningBraceToken = eslintUtils.isOpeningBraceToken;
exports.isOpeningBraceToken = isOpeningBraceToken;
const isNotOpeningBraceToken = eslintUtils.isNotOpeningBraceToken;
exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
const isOpeningBracketToken = eslintUtils.isOpeningBracketToken;
exports.isOpeningBracketToken = isOpeningBracketToken;
const isNotOpeningBracketToken = eslintUtils.isNotOpeningBracketToken;
exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
const isOpeningParenToken = eslintUtils.isOpeningParenToken;
exports.isOpeningParenToken = isOpeningParenToken;
const isNotOpeningParenToken = eslintUtils.isNotOpeningParenToken;
exports.isNotOpeningParenToken = isNotOpeningParenToken;
const isSemicolonToken = eslintUtils.isSemicolonToken;
exports.isSemicolonToken = isSemicolonToken;
const isNotSemicolonToken = eslintUtils.isNotSemicolonToken;
exports.isNotSemicolonToken = isNotSemicolonToken;
//# sourceMappingURL=predicates.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/predicates.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAG5C,MAAM,YAAY,GAAG,WAAW,CAAC,YAEuB,CAAC;AA8EvD,oCAAY;AA7Ed,MAAM,eAAe,GAAG,WAAW,CAAC,eAExB,CAAC;AAkFX,0CAAe;AAhFjB,MAAM,mBAAmB,GAAG,WAAW,CAAC,mBAEe,CAAC;AAwEtD,kDAAmB;AAvErB,MAAM,sBAAsB,GAAG,WAAW,CAAC,sBAE/B,CAAC;AA4EX,wDAAsB;AA1ExB,MAAM,qBAAqB,GAAG,WAAW,CAAC,qBAEa,CAAC;AAkEtD,sDAAqB;AAjEvB,MAAM,wBAAwB,GAAG,WAAW,CAAC,wBAEjC,CAAC;AAsEX,4DAAwB;AApE1B,MAAM,mBAAmB,GAAG,WAAW,CAAC,mBAEe,CAAC;AA4DtD,kDAAmB;AA3DrB,MAAM,sBAAsB,GAAG,WAAW,CAAC,sBAE/B,CAAC;AAgEX,wDAAsB;AA9DxB,MAAM,YAAY,GAAG,WAAW,CAAC,YAEsB,CAAC;AAsDtD,oCAAY;AArDd,MAAM,eAAe,GAAG,WAAW,CAAC,eAExB,CAAC;AA0DX,0CAAe;AAxDjB,MAAM,YAAY,GAAG,WAAW,CAAC,YAEsB,CAAC;AAgDtD,oCAAY;AA/Cd,MAAM,eAAe,GAAG,WAAW,CAAC,eAExB,CAAC;AAoDX,0CAAe;AAlDjB,MAAM,cAAc,GAAG,WAAW,CAAC,cAEL,CAAC;AA0C7B,wCAAc;AAzChB,MAAM,iBAAiB,GAAG,WAAW,CAAC,iBAII,CAAC;AA4CzC,8CAAiB;AA1CnB,MAAM,mBAAmB,GAAG,WAAW,CAAC,mBAEe,CAAC;AA6CtD,kDAAmB;AA5CrB,MAAM,sBAAsB,GAAG,WAAW,CAAC,sBAE/B,CAAC;AAsCX,wDAAsB;AApCxB,MAAM,qBAAqB,GAAG,WAAW,CAAC,qBAEa,CAAC;AAuCtD,sDAAqB;AAtCvB,MAAM,wBAAwB,GAAG,WAAW,CAAC,wBAEjC,CAAC;AAgCX,4DAAwB;AA9B1B,MAAM,mBAAmB,GAAG,WAAW,CAAC,mBAEe,CAAC;AAiCtD,kDAAmB;AAhCrB,MAAM,sBAAsB,GAAG,WAAW,CAAC,sBAE/B,CAAC;AA0BX,wDAAsB;AAxBxB,MAAM,gBAAgB,GAAG,WAAW,CAAC,gBAEkB,CAAC;AA2BtD,4CAAgB;AA1BlB,MAAM,mBAAmB,GAAG,WAAW,CAAC,mBAE5B,CAAC;AAoBX,kDAAmB"}

View file

@ -0,0 +1,18 @@
import { TSESTree } from '../../ts-estree';
import * as TSESLint from '../../ts-eslint';
/**
* Get the variable of a given name.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#findvariable}
*/
declare const findVariable: (initialScope: TSESLint.Scope.Scope, name: string) => TSESLint.Scope.Variable | null;
/**
* Get the innermost scope which contains a given node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#getinnermostscope}
* @returns The innermost scope which contains the given node.
* If such scope doesn't exist then it returns the 1st argument `initialScope`.
*/
declare const getInnermostScope: (initialScope: TSESLint.Scope.Scope, node: TSESTree.Node) => TSESLint.Scope.Scope;
export { findVariable, getInnermostScope };
//# sourceMappingURL=scopeAnalysis.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"scopeAnalysis.d.ts","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/scopeAnalysis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,QAAA,MAAM,YAAY,iBACF,SAAS,KAAK,CAAC,KAAK,QAC5B,MAAM,KACT,SAAS,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;AAEpC;;;;;;GAMG;AACH,QAAA,MAAM,iBAAiB,iBACP,SAAS,KAAK,CAAC,KAAK,QAC5B,SAAS,IAAI,KAChB,SAAS,KAAK,CAAC,KAAK,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}

View file

@ -0,0 +1,40 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInnermostScope = exports.findVariable = void 0;
const eslintUtils = __importStar(require("eslint-utils"));
/**
* Get the variable of a given name.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#findvariable}
*/
const findVariable = eslintUtils.findVariable;
exports.findVariable = findVariable;
/**
* Get the innermost scope which contains a given node.
*
* @see {@link https://eslint-utils.mysticatea.dev/api/scope-utils.html#getinnermostscope}
* @returns The innermost scope which contains the given node.
* If such scope doesn't exist then it returns the 1st argument `initialScope`.
*/
const getInnermostScope = eslintUtils.getInnermostScope;
exports.getInnermostScope = getInnermostScope;
//# sourceMappingURL=scopeAnalysis.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"scopeAnalysis.js","sourceRoot":"","sources":["../../../src/ast-utils/eslint-utils/scopeAnalysis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA4C;AAI5C;;;;GAIG;AACH,MAAM,YAAY,GAAG,WAAW,CAAC,YAGE,CAAC;AAc3B,oCAAY;AAZrB;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,WAAW,CAAC,iBAGb,CAAC;AAEH,8CAAiB"}

View file

@ -0,0 +1,4 @@
export * from './misc';
export * from './predicates';
export * from './eslint-utils';
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}

View file

@ -0,0 +1,16 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./misc"), exports);
__exportStar(require("./predicates"), exports);
__exportStar(require("./eslint-utils"), exports);
//# sourceMappingURL=index.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ast-utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,+CAA6B;AAC7B,iDAA+B"}

View file

@ -0,0 +1,8 @@
import { TSESTree } from '../ts-estree';
declare const LINEBREAK_MATCHER: RegExp;
/**
* Determines whether two adjacent tokens are on the same line
*/
declare function isTokenOnSameLine(left: TSESTree.Token | TSESTree.Comment, right: TSESTree.Token | TSESTree.Comment): boolean;
export { isTokenOnSameLine, LINEBREAK_MATCHER };
//# sourceMappingURL=misc.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/ast-utils/misc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,QAAA,MAAM,iBAAiB,QAA4B,CAAC;AAEpD;;GAEG;AACH,iBAAS,iBAAiB,CACxB,IAAI,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,EACvC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,GACvC,OAAO,CAET;AAED,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,CAAC"}

View file

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LINEBREAK_MATCHER = exports.isTokenOnSameLine = void 0;
const LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/;
exports.LINEBREAK_MATCHER = LINEBREAK_MATCHER;
/**
* Determines whether two adjacent tokens are on the same line
*/
function isTokenOnSameLine(left, right) {
return left.loc.end.line === right.loc.start.line;
}
exports.isTokenOnSameLine = isTokenOnSameLine;
//# sourceMappingURL=misc.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/ast-utils/misc.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAYxB,8CAAiB;AAV7C;;GAEG;AACH,SAAS,iBAAiB,CACxB,IAAuC,EACvC,KAAwC;IAExC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;AACpD,CAAC;AAEQ,8CAAiB"}

View file

@ -0,0 +1,58 @@
import { TSESTree } from '../ts-estree';
declare function isOptionalChainPunctuator(token: TSESTree.Token | TSESTree.Comment): token is TSESTree.PunctuatorToken & {
value: '?.';
};
declare function isNotOptionalChainPunctuator(token: TSESTree.Token | TSESTree.Comment): boolean;
declare function isNonNullAssertionPunctuator(token: TSESTree.Token | TSESTree.Comment): token is TSESTree.PunctuatorToken & {
value: '!';
};
declare function isNotNonNullAssertionPunctuator(token: TSESTree.Token | TSESTree.Comment): boolean;
/**
* Returns true if and only if the node represents: foo?.() or foo.bar?.()
*/
declare function isOptionalOptionalCallExpression(node: TSESTree.Node): node is TSESTree.OptionalCallExpression & {
optional: true;
};
/**
* Returns true if and only if the node represents logical OR
*/
declare function isLogicalOrOperator(node: TSESTree.Node): node is TSESTree.LogicalExpression & {
operator: '||';
};
/**
* Checks if a node is a type assertion:
* ```
* x as foo
* <foo>x
* ```
*/
declare function isTypeAssertion(node: TSESTree.Node | undefined | null): node is TSESTree.TSAsExpression | TSESTree.TSTypeAssertion;
declare function isVariableDeclarator(node: TSESTree.Node | undefined): node is TSESTree.VariableDeclarator;
declare function isFunction(node: TSESTree.Node | undefined): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression;
declare function isFunctionType(node: TSESTree.Node | undefined): node is TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature;
declare function isFunctionOrFunctionType(node: TSESTree.Node | undefined): node is TSESTree.ArrowFunctionExpression | TSESTree.FunctionDeclaration | TSESTree.FunctionExpression | TSESTree.TSCallSignatureDeclaration | TSESTree.TSConstructorType | TSESTree.TSConstructSignatureDeclaration | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.TSFunctionType | TSESTree.TSMethodSignature;
declare function isTSFunctionType(node: TSESTree.Node | undefined): node is TSESTree.TSFunctionType;
declare function isTSConstructorType(node: TSESTree.Node | undefined): node is TSESTree.TSConstructorType;
declare function isClassOrTypeElement(node: TSESTree.Node | undefined): node is TSESTree.ClassElement | TSESTree.TypeElement;
/**
* Checks if a node is a constructor method.
*/
declare function isConstructor(node: TSESTree.Node | undefined): node is TSESTree.MethodDefinition;
/**
* Checks if a node is a setter method.
*/
declare function isSetter(node: TSESTree.Node | undefined): node is TSESTree.MethodDefinition | TSESTree.Property;
declare function isIdentifier(node: TSESTree.Node | undefined): node is TSESTree.Identifier;
/**
* Checks if a node represents an `await …` expression.
*/
declare function isAwaitExpression(node: TSESTree.Node | undefined | null): node is TSESTree.AwaitExpression;
/**
* Checks if a possible token is the `await` keyword.
*/
declare function isAwaitKeyword(node: TSESTree.Token | TSESTree.Comment | undefined | null): node is TSESTree.KeywordToken & {
value: 'await';
};
declare function isMemberOrOptionalMemberExpression(node: TSESTree.Node): node is TSESTree.MemberExpression | TSESTree.OptionalMemberExpression;
export { isAwaitExpression, isAwaitKeyword, isConstructor, isClassOrTypeElement, isFunction, isFunctionOrFunctionType, isFunctionType, isIdentifier, isLogicalOrOperator, isMemberOrOptionalMemberExpression, isNonNullAssertionPunctuator, isNotNonNullAssertionPunctuator, isNotOptionalChainPunctuator, isOptionalChainPunctuator, isOptionalOptionalCallExpression, isSetter, isTSConstructorType, isTSFunctionType, isTypeAssertion, isVariableDeclarator, };
//# sourceMappingURL=predicates.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"predicates.d.ts","sourceRoot":"","sources":["../../src/ast-utils/predicates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEzE,iBAAS,yBAAyB,CAChC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,GACvC,KAAK,IAAI,QAAQ,CAAC,eAAe,GAAG;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,CAErD;AACD,iBAAS,4BAA4B,CACnC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,GACvC,OAAO,CAET;AAED,iBAAS,4BAA4B,CACnC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,GACvC,KAAK,IAAI,QAAQ,CAAC,eAAe,GAAG;IAAE,KAAK,EAAE,GAAG,CAAA;CAAE,CAEpD;AACD,iBAAS,+BAA+B,CACtC,KAAK,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,GACvC,OAAO,CAET;AAED;;GAEG;AACH,iBAAS,gCAAgC,CACvC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,QAAQ,CAAC,sBAAsB,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,CAO9D;AAED;;GAEG;AACH,iBAAS,mBAAmB,CAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,QAAQ,CAAC,iBAAiB,GAAG;IAAE,QAAQ,EAAE,IAAI,CAAA;CAAE,CAIzD;AAED;;;;;;GAMG;AACH,iBAAS,eAAe,CACtB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,IAAI,GACrC,IAAI,IAAI,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,eAAe,CAQ5D;AAED,iBAAS,oBAAoB,CAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,kBAAkB,CAErC;AAED,iBAAS,UAAU,CACjB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IACH,QAAQ,CAAC,uBAAuB,GAChC,QAAQ,CAAC,mBAAmB,GAC5B,QAAQ,CAAC,kBAAkB,CAU9B;AAED,iBAAS,cAAc,CACrB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IACH,QAAQ,CAAC,0BAA0B,GACnC,QAAQ,CAAC,iBAAiB,GAC1B,QAAQ,CAAC,+BAA+B,GACxC,QAAQ,CAAC,6BAA6B,GACtC,QAAQ,CAAC,cAAc,GACvB,QAAQ,CAAC,iBAAiB,CAa7B;AAED,iBAAS,wBAAwB,CAC/B,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IACH,QAAQ,CAAC,uBAAuB,GAChC,QAAQ,CAAC,mBAAmB,GAC5B,QAAQ,CAAC,kBAAkB,GAC3B,QAAQ,CAAC,0BAA0B,GACnC,QAAQ,CAAC,iBAAiB,GAC1B,QAAQ,CAAC,+BAA+B,GACxC,QAAQ,CAAC,6BAA6B,GACtC,QAAQ,CAAC,cAAc,GACvB,QAAQ,CAAC,iBAAiB,CAE7B;AAED,iBAAS,gBAAgB,CACvB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,cAAc,CAEjC;AAED,iBAAS,mBAAmB,CAC1B,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAEpC;AAED,iBAAS,oBAAoB,CAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,WAAW,CAqBtD;AAED;;GAEG;AACH,iBAAS,aAAa,CACpB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAKnC;AAED;;GAEG;AACH,iBAAS,QAAQ,CACf,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAOvD;AAED,iBAAS,YAAY,CACnB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAC9B,IAAI,IAAI,QAAQ,CAAC,UAAU,CAE7B;AAED;;GAEG;AACH,iBAAS,iBAAiB,CACxB,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,IAAI,GACrC,IAAI,IAAI,QAAQ,CAAC,eAAe,CAElC;AAED;;GAEG;AACH,iBAAS,cAAc,CACrB,IAAI,EAAE,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,OAAO,GAAG,SAAS,GAAG,IAAI,GACzD,IAAI,IAAI,QAAQ,CAAC,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAEpD;AAED,iBAAS,kCAAkC,CACzC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAClB,IAAI,IAAI,QAAQ,CAAC,gBAAgB,GAAG,QAAQ,CAAC,wBAAwB,CAKvE;AAED,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,UAAU,EACV,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,kCAAkC,EAClC,4BAA4B,EAC5B,+BAA+B,EAC/B,4BAA4B,EAC5B,yBAAyB,EACzB,gCAAgC,EAChC,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,CAAC"}

View file

@ -0,0 +1,157 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isVariableDeclarator = exports.isTypeAssertion = exports.isTSFunctionType = exports.isTSConstructorType = exports.isSetter = exports.isOptionalOptionalCallExpression = exports.isOptionalChainPunctuator = exports.isNotOptionalChainPunctuator = exports.isNotNonNullAssertionPunctuator = exports.isNonNullAssertionPunctuator = exports.isMemberOrOptionalMemberExpression = exports.isLogicalOrOperator = exports.isIdentifier = exports.isFunctionType = exports.isFunctionOrFunctionType = exports.isFunction = exports.isClassOrTypeElement = exports.isConstructor = exports.isAwaitKeyword = exports.isAwaitExpression = void 0;
const ts_estree_1 = require("../ts-estree");
function isOptionalChainPunctuator(token) {
return token.type === ts_estree_1.AST_TOKEN_TYPES.Punctuator && token.value === '?.';
}
exports.isOptionalChainPunctuator = isOptionalChainPunctuator;
function isNotOptionalChainPunctuator(token) {
return !isOptionalChainPunctuator(token);
}
exports.isNotOptionalChainPunctuator = isNotOptionalChainPunctuator;
function isNonNullAssertionPunctuator(token) {
return token.type === ts_estree_1.AST_TOKEN_TYPES.Punctuator && token.value === '!';
}
exports.isNonNullAssertionPunctuator = isNonNullAssertionPunctuator;
function isNotNonNullAssertionPunctuator(token) {
return !isNonNullAssertionPunctuator(token);
}
exports.isNotNonNullAssertionPunctuator = isNotNonNullAssertionPunctuator;
/**
* Returns true if and only if the node represents: foo?.() or foo.bar?.()
*/
function isOptionalOptionalCallExpression(node) {
return (node.type === ts_estree_1.AST_NODE_TYPES.OptionalCallExpression &&
// this flag means the call expression itself is option
// i.e. it is foo.bar?.() and not foo?.bar()
node.optional);
}
exports.isOptionalOptionalCallExpression = isOptionalOptionalCallExpression;
/**
* Returns true if and only if the node represents logical OR
*/
function isLogicalOrOperator(node) {
return (node.type === ts_estree_1.AST_NODE_TYPES.LogicalExpression && node.operator === '||');
}
exports.isLogicalOrOperator = isLogicalOrOperator;
/**
* Checks if a node is a type assertion:
* ```
* x as foo
* <foo>x
* ```
*/
function isTypeAssertion(node) {
if (!node) {
return false;
}
return (node.type === ts_estree_1.AST_NODE_TYPES.TSAsExpression ||
node.type === ts_estree_1.AST_NODE_TYPES.TSTypeAssertion);
}
exports.isTypeAssertion = isTypeAssertion;
function isVariableDeclarator(node) {
return (node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_NODE_TYPES.VariableDeclarator;
}
exports.isVariableDeclarator = isVariableDeclarator;
function isFunction(node) {
if (!node) {
return false;
}
return [
ts_estree_1.AST_NODE_TYPES.ArrowFunctionExpression,
ts_estree_1.AST_NODE_TYPES.FunctionDeclaration,
ts_estree_1.AST_NODE_TYPES.FunctionExpression,
].includes(node.type);
}
exports.isFunction = isFunction;
function isFunctionType(node) {
if (!node) {
return false;
}
return [
ts_estree_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
ts_estree_1.AST_NODE_TYPES.TSConstructorType,
ts_estree_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
ts_estree_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
ts_estree_1.AST_NODE_TYPES.TSFunctionType,
ts_estree_1.AST_NODE_TYPES.TSMethodSignature,
].includes(node.type);
}
exports.isFunctionType = isFunctionType;
function isFunctionOrFunctionType(node) {
return isFunction(node) || isFunctionType(node);
}
exports.isFunctionOrFunctionType = isFunctionOrFunctionType;
function isTSFunctionType(node) {
return (node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_NODE_TYPES.TSFunctionType;
}
exports.isTSFunctionType = isTSFunctionType;
function isTSConstructorType(node) {
return (node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_NODE_TYPES.TSConstructorType;
}
exports.isTSConstructorType = isTSConstructorType;
function isClassOrTypeElement(node) {
if (!node) {
return false;
}
return [
// ClassElement
ts_estree_1.AST_NODE_TYPES.ClassProperty,
ts_estree_1.AST_NODE_TYPES.FunctionExpression,
ts_estree_1.AST_NODE_TYPES.MethodDefinition,
ts_estree_1.AST_NODE_TYPES.TSAbstractClassProperty,
ts_estree_1.AST_NODE_TYPES.TSAbstractMethodDefinition,
ts_estree_1.AST_NODE_TYPES.TSEmptyBodyFunctionExpression,
ts_estree_1.AST_NODE_TYPES.TSIndexSignature,
// TypeElement
ts_estree_1.AST_NODE_TYPES.TSCallSignatureDeclaration,
ts_estree_1.AST_NODE_TYPES.TSConstructSignatureDeclaration,
// AST_NODE_TYPES.TSIndexSignature,
ts_estree_1.AST_NODE_TYPES.TSMethodSignature,
ts_estree_1.AST_NODE_TYPES.TSPropertySignature,
].includes(node.type);
}
exports.isClassOrTypeElement = isClassOrTypeElement;
/**
* Checks if a node is a constructor method.
*/
function isConstructor(node) {
return ((node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_NODE_TYPES.MethodDefinition &&
node.kind === 'constructor');
}
exports.isConstructor = isConstructor;
/**
* Checks if a node is a setter method.
*/
function isSetter(node) {
return (!!node &&
(node.type === ts_estree_1.AST_NODE_TYPES.MethodDefinition ||
node.type === ts_estree_1.AST_NODE_TYPES.Property) &&
node.kind === 'set');
}
exports.isSetter = isSetter;
function isIdentifier(node) {
return (node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_NODE_TYPES.Identifier;
}
exports.isIdentifier = isIdentifier;
/**
* Checks if a node represents an `await …` expression.
*/
function isAwaitExpression(node) {
return (node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_NODE_TYPES.AwaitExpression;
}
exports.isAwaitExpression = isAwaitExpression;
/**
* Checks if a possible token is the `await` keyword.
*/
function isAwaitKeyword(node) {
return (node === null || node === void 0 ? void 0 : node.type) === ts_estree_1.AST_TOKEN_TYPES.Identifier && node.value === 'await';
}
exports.isAwaitKeyword = isAwaitKeyword;
function isMemberOrOptionalMemberExpression(node) {
return (node.type === ts_estree_1.AST_NODE_TYPES.MemberExpression ||
node.type === ts_estree_1.AST_NODE_TYPES.OptionalMemberExpression);
}
exports.isMemberOrOptionalMemberExpression = isMemberOrOptionalMemberExpression;
//# sourceMappingURL=predicates.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"predicates.js","sourceRoot":"","sources":["../../src/ast-utils/predicates.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AAEzE,SAAS,yBAAyB,CAChC,KAAwC;IAExC,OAAO,KAAK,CAAC,IAAI,KAAK,2BAAe,CAAC,UAAU,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;AAC3E,CAAC;AAyOC,8DAAyB;AAxO3B,SAAS,4BAA4B,CACnC,KAAwC;IAExC,OAAO,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAmOC,oEAA4B;AAjO9B,SAAS,4BAA4B,CACnC,KAAwC;IAExC,OAAO,KAAK,CAAC,IAAI,KAAK,2BAAe,CAAC,UAAU,IAAI,KAAK,CAAC,KAAK,KAAK,GAAG,CAAC;AAC1E,CAAC;AA2NC,oEAA4B;AA1N9B,SAAS,+BAA+B,CACtC,KAAwC;IAExC,OAAO,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAC9C,CAAC;AAuNC,0EAA+B;AArNjC;;GAEG;AACH,SAAS,gCAAgC,CACvC,IAAmB;IAEnB,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,sBAAsB;QACnD,uDAAuD;QACvD,4CAA4C;QAC5C,IAAI,CAAC,QAAQ,CACd,CAAC;AACJ,CAAC;AA4MC,4EAAgC;AA1MlC;;GAEG;AACH,SAAS,mBAAmB,CAC1B,IAAmB;IAEnB,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,iBAAiB,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CACzE,CAAC;AACJ,CAAC;AA2LC,kDAAmB;AAzLrB;;;;;;GAMG;AACH,SAAS,eAAe,CACtB,IAAsC;IAEtC,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,cAAc;QAC3C,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,eAAe,CAC7C,CAAC;AACJ,CAAC;AAkLC,0CAAe;AAhLjB,SAAS,oBAAoB,CAC3B,IAA+B;IAE/B,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,0BAAc,CAAC,kBAAkB,CAAC;AAC1D,CAAC;AA6KC,oDAAoB;AA3KtB,SAAS,UAAU,CACjB,IAA+B;IAK/B,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IAED,OAAO;QACL,0BAAc,CAAC,uBAAuB;QACtC,0BAAc,CAAC,mBAAmB;QAClC,0BAAc,CAAC,kBAAkB;KAClC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AA6IC,gCAAU;AA3IZ,SAAS,cAAc,CACrB,IAA+B;IAQ/B,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IAED,OAAO;QACL,0BAAc,CAAC,0BAA0B;QACzC,0BAAc,CAAC,iBAAiB;QAChC,0BAAc,CAAC,+BAA+B;QAC9C,0BAAc,CAAC,6BAA6B;QAC5C,0BAAc,CAAC,cAAc;QAC7B,0BAAc,CAAC,iBAAiB;KACjC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAwHC,wCAAc;AAtHhB,SAAS,wBAAwB,CAC/B,IAA+B;IAW/B,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,CAAC;AAClD,CAAC;AAwGC,4DAAwB;AAtG1B,SAAS,gBAAgB,CACvB,IAA+B;IAE/B,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,0BAAc,CAAC,cAAc,CAAC;AACtD,CAAC;AA8GC,4CAAgB;AA5GlB,SAAS,mBAAmB,CAC1B,IAA+B;IAE/B,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,0BAAc,CAAC,iBAAiB,CAAC;AACzD,CAAC;AAuGC,kDAAmB;AArGrB,SAAS,oBAAoB,CAC3B,IAA+B;IAE/B,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,KAAK,CAAC;KACd;IAED,OAAO;QACL,eAAe;QACf,0BAAc,CAAC,aAAa;QAC5B,0BAAc,CAAC,kBAAkB;QACjC,0BAAc,CAAC,gBAAgB;QAC/B,0BAAc,CAAC,uBAAuB;QACtC,0BAAc,CAAC,0BAA0B;QACzC,0BAAc,CAAC,6BAA6B;QAC5C,0BAAc,CAAC,gBAAgB;QAC/B,cAAc;QACd,0BAAc,CAAC,0BAA0B;QACzC,0BAAc,CAAC,+BAA+B;QAC9C,mCAAmC;QACnC,0BAAc,CAAC,iBAAiB;QAChC,0BAAc,CAAC,mBAAmB;KACnC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC;AAiEC,oDAAoB;AA/DtB;;GAEG;AACH,SAAS,aAAa,CACpB,IAA+B;IAE/B,OAAO,CACL,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,0BAAc,CAAC,gBAAgB;QAC9C,IAAI,CAAC,IAAI,KAAK,aAAa,CAC5B,CAAC;AACJ,CAAC;AAoDC,sCAAa;AAlDf;;GAEG;AACH,SAAS,QAAQ,CACf,IAA+B;IAE/B,OAAO,CACL,CAAC,CAAC,IAAI;QACN,CAAC,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,gBAAgB;YAC5C,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,IAAI,KAAK,KAAK,CACpB,CAAC;AACJ,CAAC;AAmDC,4BAAQ;AAjDV,SAAS,YAAY,CACnB,IAA+B;IAE/B,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,0BAAc,CAAC,UAAU,CAAC;AAClD,CAAC;AAqCC,oCAAY;AAnCd;;GAEG;AACH,SAAS,iBAAiB,CACxB,IAAsC;IAEtC,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,0BAAc,CAAC,eAAe,CAAC;AACvD,CAAC;AAqBC,8CAAiB;AAnBnB;;GAEG;AACH,SAAS,cAAc,CACrB,IAA0D;IAE1D,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,MAAK,2BAAe,CAAC,UAAU,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC;AAC7E,CAAC;AAaC,wCAAc;AAXhB,SAAS,kCAAkC,CACzC,IAAmB;IAEnB,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,gBAAgB;QAC7C,IAAI,CAAC,IAAI,KAAK,0BAAc,CAAC,wBAAwB,CACtD,CAAC;AACJ,CAAC;AAYC,gFAAkC"}

View file

@ -0,0 +1,12 @@
import { RuleModule } from '../ts-eslint';
declare type InferOptionsTypeFromRuleNever<T> = T extends RuleModule<never, infer TOptions> ? TOptions : unknown;
/**
* Uses type inference to fetch the TOptions type from the given RuleModule
*/
declare type InferOptionsTypeFromRule<T> = T extends RuleModule<string, infer TOptions> ? TOptions : InferOptionsTypeFromRuleNever<T>;
/**
* Uses type inference to fetch the TMessageIds type from the given RuleModule
*/
declare type InferMessageIdsTypeFromRule<T> = T extends RuleModule<infer TMessageIds, unknown[]> ? TMessageIds : unknown;
export { InferOptionsTypeFromRule, InferMessageIdsTypeFromRule };
//# sourceMappingURL=InferTypesFromRule.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"InferTypesFromRule.d.ts","sourceRoot":"","sources":["../../src/eslint-utils/InferTypesFromRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,aAAK,6BAA6B,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAC1D,KAAK,EACL,MAAM,QAAQ,CACf,GACG,QAAQ,GACR,OAAO,CAAC;AACZ;;GAEG;AACH,aAAK,wBAAwB,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,GAC3E,QAAQ,GACR,6BAA6B,CAAC,CAAC,CAAC,CAAC;AAErC;;GAEG;AACH,aAAK,2BAA2B,CAAC,CAAC,IAAI,CAAC,SAAS,UAAU,CACxD,MAAM,WAAW,EACjB,OAAO,EAAE,CACV,GACG,WAAW,GACX,OAAO,CAAC;AAEZ,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,CAAC"}

View file

@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=InferTypesFromRule.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"InferTypesFromRule.js","sourceRoot":"","sources":["../../src/eslint-utils/InferTypesFromRule.ts"],"names":[],"mappings":""}

View file

@ -0,0 +1,13 @@
import { RuleMetaData, RuleMetaDataDocs, RuleListener, RuleContext, RuleModule } from '../ts-eslint/Rule';
declare type CreateRuleMetaDocs = Omit<RuleMetaDataDocs, 'url'>;
declare type CreateRuleMeta<TMessageIds extends string> = {
docs: CreateRuleMetaDocs;
} & Omit<RuleMetaData<TMessageIds>, 'docs'>;
declare function RuleCreator(urlCreator: (ruleName: string) => string): <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends RuleListener = RuleListener>({ name, meta, defaultOptions, create, }: Readonly<{
name: string;
meta: CreateRuleMeta<TMessageIds>;
defaultOptions: Readonly<TOptions>;
create: (context: Readonly<RuleContext<TMessageIds, TOptions>>, optionsWithDefault: Readonly<TOptions>) => TRuleListener;
}>) => RuleModule<TMessageIds, TOptions, TRuleListener>;
export { RuleCreator };
//# sourceMappingURL=RuleCreator.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"RuleCreator.d.ts","sourceRoot":"","sources":["../../src/eslint-utils/RuleCreator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,UAAU,EACX,MAAM,mBAAmB,CAAC;AAI3B,aAAK,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AACxD,aAAK,cAAc,CAAC,WAAW,SAAS,MAAM,IAAI;IAChD,IAAI,EAAE,kBAAkB,CAAC;CAC1B,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;AAE5C,iBAAS,WAAW,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM;UAanD,MAAM;;;;wDA2Bf;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}

View file

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleCreator = void 0;
const applyDefault_1 = require("./applyDefault");
function RuleCreator(urlCreator) {
// This function will get much easier to call when this is merged https://github.com/Microsoft/TypeScript/pull/26349
// TODO - when the above PR lands; add type checking for the context.report `data` property
return function createRule({ name, meta, defaultOptions, create, }) {
return {
meta: Object.assign(Object.assign({}, meta), { docs: Object.assign(Object.assign({}, meta.docs), { url: urlCreator(name) }) }),
create(context) {
const optionsWithDefault = applyDefault_1.applyDefault(defaultOptions, context.options);
return create(context, optionsWithDefault);
},
};
};
}
exports.RuleCreator = RuleCreator;
//# sourceMappingURL=RuleCreator.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"RuleCreator.js","sourceRoot":"","sources":["../../src/eslint-utils/RuleCreator.ts"],"names":[],"mappings":";;;AAOA,iDAA8C;AAQ9C,SAAS,WAAW,CAAC,UAAwC;IAC3D,oHAAoH;IACpH,2FAA2F;IAC3F,OAAO,SAAS,UAAU,CAIxB,EACA,IAAI,EACJ,IAAI,EACJ,cAAc,EACd,MAAM,GASN;QACA,OAAO;YACL,IAAI,kCACC,IAAI,KACP,IAAI,kCACC,IAAI,CAAC,IAAI,KACZ,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,MAExB;YACD,MAAM,CACJ,OAAqD;gBAErD,MAAM,kBAAkB,GAAG,2BAAY,CACrC,cAAc,EACd,OAAO,CAAC,OAAO,CAChB,CAAC;gBACF,OAAO,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;YAC7C,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAEQ,kCAAW"}

View file

@ -0,0 +1,18 @@
import * as TSESLint from '../ts-eslint';
declare const parser = "@typescript-eslint/parser";
declare type RuleTesterConfig = Omit<TSESLint.RuleTesterConfig, 'parser'> & {
parser: typeof parser;
};
declare class RuleTester extends TSESLint.RuleTester {
#private;
constructor(options: RuleTesterConfig);
private getFilename;
run<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(name: string, rule: TSESLint.RuleModule<TMessageIds, TOptions>, testsReadonly: TSESLint.RunTests<TMessageIds, TOptions>): void;
}
/**
* Simple no-op tag to mark code samples as "should not format with prettier"
* for the internal/plugin-test-formatting lint rule
*/
declare function noFormat(strings: TemplateStringsArray, ...keys: string[]): string;
export { noFormat, RuleTester };
//# sourceMappingURL=RuleTester.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"RuleTester.d.ts","sourceRoot":"","sources":["../../src/eslint-utils/RuleTester.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,cAAc,CAAC;AAEzC,QAAA,MAAM,MAAM,8BAA8B,CAAC;AAE3C,aAAK,gBAAgB,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG;IAClE,MAAM,EAAE,OAAO,MAAM,CAAC;CACvB,CAAC;AAEF,cAAM,UAAW,SAAQ,QAAQ,CAAC,UAAU;;gBAM9B,OAAO,EAAE,gBAAgB;IAyBrC,OAAO,CAAC,WAAW;IAuBnB,GAAG,CAAC,WAAW,SAAS,MAAM,EAAE,QAAQ,SAAS,QAAQ,CAAC,OAAO,EAAE,CAAC,EAClE,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC,EAChD,aAAa,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,GACtD,IAAI;CA4CR;AAED;;;GAGG;AACH,iBAAS,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAM1E;AAED,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}

View file

@ -0,0 +1,128 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
};
var _options;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuleTester = exports.noFormat = void 0;
const path = __importStar(require("path"));
const TSESLint = __importStar(require("../ts-eslint"));
const parser = '@typescript-eslint/parser';
class RuleTester extends TSESLint.RuleTester {
// as of eslint 6 you have to provide an absolute path to the parser
// but that's not as clean to type, this saves us trying to manually enforce
// that contributors require.resolve everything
constructor(options) {
var _a, _b;
super(Object.assign(Object.assign({}, options), { parserOptions: Object.assign(Object.assign({}, options.parserOptions), { warnOnUnsupportedTypeScriptVersion: (_b = (_a = options.parserOptions) === null || _a === void 0 ? void 0 : _a.warnOnUnsupportedTypeScriptVersion) !== null && _b !== void 0 ? _b : false }), parser: require.resolve(options.parser) }));
_options.set(this, void 0);
__classPrivateFieldSet(this, _options, options);
// make sure that the parser doesn't hold onto file handles between tests
// on linux (i.e. our CI env), there can be very a limited number of watch handles available
afterAll(() => {
try {
// instead of creating a hard dependency, just use a soft require
// a bit weird, but if they're using this tooling, it'll be installed
require(parser).clearCaches();
}
catch (_a) {
// ignored
}
});
}
getFilename(options) {
var _a;
if (options) {
const filename = `file.ts${((_a = options.ecmaFeatures) === null || _a === void 0 ? void 0 : _a.jsx) ? 'x' : ''}`;
if (options.project) {
return path.join(options.tsconfigRootDir != null
? options.tsconfigRootDir
: process.cwd(), filename);
}
return filename;
}
else if (__classPrivateFieldGet(this, _options).parserOptions) {
return this.getFilename(__classPrivateFieldGet(this, _options).parserOptions);
}
return 'file.ts';
}
// as of eslint 6 you have to provide an absolute path to the parser
// If you don't do that at the test level, the test will fail somewhat cryptically...
// This is a lot more explicit
run(name, rule, testsReadonly) {
const errorMessage = `Do not set the parser at the test level unless you want to use a parser other than ${parser}`;
const tests = Object.assign({}, testsReadonly);
// standardize the valid tests as objects
tests.valid = tests.valid.map(test => {
if (typeof test === 'string') {
return {
code: test,
};
}
return test;
});
tests.valid = tests.valid.map(test => {
if (typeof test !== 'string') {
if (test.parser === parser) {
throw new Error(errorMessage);
}
if (!test.filename) {
return Object.assign(Object.assign({}, test), { filename: this.getFilename(test.parserOptions) });
}
}
return test;
});
tests.invalid = tests.invalid.map(test => {
if (test.parser === parser) {
throw new Error(errorMessage);
}
if (!test.filename) {
return Object.assign(Object.assign({}, test), { filename: this.getFilename(test.parserOptions) });
}
return test;
});
super.run(name, rule, tests);
}
}
exports.RuleTester = RuleTester;
_options = new WeakMap();
/**
* Simple no-op tag to mark code samples as "should not format with prettier"
* for the internal/plugin-test-formatting lint rule
*/
function noFormat(strings, ...keys) {
const lastIndex = strings.length - 1;
return (strings.slice(0, lastIndex).reduce((p, s, i) => p + s + keys[i], '') +
strings[lastIndex]);
}
exports.noFormat = noFormat;
//# sourceMappingURL=RuleTester.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"RuleTester.js","sourceRoot":"","sources":["../../src/eslint-utils/RuleTester.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,uDAAyC;AAEzC,MAAM,MAAM,GAAG,2BAA2B,CAAC;AAM3C,MAAM,UAAW,SAAQ,QAAQ,CAAC,UAAU;IAG1C,oEAAoE;IACpE,4EAA4E;IAC5E,+CAA+C;IAC/C,YAAY,OAAyB;;QACnC,KAAK,iCACA,OAAO,KACV,aAAa,kCACR,OAAO,CAAC,aAAa,KACxB,kCAAkC,cAChC,OAAO,CAAC,aAAa,0CAAE,kCAAkC,mCAAI,KAAK,KAEtE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,IACvC,CAAC;QAdL,2BAAoC;QAgBlC,uBAAA,IAAI,YAAY,OAAO,EAAC;QAExB,yEAAyE;QACzE,4FAA4F;QAC5F,QAAQ,CAAC,GAAG,EAAE;YACZ,IAAI;gBACF,iEAAiE;gBACjE,qEAAqE;gBACrE,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;aAC/B;YAAC,WAAM;gBACN,UAAU;aACX;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IACO,WAAW,CAAC,OAAgC;;QAClD,IAAI,OAAO,EAAE;YACX,MAAM,QAAQ,GAAG,UAAU,OAAA,OAAO,CAAC,YAAY,0CAAE,GAAG,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YAClE,IAAI,OAAO,CAAC,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC,IAAI,CACd,OAAO,CAAC,eAAe,IAAI,IAAI;oBAC7B,CAAC,CAAC,OAAO,CAAC,eAAe;oBACzB,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EACjB,QAAQ,CACT,CAAC;aACH;YAED,OAAO,QAAQ,CAAC;SACjB;aAAM,IAAI,uCAAc,aAAa,EAAE;YACtC,OAAO,IAAI,CAAC,WAAW,CAAC,uCAAc,aAAa,CAAC,CAAC;SACtD;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,oEAAoE;IACpE,qFAAqF;IACrF,8BAA8B;IAC9B,GAAG,CACD,IAAY,EACZ,IAAgD,EAChD,aAAuD;QAEvD,MAAM,YAAY,GAAG,sFAAsF,MAAM,EAAE,CAAC;QAEpH,MAAM,KAAK,qBAAQ,aAAa,CAAE,CAAC;QAEnC,yCAAyC;QACzC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,OAAO;oBACL,IAAI,EAAE,IAAI;iBACX,CAAC;aACH;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;oBAC1B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;iBAC/B;gBACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAClB,uCACK,IAAI,KACP,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,IAC9C;iBACH;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACvC,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;aAC/B;YACD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAClB,uCACK,IAAI,KACP,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,IAC9C;aACH;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;CACF;AAckB,gCAAU;;AAZ7B;;;GAGG;AACH,SAAS,QAAQ,CAAC,OAA6B,EAAE,GAAG,IAAc;IAChE,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,OAAO,CACL,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACpE,OAAO,CAAC,SAAS,CAAC,CACnB,CAAC;AACJ,CAAC;AAEQ,4BAAQ"}

View file

@ -0,0 +1,10 @@
/**
* Pure function - doesn't mutate either parameter!
* Uses the default options and overrides with the options provided by the user
* @param defaultOptions the defaults
* @param userOptions the user opts
* @returns the options with defaults
*/
declare function applyDefault<TUser extends readonly unknown[], TDefault extends TUser>(defaultOptions: TDefault, userOptions: TUser | null): TDefault;
export { applyDefault };
//# sourceMappingURL=applyDefault.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"applyDefault.d.ts","sourceRoot":"","sources":["../../src/eslint-utils/applyDefault.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,iBAAS,YAAY,CAAC,KAAK,SAAS,SAAS,OAAO,EAAE,EAAE,QAAQ,SAAS,KAAK,EAC5E,cAAc,EAAE,QAAQ,EACxB,WAAW,EAAE,KAAK,GAAG,IAAI,GACxB,QAAQ,CAuBV;AAMD,OAAO,EAAE,YAAY,EAAE,CAAC"}

View file

@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyDefault = void 0;
const deepMerge_1 = require("./deepMerge");
/**
* Pure function - doesn't mutate either parameter!
* Uses the default options and overrides with the options provided by the user
* @param defaultOptions the defaults
* @param userOptions the user opts
* @returns the options with defaults
*/
function applyDefault(defaultOptions, userOptions) {
// clone defaults
const options = JSON.parse(JSON.stringify(defaultOptions));
if (userOptions === null || userOptions === undefined) {
return options;
}
options.forEach((opt, i) => {
if (userOptions[i] !== undefined) {
const userOpt = userOptions[i];
if (deepMerge_1.isObjectNotArray(userOpt) && deepMerge_1.isObjectNotArray(opt)) {
options[i] = deepMerge_1.deepMerge(opt, userOpt);
}
else {
options[i] = userOpt;
}
}
});
return options;
}
exports.applyDefault = applyDefault;
//# sourceMappingURL=applyDefault.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"applyDefault.js","sourceRoot":"","sources":["../../src/eslint-utils/applyDefault.ts"],"names":[],"mappings":";;;AAAA,2CAA0D;AAE1D;;;;;;GAMG;AACH,SAAS,YAAY,CACnB,cAAwB,EACxB,WAAyB;IAEzB,iBAAiB;IACjB,MAAM,OAAO,GAAwB,IAAI,CAAC,KAAK,CAC7C,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAC/B,CAAC;IAEF,IAAI,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,SAAS,EAAE;QACrD,OAAO,OAAO,CAAC;KAChB;IAED,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACzB,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YAChC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;YAE/B,IAAI,4BAAgB,CAAC,OAAO,CAAC,IAAI,4BAAgB,CAAC,GAAG,CAAC,EAAE;gBACtD,OAAO,CAAC,CAAC,CAAC,GAAG,qBAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;aACtC;iBAAM;gBACL,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;aACtB;SACF;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAMQ,oCAAY"}

View file

@ -0,0 +1,24 @@
import { ValidTestCase, InvalidTestCase } from '../ts-eslint';
/**
* Converts a batch of single line tests into a number of separate test cases.
* This makes it easier to write tests which use the same options.
*
* Why wouldn't you just leave them as one test?
* Because it makes the test error messages harder to decipher.
* This way each line will fail separately, instead of them all failing together.
*/
declare function batchedSingleLineTests<TOptions extends Readonly<unknown[]>>(test: ValidTestCase<TOptions>): ValidTestCase<TOptions>[];
/**
* Converts a batch of single line tests into a number of separate test cases.
* This makes it easier to write tests which use the same options.
*
* Why wouldn't you just leave them as one test?
* Because it makes the test error messages harder to decipher.
* This way each line will fail separately, instead of them all failing together.
*
* Make sure you have your line numbers correct for error reporting, as it will match
* the line numbers up with the split tests!
*/
declare function batchedSingleLineTests<TMessageIds extends string, TOptions extends Readonly<unknown[]>>(test: InvalidTestCase<TMessageIds, TOptions>): InvalidTestCase<TMessageIds, TOptions>[];
export { batchedSingleLineTests };
//# sourceMappingURL=batchedSingleLineTests.d.ts.map

Some files were not shown because too many files have changed in this diff Show more