diff --git a/.spelling b/.spelling new file mode 100644 index 000000000000..8acf2e674fe3 --- /dev/null +++ b/.spelling @@ -0,0 +1,126 @@ +# markdown-spellcheck spelling configuration file +# Format - lines beginning # are comments +# global dictionary is at the start, file overrides afterwards +# one word per line, to define a file override use ' - filename' +# where filename is relative to this configuration file +1000s +1pm +30s +A11y +Airbnb +Airbnb's +ands +API +APIs +ASI +AST +ASTs +async +autofixers +backticks +boolean +booleans +camelCase +camelCasing +CLI +codebase +codebases +CommonJS +config +configs +const +Crockford +declarators +destructure +destructured +destructuring +e.g. +enum +enums +ES2015 +ES2016 +ES5 +ES6 +ESLint +ESLint's +eslintrc.js +ESTree +fallthrough +falsy +filenames +heavy_check_mark +i.e. +IIFE +IIFEs +ing +jQuery +JS +JSCS +JSHint +JSON +JSX +linebreak +linters +MDN +monorepo +monorepos +multiline +namespace +namespaces +natively +necroing +NodeJS +npm +nullish +OOM +OOMs +onboard +OSS +package.json +Palantir +PascalCase +PascalCased +performant +pluggable +pre-ES6 +pre-parse +pre-releases +premade +README +readonly +realtime +RegExp#exec +reimplement +repo +roadmap +ruleset +rulesets +runtime +searchable +String#match +substring +substrings +superset +supertype +syntaxes +thenable +thought_balloon +timelines +TODO +transpile +truthy +tsconfig +tsconfig.json +tsconfigs +TSLint +typecheck +typechecker +typechecking +TypeScript +typings +unfixable +unprefixed +untyped +VSCode +Vue +whitespace diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000000..37ca0a15534a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,92 @@ +# Contributing + +## Raising Issues + +Feel free to raise an issue if you have a question, an enhancement, or a bug report. + +Please ensure you use the issue search functionality to search all **_opened and closed_** issues before raising a new issue. + +When raising a new issue, please fill out the issue template - please don't skip sections. +Please provide **_as much information as possible_**. This project is maintained by volunteers, so the more the more information you provide, the less likely we will have to waste everyone's time in asking you for more information. + +**_Help us to help you_** + +## Commenting + +Feel free to comment on any open issue if you have more information that you feel like you can provide. If you don't have more information, instead use the "reaction" feature on the root comment for the issue. We use reactions to help gauge which issues are important to the community, so these are the best way to show us an issue is important. + +Please refrain from leaving useless comments on issues. Comments like "+1", or "when's this getting fixed", or "any progress on this" just serve as spam, and annoy every single person subscribed to the issue. Generally we will just delete those comments, so save everyone time and think twice. + +Please refrain from commenting on old, closed issues and PRs. Your issue is rarely related enough to a closed issue to warrant "necroing" a dead thread - raising a new issue means you can fill in the template, and make it easier for us to help you. Often times if you comment on a closed issue, we will just ask you to open a new issue, so please save everyone's time, and **_help us to help you_**. + +Please refrain from commenting on `master` commits. Commit comments are not searchable, meaning that nobody else can discover your comments. Raise an issue and reference the commit instead so that everyone can see your comment, and you can fill out the template. + +--- + +## Pull Requests + +Anyone is free to help us build and maintain this project. If you see an issue that needs working on because it's important to you, comment on the issue to help make sure that nobody else works on it at the same time, and then start working. + +Developing in this repo is easy: + +- First fork the repo, and then clone it locally. +- Create a new branch. +- In the root of the project, run `yarn install`. + - This will install the dependencies, link the packages and do a build. +- Make the required changes. + +### Validating Your Changes + +We have a sophisticated CI process setup which gets run on every PR. You must pass all of the checks for us to consider merging your PR. Here is a list of checks that are done automatically, that you can also perform locally before pushing. + +- Ensure your code is properly formatted. + - You can run `yarn format` in any package or in the root. + - Alternatively, you can run prettier on save. +- Ensure there are no typechecking errors. + - You can run `yarn typecheck` in any package or in the root. +- Ensure your changes are adequately tested. + - You can run `yarn test` in any package. + - We aim for around `90%` branch coverage for every PR. + - Coverage reports should automatically be generated locally, and the `codecov` bot should also comment on your PR with the percentage, as well as links to the line-by-line coverage of each file touched by your PR. +- Ensure you have no lint errors. + - You can run `yarn lint` in any package or in the root. +- If you have made changes to any markdown documentation, ensure there are no spelling errors + - You can run `yarn check:spelling` in the root. +- If you have made changes within the `eslint-plugin` package, ensure the configs and documentation are valid. + - You can run `yarn check:configs` and `yarn check:docs` in the root, or in the `eslint-plugin` folder. + +### Raising a PR + +Once your changes are ready, you can raise a PR. The title of your PR should match the following format: + +``` +(): +``` + +Where `` is one of: + +- `feat` - for any new functionality additions +- `fix` - for any bug fixes that don't add new functionality +- `test` - if you only change tests, and not shipped code +- `docs` - if you only change documentation, and not shipped code +- `chore` - anything else + +And `` is the name of the package you have made changes within (`eslint-plugin`, `parser`, `typescript-estree`, etc). If you make significant changes across multiple packages, you can omit this (i.e. `feat: foo bar`). + +And `` is a succinct title for the PR. + +Within the body of your PR, make sure you reference the issue that you have worked on, as well as a pointing out anything of note you wish us to look at during our review. + +Make sure you use the "Fixes #xxx" format to reference issues, so that GitHub automatically closes the issues when we merge the PR. Also note that if you are fixing multiple issues at once, you can only reference one issue per line, and must put one "Fixes #xxx" per issue number. + +In terms of your commit history - we do not care about the number, or style of commits in your history, because we squash merge every PR into master. Feel free to commit in whatever style you feel comfortable with. + +**_One thing we ask is to please avoid force pushing after you have raised a PR_**. GitHub is not able to track changes across force pushes, which makes it impossible to efficiently do incremental reviews. This slows us down, and means it will take longer for us to get your PR merged. + +### Addressing Feedback and Beyond + +With your PR raised, and the CI showing green, your PR will [sit in the queue to be reviewed](https://github.com/typescript-eslint/typescript-eslint/pulls?q=is%3Apr+is%3Aopen+sort%3Acreated-asc+-label%3A%22breaking+change%22+-label%3A%22awaiting+response%22+-label%3A%221+approval%22+-label%3A%22DO+NOT+MERGE%22). We generally review PRs oldest to newest, unless we consider a newer PR higher priority (i.e. if it's a bug fix). + +Please note that as this project is maintained by volunteers, it may take a while for us to get around to your PR (sometimes a month or more). Be patient, we'll get to it. Please refrain from commenting asking for a review, or similar bump comments. **_These just create spam for maintainers, and does not push your PR higher in the queue_**. + +Once we have reviewed your PR, we will provide any feedback that needs addressing. If you feel a requested change is wrong, don't be afraid to discuss with us in the comments. Once the feedback is addressed, and the PR is reviewed, we'll ensure the branch is up to date with master, and merge it for you. diff --git a/README.md b/README.md index 1f6d7c3cac1d..47c388762b6f 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,12 @@ - [What are ESLint and TypeScript, and how do they compare?](#what-are-eslint-and-typescript-and-how-do-they-compare) - [Why does this project exist?](#why-does-this-project-exist) - [What about TSLint?](#what-about-tslint) -- [How does typescript-eslint work and why do you have multiple packages?](#how-does-typescript-eslint-work-and-why-do-you-have-multiple-packages) +- [How does `typescript-eslint` work and why do you have multiple packages?](#how-does-typescript-eslint-work-and-why-do-you-have-multiple-packages) - [Can I use all of the existing ESLint plugins and rules without any changes?](#can-i-use-all-of-the-existing-eslint-plugins-and-rules-without-any-changes) - [Can we write rules which leverage type information?](#can-we-write-rules-which-leverage-type-information) -- [What about Babel and babel-eslint?](#what-about-babel-and-babel-eslint) +- [What about Babel and `babel-eslint`?](#what-about-babel-and-babel-eslint) - [How can I help?](#how-can-i-help) -- [How do I configure my project to use typescript-eslint?](#how-do-i-configure-my-project-to-use-typescript-eslint) +- [Packages included in this project?](#packages-included-in-this-project) - [Package Versions](#package-versions) - [Supported TypeScript Version](#supported-typescript-version) - [Supported ESLint version](#supported-eslint-version) @@ -34,11 +34,12 @@ ## Getting Started -The following sections will give you an overview of what this project is, why it exists and how it works at a high level. +**[You can find our Getting Started docs here](./docs/getting-started/README.md)** +**[You can find our Linting FAQ / Troubleshooting docs here](./docs/getting-started/linting/FAQ.md)** -**It is very important that you are familiar with these concepts before reporting issues**, so please read them and let us know if you have any feedback. +The documentation below will give you an overview of what this project is, why it exists and how it works at a high level. -If you are ready to get started you can jump to the package READMEs from here: [#how-do-i-configure-my-project-to-use-typescript-eslint](#how-do-i-configure-my-project-to-use-typescript-eslint) +**It is very important that you are familiar with these concepts before reporting issues**, so it is a good idea to read them before raising issues.
@@ -195,12 +196,10 @@ All positive contributions are welcome here!
-## How do I configure my project to use `typescript-eslint`? +## Packages included in this project Please follow the links below for the packages you care about. -If you are interested in using TypeScript and ESLint together, you will want to check out [`@typescript-eslint/parser`](./packages/parser/) and [`@typescript-eslint/eslint-plugin`](./packages/eslint-plugin/) at the very least: - - [`@typescript-eslint/typescript-estree`](./packages/typescript-estree/) - An entirely generic TypeScript parser which takes TypeScript source code and produces an ESTree-compatible AST

- This package is also used to power the amazing opinionated code formatter [Prettier](https://prettier.io)'s own TypeScript use-case. @@ -229,7 +228,7 @@ The latest version under the `canary` tag **(latest commit to master)** is: NPM Version -(Note: The only exceptions to the automated publishes described above are when we are in the final phases of creating the next major version of the libraries - e.g. going from 1.x.x to 2.x.x. During these periods, we manually publish `canary` releases until we are happy with the release and promote it to `latest`.) +(Note: The only exceptions to the automated publishes described above are when we are in the final phases of creating the next major version of the libraries - e.g. going from `1.x.x` to `2.x.x`. During these periods, we manually publish `canary` releases until we are happy with the release and promote it to `latest`.)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 960eb86b11d5..19c0cc15d8d6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -35,6 +35,10 @@ jobs: yarn check:docs displayName: 'Validate documentation' + - script: | + yarn check:spelling + displayName: 'Validate documentation spelling' + - script: | yarn check:configs displayName: 'Validate plugin configs' @@ -80,8 +84,8 @@ jobs: - job: publish_canary_version displayName: Publish the latest code as a canary version dependsOn: - - primary_code_validation_and_tests - - unit_tests_on_other_node_versions + - primary_code_validation_and_tests + - unit_tests_on_other_node_versions condition: and(succeeded(), eq(variables['Build.SourceBranchName'], 'master'), ne(variables['Build.Reason'], 'PullRequest')) pool: vmImage: 'Ubuntu-16.04' diff --git a/docs/getting-started/README.md b/docs/getting-started/README.md new file mode 100644 index 000000000000..f3abf26f1c42 --- /dev/null +++ b/docs/getting-started/README.md @@ -0,0 +1,11 @@ +# Getting Started + +Approaching a monorepo project like this can be pretty daunting and hard to navigate for a new user. + +The goal of these docs are to give you a quick overview of the project and all of its the pieces, as well as provide guides to help you get setup. + +The docs are broken down into the following categories: + +### [I want to lint my TypeScript codebase.](./linting/README.md) + +### [(TODO) I want to write an ESLint plugin in TypeScript.](./plugin-development/README.md) diff --git a/docs/getting-started/linting/FAQ.md b/docs/getting-started/linting/FAQ.md new file mode 100644 index 000000000000..290c57984286 --- /dev/null +++ b/docs/getting-started/linting/FAQ.md @@ -0,0 +1,83 @@ +# Troubleshooting / FAQ + +## Table of Contents + +- [My linting seems really slow](#my-linting-seems-really-slow) +- [I get errors telling me "The file must be included in at least one of the projects provided"](#i-get-errors-telling-me-"the-file-must-be-included-in-at-least-one-of-the-projects-provided") +- [I use a framework (like Vue) that requires custom file extensions, and I get errors like "You should add `parserOptions.extraFileExtensions` to your config"](<#i-use-a-framework-(like-vue)-that-requires-custom-file-extensions,-and-i-get-errors-like-"you-should-add-`parserOptions.extraFileExtensions`-to-your-config">) + +--- + +## My linting feels really slow + +As mentioned in the [type-aware linting doc](./TYPED_LINTING.md), if you're using type-aware linting, your lint times should be roughly the same as your build times. + +If you're experiencing times much slower than that, then there are a few common culprits. + +### Wide includes in your `tsconfig` + +When using type-aware linting, you provide us with one or more tsconfigs. We then will pre-parse all files so that full and complete type information is available. + +If you provide very wide globs in your `include` (like `**/*`), it can cause many more files than you expect to be included in this pre-parse. Additionally, if you provide no `include` in your tsconfig, then it is the same as providing the widest glob. + +Wide globs can cause TypeScript to parse things like build artifacts, which can heavily impact performance. Always ensure you provide globs targeted at the folders you are specifically wanting to lint. + +### `eslint-plugin-prettier` + +This plugin surfaces prettier formatting problems at lint time, helping to ensure your code is always formatted. However this comes at a quite a large cost - in order to figure out if there is a difference, it has to do a prettier format on every file being linted. This means that each file will be parsed twice - once by ESLint, and once by Prettier. This can add up for large codebases. + +Instead of using this plugin, we recommend using prettier's `--list-different` flag to detect if a file has not been correctly formatted. For example, our CI is setup to run the following command automatically, which blocks diffs that have not been formatted: + +```bash +$ yarn prettier --list-different \"./**/*.{ts,js,json,md}\" +``` + +### `eslint-plugin-import` + +This is another great plugin that we use ourselves in this project. However there are a few rules which can cause your lints to be really slow, because they cause the plugin to do its own parsing, and file tracking. This double parsing adds up for large codebases. + +There are many rules that do single file static analysis, but we provide the following recommendations. + +We recommend you do not use the following rules, as TypeScript provides the same checks as part of standard type checking: + +- `import/named` +- `import/namespace` +- `import/default` +- `import/no-named-as-default-member` + +The following rules do not have equivalent checks in TypeScript, so we recommend that you only run them at CI/push time, to lessen the local performance burden. + +- `import/no-named-as-default` +- `import/no-cycle` +- `import/no-unused-modules` +- `import/no-deprecated` + +### The `indent` / `@typescript-eslint/indent` rules + +This rule helps ensure your codebase follows a consistent indentation pattern. However this involves a _lot_ of computations across every single token in a file. Across a large codebase, these can add up, and severely impact performance. + +We recommend not using this rule, and instead using a tool like [`prettier`](https://www.npmjs.com/package/) to enforce a standardized formatting. + +--- + +## I get errors telling me "The file must be included in at least one of the projects provided" + +This error means that the file that's being linted is not included in any of the tsconfig files you provided us. A lot of the time this happens when users have test files or similar that are not included. + +To fix this, simply make sure the `include` option in your tsconfig includes every single file you want to lint. + +--- + +## I use a framework (like Vue) that requires custom file extensions, and I get errors like "You should add `parserOptions.extraFileExtensions` to your config" + +You can use `parserOptions.extraFileExtensions` to specify an array of non-TypeScript extensions to allow, for example: + +```diff + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], ++ extraFileExtensions: ['.vue'], + }, +``` + +--- diff --git a/docs/getting-started/linting/MONOREPO.md b/docs/getting-started/linting/MONOREPO.md new file mode 100644 index 000000000000..00200300f5d1 --- /dev/null +++ b/docs/getting-started/linting/MONOREPO.md @@ -0,0 +1,78 @@ +# Getting Started - Monorepo Configuration + +If you're using a monorepo, these docs will help you figure out how to setup typed linting. +If you don't want to use typed linting, then you can stop here - you don't need to do anything special. + +The first question to answer is how are your `tsconfig.json` setup? You should have one of two setups: + +1. One `tsconfig.json` per package (and an optional one in the root) +2. One root `tsconfig.json` + +Which config style you specifically choose doesn't matter + +## One `tsconfig.json` per package (and an optional one in the root) + +This setup is pretty easy to configure. Earlier in our docs on [typed linting](./TYPED_LINTING.md), we showed you how to setup a config for typed linting using the `parserOptions.project` option. This option accepts an array of relative paths, allowing you to specify each and every `tsconfig.json` in your monorepo. For those of you with too many packages, you can also supply a [glob path](https://github.com/isaacs/node-glob/blob/f5a57d3d6e19b324522a3fa5bdd5075fd1aa79d1/README.md#glob-primer). + +For example, this is how we specify all of our `tsconfig.json` within this repo. + +```diff + module.exports = { + root: true, + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, +- project: ['./tsconfig.json'], ++ project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'], + }, + plugins: ['@typescript-eslint'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + ], + }; +``` + +If you're looking for an example of what the `.eslintrc.js`, and referenced `tsconfig.json` might look like in a real example, look no further than this very repo. We're a multi-package monorepo that uses one `tsconfig.json` per package, that also uses typed linting. + +### Important note regarding large (> 10) multi-package monorepos + +We've had reports that for sufficiently large and/or interdependent projects, you may run into OOMs using this approach. Our advice is to set it up and test first, as there are very few cases that trigger this OOM. We are in the process of investigating solutions with the help of the TypeScript team. + +See [#1192](https://github.com/typescript-eslint/typescript-eslint/issues/1192) for more information and discussion. + +If you do run into an OOM, please comment on the above issue and let us know about your repo - the more information we have, the better. As an interim workaround, consider one of the following: + +- Switching to one root `tsconfig.eslint.json` (see below) +- Using a shell script to only lint one package at a time, using your existing config above. + +## One root `tsconfig.json` + +If you've only got one, you should inspect the `include` paths. If it doesn't include all of your files, then we won't be able to lint them. In this instance, you have two options: add them in to the `include`, or create a new config. + +The former doesn't always work for everyone if they've got a complex build, adding more paths (like test paths) to `include` could break the build, so in those cases we suggest creating a new config; called `tsconfig.eslint.json`, that looks something like this: + +```jsonc +{ + // extend your base config to share compilerOptions, etc + "extends": "./tsconfig.json", + "compilerOptions": { + // ensure that nobody can accidentally use this config for a build + "noEmit": true + }, + "include": [ + // whatever paths you intend to lint + "src", + "test", + "tools" + ] +} +``` + +Of course, ensure you update your `.eslintrc.js` to point at this new config file. + +## FAQ + +If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](./FAQ.md). diff --git a/docs/getting-started/linting/README.md b/docs/getting-started/linting/README.md new file mode 100644 index 000000000000..c136c37ec250 --- /dev/null +++ b/docs/getting-started/linting/README.md @@ -0,0 +1,167 @@ +# Getting Started - Linting your TypeScript Codebase + +Whether you're adding linting to a new TypeScript codebase, adding TypeScript to an old codebase, or migrating from the deprecated [TSLint](https://www.npmjs.com/package/tslint), the steps aren't a whole lot different. + +## Installation + +First step is to make sure you've got the required packages installed: + +```bash +$ yarn add -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin +``` + +## Configuration + +Next, create a `.eslintrc.js` config file in the root of your project, and populate it with the following: + + +```js +module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + ], +}; +``` + +This is about the smallest config file we recommend. There's a lot more you can add to this as you further onboard, but this will be enough to get you started. + +Explaining the important bits: + +- `parser: '@typescript-eslint/parser'` tells ESLint to use the parser package you installed ([`@typescript-eslint/parser`](../../../packages/parser)). + - This allows ESLint to understand TypeScript syntax. + - This is required, or else ESLint will throw errors as it tries to parse TypeScript code as if it were regular JavaScript. +- `plugins: ['@typescript-eslint']` tells ESLint to load the plugin package you installed ([`@typescript-eslint/eslint-plugin`](../../../packages/eslint-plugin)). + - This allows you to use the rules within your codebase. +- `extends: [ ... ]` tells ESLint that your config extends the given configurations. + - `eslint:recommended` is ESLint's inbuilt "recommended" config - it turns on a small, sensible set of rules which lint for well-known best-practices. + - `plugin:@typescript-eslint/eslint-recommended` is a configuration we provide which disables a few of the recommended rules from the previous set that we know are already covered by TypeScript's typechecker. + - `plugin:@typescript-eslint/recommended` is our "recommended" config - it's just like `eslint:recommended`, except it only turns on rules from our TypeScript-specific plugin. + +Further reading: + +- You can read more about configuring ESLint [in their documentation on configuration.](https://eslint.org/docs/user-guide/configuring). +- You can read more about the rules provided by ESLint [in their documentation on their rules](https://eslint.org/docs/rules/). +- You can read more about the rules provided by us in [our plugin documentation](../../../packages/eslint-plugin). + +## Ignoring unnecessary files + +Next, create a `.eslintignore` file in the root of your project. +This file will tell ESLint which files and folders it should never lint. + +Add the following lines to the file: + +```ignore +# don't ever lint node_modules +node_modules +# don't lint build output (make sure it's set to your correct build folder name) +dist +# don't lint nyc coverage output +coverage +``` + +## Running the lint + +With that configured, open a terminal to the root of your project, and run the following command + +```bash +$ yarn eslint . --ext .js,.jsx,.ts,.tsx +``` + +That's it - ESLint will lint all `.js`, `.jsx`, `.ts`, and `.tsx` files within the current folder, and will output the results to your terminal. + +You can also get results in realtime inside most IDEs via a plugin - just search your IDE's extension store. + +## Next Steps + +With that configured you can now start to delve into the wide and extensive ESLint ecosystem of plugins and configs. + +### Extending your TypeScript linting with Type-Aware Rules + +We have a lot of awesome rules which utilize the power of TypeScript's type information. They require a little bit of extra setup beyond this first step, [so visit the next page to see how to set this up.](./TYPED_LINTING.md) + +### ESLint Configs + +There are many configuration packages in the ecosystem - these packages that exist solely to provide a comprehensive base config for you, with the intention that you add the config and it gives you an opinionated setup. A few popular all-in-one-configs are: + +- Airbnb's ESLint config - [`eslint-config-airbnb-typescript`](https://www.npmjs.com/package/eslint-config-airbnb-typescript). +- Standard - [`eslint-config-standard-with-typescript`](https://www.npmjs.com/package/eslint-config-standard-with-typescript). + +To use one of these complete config packages, you would replace the `extends` with one of these, for example: + +```diff + module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + extends: [ +- 'eslint:recommended', +- 'plugin:@typescript-eslint/eslint-recommended', +- 'plugin:@typescript-eslint/recommended', ++ 'airbnb-typescript', + ], + }; +``` + +#### Usage with prettier + +If you use [`prettier`](https://www.npmjs.com/package/prettier), there is also a helpful config to help ensure ESLint doesn't report on formatting issues that prettier will fix: [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier). + +Using this config is as simple as adding it to the end of your `extends`: + +```diff + module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', ++ 'prettier/@typescript-eslint', + ], + }; +``` + +### Plugins + +There are many plugins, each covering a different slice of the JS development world. Below are just a few examples, but there are [many, many more](https://www.npmjs.com/search?q=eslint-plugin). + +- Jest testing: [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest) +- ESLint comment restrictions: [`eslint-plugin-eslint-comments`](https://www.npmjs.com/package/eslint-plugin-eslint-comments) +- Import/export conventions : [`eslint-plugin-eslint-comments`](https://www.npmjs.com/package/eslint-plugin-import) +- React best practices: [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react) and [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks) +- NodeJS best practices: [`eslint-plugin-node`](https://www.npmjs.com/package/eslint-plugin-node) + +Every plugin that is out there includes documentation on the various rules they offer, as well as recommended their own recommended configurations (just like we provide). You can add a plugin and a recommended config as follows: + +```diff + module.exports = { + root: true, + parser: '@typescript-eslint/parser', + plugins: [ + '@typescript-eslint', ++ 'jest', + ], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', ++ 'plugin:jest/recommended', + ], + }; +``` + +## FAQ + +If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](./FAQ.md). diff --git a/docs/getting-started/linting/TYPED_LINTING.md b/docs/getting-started/linting/TYPED_LINTING.md new file mode 100644 index 000000000000..fd6fe4fb2f4c --- /dev/null +++ b/docs/getting-started/linting/TYPED_LINTING.md @@ -0,0 +1,49 @@ +# Getting Started - Linting with Type Information + +The parser you configured earlier has a little secret. Under the hood, it actually just uses TypeScript's compiler APIs to parse the files. This means that we can provide lint rules with access to all of the type information that TypeScript knows about your codebase. + +This provides a lot of additional power, unlocking many possibilities for static analysis. + +How can we tap into this? There are two small changes you need to make to your config file: + +```diff + module.exports = { + root: true, + parser: '@typescript-eslint/parser', ++ parserOptions: { ++ tsconfigRootDir: __dirname, ++ project: ['./tsconfig.json'], ++ }, + plugins: ['@typescript-eslint'], + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', ++ 'plugin:@typescript-eslint/recommended-requiring-type-checking', + ], + }; +``` + +The first change is adding the `parserOptions` configuration: + +- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory. +- `parserOptions.project` tells our parser the relative path where your project's `tsconfig.json` is. + - If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./MONOREPO.md). +- `plugin:@typescript-eslint/recommended-requiring-type-checking` is another recommended configuration we provide. This one contains rules that specifically require type information. + +With that done, simply run the same lint command you ran before. You will see new rules reporting errors based on type information! + +## Performance + +_But wait_ - I hear you exclaim - _why would you ever not want type-aware rules?_ + +Well (for full disclosure) there is a catch; by including `parserOptions.project` in your config, you are essentially asking TypeScript to do a build of your project before ESLint can do its linting. For small projects this takes a negligible amount of time (a few seconds); for large projects, it can take longer (30s or more). + +Most of our users are fine with this, as they think the power of type-aware static analysis is worth it. +Additionally, most users primarily consume lint errors via IDE plugins which, through some caching magic, do not suffer the same penalties. This means that generally they usually only run a complete lint before a push, or via their CI, where the extra time really doesn't matter. + +We strongly recommend you do use it, but the above information is included so that you can make your own, informed decision. + +## FAQ + +If you're having problems getting this working, please have a look at our [Troubleshooting FAQ](./FAQ.md). diff --git a/docs/getting-started/plugin-development/README.md b/docs/getting-started/plugin-development/README.md new file mode 100644 index 000000000000..46f0c551956e --- /dev/null +++ b/docs/getting-started/plugin-development/README.md @@ -0,0 +1,12 @@ +# Getting Started - Writing an ESLint Plugin in TypeScript + +TODO: + +- talk about how to setup the folder structure +- talk about how to consume `experimental-utils` to create an empty rule +- talk about https://eslint.org/docs/developer-guide/selectors and how to use the strict types +- talk about how to write tests + +TODO: (advanced) + +- talk about how to use type information diff --git a/package.json b/package.json index aca3b80aee45..47aa94d20a74 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "cz": "git-cz", "check:docs": "lerna run check:docs", "check:configs": "lerna run check:configs", + "check:spelling": "yarn check:spelling-interactive -r", + "check:spelling-interactive": "mdspell '**/*.md' '!**/node_modules/**/*.md' '!**/CHANGELOG.md' '!**/CONTRIBUTORS.md' '!**/ROADMAP.md' --ignore-numbers --en-us", "generate-contributors": "yarn ts-node --transpile-only ./tools/generate-contributors.ts && yarn all-contributors generate", "format": "prettier --write \"./**/*.{ts,js,json,md}\"", "format-check": "prettier --list-different \"./**/*.{ts,js,json,md}\"", @@ -67,6 +69,7 @@ "jest": "^24.9.0", "lerna": "^3.18.4", "lint-staged": "^9.4.3", + "markdown-spellcheck": "^1.3.1", "opencollective-postinstall": "^2.0.2", "prettier": "^1.19.1", "ts-jest": "^24.0.0", diff --git a/packages/eslint-plugin-tslint/README.md b/packages/eslint-plugin-tslint/README.md index 5e502168d82a..bfdd640ad4f5 100644 --- a/packages/eslint-plugin-tslint/README.md +++ b/packages/eslint-plugin-tslint/README.md @@ -13,12 +13,12 @@ ## Installation ```sh -npm i @typescript-eslint/eslint-plugin-tslint --save-dev +yarn add -D @typescript-eslint/eslint-plugin-tslint ``` ## Usage -Configure in your eslint config file: +Configure in your ESLint config file: ```js { @@ -42,7 +42,7 @@ Configure in your eslint config file: } ``` -**Note:** The ability to automatically fix problems with `--fix` is unavailable for tslint rules loaded with this plugin. +**Note:** The ability to automatically fix problems with `--fix` is unavailable for TSLint rules loaded with this plugin. ## Rules @@ -50,7 +50,7 @@ Plugin contains only single rule `@typescript-eslint/tslint/config`. ## Examples -- [unlight/node-package-starter/.eslintrc.js](https://github.com/unlight/node-package-starter/blob/master/.eslintrc.js) +- [`unlight/node-package-starter/.eslintrc.js`](https://github.com/unlight/node-package-starter/blob/master/.eslintrc.js) ### TSLint Plugins diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 08030874d996..e018b8a5a0e7 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -8,30 +8,30 @@ Commitizen friendly

-## Installation +## Getting Started -Make sure you have TypeScript and `@typescript-eslint/parser` installed, then install the plugin: +**[You can find our Getting Started docs here](../../docs/getting-started/linting/README.md)** +**[You can find our FAQ / Troubleshooting docs here](./docs/getting-started/linting/FAQ.md)** + +These docs walk you through setting up ESLint, this plugin, and our parser. If you know what you're doing and just want to quick start, read on... + +## Quick-start + +### Installation + +Make sure you have TypeScript and [`@typescript-eslint/parser`](../parser) installed, then install the plugin: ```sh -npm i @typescript-eslint/eslint-plugin --save-dev +yarn add -D @typescript-eslint/eslint-plugin ``` It is important that you use the same version number for `@typescript-eslint/parser` and `@typescript-eslint/eslint-plugin`. **Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@typescript-eslint/eslint-plugin` globally. -## Usage - -Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file: - -```json -{ - "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint"] -} -``` +### Usage -Then configure the rules you want to use under the rules section. +Add `@typescript-eslint/parser` to the `parser` field and `@typescript-eslint` to the plugins section of your `.eslintrc` configuration file, then configure the rules you want to use under the rules section. ```json { @@ -51,7 +51,11 @@ You can also enable all the recommended rules for our plugin. Add `plugin:@types } ``` -You can also use [eslint:recommended](https://eslint.org/docs/rules/) (the set of rules which are recommended for all projects by the ESLint Team) with this plugin. As noted in the root README, not all eslint core rules are compatible with TypeScript, so you need to add both `eslint:recommended` and `plugin:@typescript-eslint/eslint-recommended` (which will adjust the one from eslint appropriately for TypeScript) to your config: +**Note: Make sure to use `eslint --ext .js,.ts` since by [default](https://eslint.org/docs/user-guide/command-line-interface#--ext) `eslint` will only search for `.js` files.** + +### Recommended Configs + +You can also use [`eslint:recommended`](https://eslint.org/docs/rules/) (the set of rules which are recommended for all projects by the ESLint Team) with this plugin. As noted in the root README, not all ESLint core rules are compatible with TypeScript, so you need to add both `eslint:recommended` and `plugin:@typescript-eslint/eslint-recommended` (which will adjust the one from ESLint appropriately for TypeScript) to your config: ```json { @@ -80,56 +84,7 @@ Some highly valuable rules simply require type-checking in order to be implement Pro Tip: For larger codebases you may want to consider splitting our linting into two separate stages: 1. fast feedback rules which operate purely based on syntax (no type-checking), 2. rules which are based on semantics (type-checking). -NOTE: If you want to use rules which require type information, you will need to specify a path to your tsconfig.json file in the "project" property of "parserOptions". If you do not do this, you will get a runtime error which explains this. - -```json -{ - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "./tsconfig.json" - }, - "plugins": ["@typescript-eslint"], - "rules": { - "@typescript-eslint/restrict-plus-operands": "error" - } -} -``` - -See [@typescript-eslint/parser's README.md](../parser/README.md) for more information on the available "parserOptions". - -**Note: Make sure to use `eslint --ext .js,.ts` since by [default](https://eslint.org/docs/user-guide/command-line-interface#--ext) `eslint` will only search for .js files.** - -## Usage with Prettier - -Install [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) to disable our code formatting related rules: - -```json -{ - "extends": [ - "plugin:@typescript-eslint/recommended", - "prettier", - "prettier/@typescript-eslint" - ] -} -``` - -**Note: Make sure you have `eslint-config-prettier@4.0.0` or newer.** - -## Usage with Airbnb - -Airbnb has two configs, a base one [`eslint-config-airbnb-base`](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base) and one that includes rules for React [`eslint-config-airbnb`](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb). - -First you'll need to install the config according to the instructions in one of the links above. `npx install-peerdeps --dev eslint-config-airbnb` or `npx install-peerdeps --dev eslint-config-airbnb-base` should work if you are using **npm 5+**. - -Then you should add `airbnb` (or `airbnb-base`) to your `extends` section of `.eslintrc`. You might also want to turn on `plugin:@typescript-eslint/recommended` as well to enable all of the recommended rules. - -```json -{ - "extends": ["airbnb-base", "plugin:@typescript-eslint/recommended"] -} -``` - -**Note: You can use Airbnb's rules alongside Prettier, see [Usage with Prettier](#usage-with-prettier)** +**[You can read more about linting with type information here](../../docs/getting-started/linting/TYPED_LINTING.md)** ## Supported Rules diff --git a/packages/eslint-plugin/ROADMAP.md b/packages/eslint-plugin/ROADMAP.md index c97e1a303148..34d396853481 100644 --- a/packages/eslint-plugin/ROADMAP.md +++ b/packages/eslint-plugin/ROADMAP.md @@ -1,4 +1,9 @@ -# Roadmap +# TSLint Migration Guide + +This document serves as a guid to help you migrate from TSLint. +It lists all TSLint rules along side rules from the ESLint ecosystem that are the same or similar. + +## TSLint rules ✅ = done
🌟 = in ESLint core
@@ -6,8 +11,6 @@ 🌓 = implementations differ or ESLint version is missing functionality
🛑 = unimplemented
-## TSLint rules - ### TypeScript-specific | TSLint rule | | ESLint rule | @@ -102,7 +105,7 @@ | [`use-default-type-parameter`] | ✅ | [`@typescript-eslint/no-unnecessary-type-arguments`] | | [`use-isnan`] | 🌟 | [`use-isnan`][use-isnan] | -[1] The ESLint rule also supports silencing with an extra set of parens (`if ((foo = bar)) {}`)
+[1] The ESLint rule also supports silencing with an extra set of parentheses (`if ((foo = bar)) {}`)
### Maintainability diff --git a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md index 690de86b6542..01d37b218eba 100644 --- a/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md +++ b/packages/eslint-plugin/docs/rules/adjacent-overload-signatures.md @@ -4,7 +4,7 @@ Grouping overloaded members together can improve readability of the code. ## Rule Details -This rule aims to standardise the way overloaded members are organized. +This rule aims to standardize the way overloaded members are organized. The following patterns are considered warnings: diff --git a/packages/eslint-plugin/docs/rules/array-type.md b/packages/eslint-plugin/docs/rules/array-type.md index 9acab2200c83..d76b7f8ea09c 100644 --- a/packages/eslint-plugin/docs/rules/array-type.md +++ b/packages/eslint-plugin/docs/rules/array-type.md @@ -4,7 +4,7 @@ Using the same style for array definitions across your codebase makes it easier ## Rule Details -This rule aims to standardise usage of array types within your codebase. +This rule aims to standardize usage of array types within your codebase. ## Options diff --git a/packages/eslint-plugin/docs/rules/await-thenable.md b/packages/eslint-plugin/docs/rules/await-thenable.md index 47780d1db42d..05eab6414914 100644 --- a/packages/eslint-plugin/docs/rules/await-thenable.md +++ b/packages/eslint-plugin/docs/rules/await-thenable.md @@ -1,4 +1,4 @@ -# Disallows awaiting a value that is not a Promise (await-thenable) +# Disallows awaiting a value that is not a Promise (`await-thenable`) This rule disallows awaiting a value that is not a "Thenable" (an object which has `then` method, such as a Promise). While it is valid JavaScript to await a non-`Promise`-like value (it will resolve immediately), this pattern is often a programmer error, such as forgetting to add parenthesis to call a function that returns a Promise. diff --git a/packages/eslint-plugin/docs/rules/ban-ts-ignore.md b/packages/eslint-plugin/docs/rules/ban-ts-ignore.md index 7480d044d950..174ac5e78e4d 100644 --- a/packages/eslint-plugin/docs/rules/ban-ts-ignore.md +++ b/packages/eslint-plugin/docs/rules/ban-ts-ignore.md @@ -1,6 +1,6 @@ # Bans “// @ts-ignore” comments from being used (ban-ts-ignore) -Suppressing Typescript Compiler Errors can be hard to discover. +Suppressing TypeScript Compiler Errors can be hard to discover. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/brace-style.md b/packages/eslint-plugin/docs/rules/brace-style.md index 908fca707c1d..5a667294f2c8 100644 --- a/packages/eslint-plugin/docs/rules/brace-style.md +++ b/packages/eslint-plugin/docs/rules/brace-style.md @@ -2,7 +2,7 @@ ## Rule Details -This rule extends the base [eslint/brace-style](https://eslint.org/docs/rules/brace-style) rule. +This rule extends the base [`eslint/brace-style`](https://eslint.org/docs/rules/brace-style) rule. It supports all options and features of the base rule. ## How to use @@ -17,6 +17,6 @@ It supports all options and features of the base rule. ## Options -See [eslint/brace-style options](https://eslint.org/docs/rules/brace-style#options). +See [`eslint/brace-style` options](https://eslint.org/docs/rules/brace-style#options). Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/brace-style.md) diff --git a/packages/eslint-plugin/docs/rules/camelcase.md b/packages/eslint-plugin/docs/rules/camelcase.md index 5fa0c8e530ff..f0b49d0420fa 100644 --- a/packages/eslint-plugin/docs/rules/camelcase.md +++ b/packages/eslint-plugin/docs/rules/camelcase.md @@ -1,8 +1,8 @@ -# Enforce camelCase naming convention (camelcase) +# Enforce camelCase naming convention (`camelcase`) When it comes to naming variables, style guides generally fall into one of two -camps: camelcase (`variableName`) and underscores (`variable_name`). This rule -focuses on using the camelcase approach. If your style guide calls for +camps: camelCase (`variableName`) and underscores (`variable_name`). This rule +focuses on using the camelCase approach. If your style guide calls for camelCasing your variable names, then this rule is for you! ## Rule Details @@ -31,10 +31,10 @@ variable that will be imported into the local module scope. This rule has an object option: - `"properties": "never"` (default) does not check property names -- `"properties": "always"` enforces camelcase style for property names +- `"properties": "always"` enforces camelCase style for property names - `"genericType": "never"` (default) does not check generic identifiers -- `"genericType": "always"` enforces camelcase style for generic identifiers -- `"ignoreDestructuring": false` (default) enforces camelcase style for destructured identifiers +- `"genericType": "always"` enforces camelCase style for generic identifiers +- `"ignoreDestructuring": false` (default) enforces camelCase style for destructured identifiers - `"ignoreDestructuring": true` does not check destructured identifiers - `allow` (`string[]`) list of properties to accept. Accept regex. @@ -119,7 +119,7 @@ var { foo: isCamelCased } = bar; var { foo: isCamelCased = 1 } = quz; ``` -### properties: "never" +### `properties: "never"` Examples of **correct** code for this rule with the `{ "properties": "never" }` option: @@ -131,7 +131,7 @@ var obj = { }; ``` -### genericType: "always" +### `genericType: "always"` Examples of **incorrect** code for this rule with the default `{ "genericType": "always" }` option: @@ -193,7 +193,7 @@ class Foo { } ``` -### genericType: "never" +### `genericType: "never"` Examples of **correct** code for this rule with the `{ "genericType": "never" }` option: @@ -225,7 +225,7 @@ class Foo { } ``` -### ignoreDestructuring: false +### `ignoreDestructuring: false` Examples of **incorrect** code for this rule with the default `{ "ignoreDestructuring": false }` option: @@ -243,7 +243,7 @@ var { category_id: category_alias } = query; var { category_id: categoryId, ...other_props } = query; ``` -### ignoreDestructuring: true +### `ignoreDestructuring: true` Examples of **incorrect** code for this rule with the `{ "ignoreDestructuring": true }` option: diff --git a/packages/eslint-plugin/docs/rules/class-name-casing.md b/packages/eslint-plugin/docs/rules/class-name-casing.md index f594a9854f18..13b174548b3f 100644 --- a/packages/eslint-plugin/docs/rules/class-name-casing.md +++ b/packages/eslint-plugin/docs/rules/class-name-casing.md @@ -1,6 +1,6 @@ -# Require PascalCased class and interface names (class-name-casing) +# Require PascalCase class and interface names (class-name-casing) -This rule enforces PascalCased names for classes and interfaces. +This rule enforces PascalCase names for classes and interfaces. ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md index 8e619c430ea7..1041d2bae84b 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-assertions.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-assertions.md @@ -2,7 +2,7 @@ ## Rule Details -This rule aims to standardise the use of type assertion style across the codebase. +This rule aims to standardize the use of type assertion style across the codebase. Type assertions are also commonly referred as "type casting" in TypeScript (even though it is technically slightly different to what is understood by type casting in other languages), so you can think of type assertions and type casting referring to the same thing. It is essentially you saying to the TypeScript compiler, "in this case, I know better than you!". @@ -24,7 +24,7 @@ const defaultOptions: Options = { }; ``` -### assertionStyle +### `assertionStyle` This option defines the expected assertion style. Valid values for `assertionStyle` are: @@ -36,7 +36,7 @@ Most code bases will want to enforce not using `angle-bracket` style because it Some codebases like to go for an extra level of type safety, and ban assertions altogether via the `never` option. -### objectLiteralTypeAssertions +### `objectLiteralTypeAssertions` Always prefer `const x: T = { ... };` to `const x = { ... } as T;` (or similar with angle brackets). The type assertion in the latter case is either unnecessary or will probably hide an error. diff --git a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md index 7e3093ebfaa0..27315771e428 100644 --- a/packages/eslint-plugin/docs/rules/explicit-function-return-type.md +++ b/packages/eslint-plugin/docs/rules/explicit-function-return-type.md @@ -100,7 +100,7 @@ If you are working on a codebase within which you lint non-TypeScript code (i.e. } ``` -### allowExpressions +### `allowExpressions` Examples of **incorrect** code for this rule with `{ allowExpressions: true }`: @@ -122,7 +122,7 @@ node.addEventListener('click', function() {}); const foo = arr.map(i => i * i); ``` -### allowTypedFunctionExpressions +### `allowTypedFunctionExpressions` Examples of **incorrect** code for this rule with `{ allowTypedFunctionExpressions: true }`: @@ -176,7 +176,7 @@ functionWithObjectArg({ }); ``` -### allowHigherOrderFunctions +### `allowHigherOrderFunctions` Examples of **incorrect** code for this rule with `{ allowHigherOrderFunctions: true }`: diff --git a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md index a86257783918..a4cb8c3d5569 100644 --- a/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md +++ b/packages/eslint-plugin/docs/rules/explicit-member-accessibility.md @@ -313,7 +313,7 @@ class Animal { ### Except specific methods -If you want to ignore some specific methods, you can do it by specifing method names. Note that this option does not care for the context, and will ignore every method with these names, which could lead to it missing some cases. You should use this sparingly. +If you want to ignore some specific methods, you can do it by specifying method names. Note that this option does not care for the context, and will ignore every method with these names, which could lead to it missing some cases. You should use this sparingly. e.g. `[ { ignoredMethodNames: ['specificMethod', 'whateverMethod'] } ]` ```ts diff --git a/packages/eslint-plugin/docs/rules/func-call-spacing.md b/packages/eslint-plugin/docs/rules/func-call-spacing.md index d852df451a11..9bcabde63dae 100644 --- a/packages/eslint-plugin/docs/rules/func-call-spacing.md +++ b/packages/eslint-plugin/docs/rules/func-call-spacing.md @@ -1,11 +1,11 @@ -# require or disallow spacing between function identifiers and their invocations (func-call-spacing) +# require or disallow spacing between function identifiers and their invocations (`func-call-spacing`) When calling a function, developers may insert optional whitespace between the function’s name and the parentheses that invoke it. This rule requires or disallows spaces between the function name and the opening parenthesis that calls it. ## Rule Details -This rule extends the base [eslint/func-call-spacing](https://eslint.org/docs/rules/func-call-spacing) rule. +This rule extends the base [`eslint/func-call-spacing`](https://eslint.org/docs/rules/func-call-spacing) rule. It supports all options and features of the base rule. This version adds support for generic type parameters on function calls. @@ -21,6 +21,6 @@ This version adds support for generic type parameters on function calls. ## Options -See [eslint/func-call-spacing options](https://eslint.org/docs/rules/func-call-spacing#options). +See [`eslint/func-call-spacing` options](https://eslint.org/docs/rules/func-call-spacing#options). Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/func-call-spacing.md) diff --git a/packages/eslint-plugin/docs/rules/indent.md b/packages/eslint-plugin/docs/rules/indent.md index 4ffd6f894c70..572b3e5fd1b5 100644 --- a/packages/eslint-plugin/docs/rules/indent.md +++ b/packages/eslint-plugin/docs/rules/indent.md @@ -12,7 +12,7 @@ function hello(indentSize, type) { These are the most common scenarios recommended in different style guides: -- Two spaces, not longer and no tabs: Google, npm, Node.js, Idiomatic, Felix +- Two spaces, not longer and no tabs: Google, npm, NodeJS, Idiomatic, Felix - Tabs: jQuery - Four spaces: Crockford @@ -77,15 +77,15 @@ This rule has an object option: - `"SwitchCase"` (default: 0) enforces indentation level for `case` clauses in `switch` statements - `"VariableDeclarator"` (default: 1) enforces indentation level for `var` declarators; can also take an object to define separate rules for `var`, `let` and `const` declarations. - `"outerIIFEBody"` (default: 1) enforces indentation level for file-level IIFEs. -- `"MemberExpression"` (default: 1) enforces indentation level for multi-line property chains. This can also be set to `"off"` to disable checking for MemberExpression indentation. +- `"MemberExpression"` (default: 1) enforces indentation level for multi-line property chains. This can also be set to `"off"` to disable checking for `MemberExpression` indentation. - `"FunctionDeclaration"` takes an object to define rules for function declarations. - - `parameters` (default: 1) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string `"first"` indicating that all parameters of the declaration must be aligned with the first parameter. This can also be set to `"off"` to disable checking for FunctionDeclaration parameters. + - `parameters` (default: 1) enforces indentation level for parameters in a function declaration. This can either be a number indicating indentation level, or the string `"first"` indicating that all parameters of the declaration must be aligned with the first parameter. This can also be set to `"off"` to disable checking for `FunctionDeclaration` parameters. - `body` (default: 1) enforces indentation level for the body of a function declaration. - `"FunctionExpression"` takes an object to define rules for function expressions. - - `parameters` (default: 1) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all parameters of the expression must be aligned with the first parameter. This can also be set to `"off"` to disable checking for FunctionExpression parameters. + - `parameters` (default: 1) enforces indentation level for parameters in a function expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all parameters of the expression must be aligned with the first parameter. This can also be set to `"off"` to disable checking for `FunctionExpression` parameters. - `body` (default: 1) enforces indentation level for the body of a function expression. - `"CallExpression"` takes an object to define rules for function call expressions. - - `arguments` (default: 1) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all arguments of the expression must be aligned with the first argument. This can also be set to `"off"` to disable checking for CallExpression arguments. + - `arguments` (default: 1) enforces indentation level for arguments in a call expression. This can either be a number indicating indentation level, or the string `"first"` indicating that all arguments of the expression must be aligned with the first argument. This can also be set to `"off"` to disable checking for `CallExpression` arguments. - `"ArrayExpression"` (default: 1) enforces indentation level for elements in arrays. It can also be set to the string `"first"`, indicating that all the elements in the array should be aligned with the first element. This can also be set to `"off"` to disable checking for array elements. - `"ObjectExpression"` (default: 1) enforces indentation level for properties in objects. It can be set to the string `"first"`, indicating that all properties in the object should be aligned with the first property. This can also be set to `"off"` to disable checking for object properties. - `"ImportDeclaration"` (default: 1) enforces indentation level for import statements. It can be set to the string `"first"`, indicating that all imported members from a module should be aligned with the first member in the list. This can also be set to `"off"` to disable checking for imported module members. @@ -140,7 +140,7 @@ if (a) { } ``` -### SwitchCase +### `SwitchCase` Examples of **incorrect** code for this rule with the `2, { "SwitchCase": 1 }` options: @@ -170,7 +170,7 @@ switch(a){ } ``` -### VariableDeclarator +### `VariableDeclarator` Examples of **incorrect** code for this rule with the `2, { "VariableDeclarator": 1 }` options: @@ -244,7 +244,7 @@ const a = 1, c = 3; ``` -### outerIIFEBody +### `outerIIFEBody` Examples of **incorrect** code for this rule with the options `2, { "outerIIFEBody": 0 }`: @@ -286,7 +286,7 @@ if(y) { } ``` -### MemberExpression +### `MemberExpression` Examples of **incorrect** code for this rule with the `2, { "MemberExpression": 1 }` options: @@ -310,7 +310,7 @@ foo .baz(); ``` -### FunctionDeclaration +### `FunctionDeclaration` Examples of **incorrect** code for this rule with the `2, { "FunctionDeclaration": {"body": 1, "parameters": 2} }` option: @@ -362,7 +362,7 @@ function foo(bar, baz, } ``` -### FunctionExpression +### `FunctionExpression` Examples of **incorrect** code for this rule with the `2, { "FunctionExpression": {"body": 1, "parameters": 2} }` option: @@ -414,7 +414,7 @@ var foo = function(bar, baz, } ``` -### CallExpression +### `CallExpression` Examples of **incorrect** code for this rule with the `2, { "CallExpression": {"arguments": 1} }` option: @@ -460,7 +460,7 @@ foo(bar, baz, baz, boop, beep); ``` -### ArrayExpression +### `ArrayExpression` Examples of **incorrect** code for this rule with the `2, { "ArrayExpression": 1 }` option: @@ -512,7 +512,7 @@ var foo = [bar, ]; ``` -### ObjectExpression +### `ObjectExpression` Examples of **incorrect** code for this rule with the `2, { "ObjectExpression": 1 }` option: @@ -560,7 +560,7 @@ var foo = { bar: 1, baz: 2 }; ``` -### ImportDeclaration +### `ImportDeclaration` Examples of **correct** code for this rule with the `4, { "ImportDeclaration": 1 }` option (the default): @@ -604,7 +604,7 @@ import { foo, } from 'qux'; ``` -### flatTernaryExpressions +### `flatTernaryExpressions` Examples of **incorrect** code for this rule with the default `4, { "flatTernaryExpressions": false }` option: @@ -654,7 +654,7 @@ var a = boop; ``` -### ignoredNodes +### `ignoredNodes` The following configuration ignores the indentation of `ConditionalExpression` ("ternary expression") nodes: @@ -689,7 +689,7 @@ bar(); }) ``` -### ignoreComments +### `ignoreComments` Examples of additional **correct** code for this rule with the `4, { "ignoreComments": true }` option: @@ -708,6 +708,6 @@ if (foo) { ## Compatibility - **JSHint**: `indent` -- **JSCS**: [validateIndentation](https://jscs-dev.github.io/rule/validateIndentation) +- **JSCS**: [`validateIndentation`](https://jscs-dev.github.io/rule/validateIndentation) Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/indent.md) diff --git a/packages/eslint-plugin/docs/rules/member-delimiter-style.md b/packages/eslint-plugin/docs/rules/member-delimiter-style.md index 2ec96d80614a..07f339665e23 100644 --- a/packages/eslint-plugin/docs/rules/member-delimiter-style.md +++ b/packages/eslint-plugin/docs/rules/member-delimiter-style.md @@ -52,7 +52,7 @@ Finally, this rule can enforce separate delimiter syntax for single line declara ## Rule Details -This rule aims to standardise the way interface and type literal members are delimited. +This rule aims to standardize the way interface and type literal members are delimited. ## Options diff --git a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md index 630046823387..76928c04764e 100644 --- a/packages/eslint-plugin/docs/rules/no-dynamic-delete.md +++ b/packages/eslint-plugin/docs/rules/no-dynamic-delete.md @@ -8,7 +8,7 @@ Using the `delete` operator on keys that aren't runtime constants could be a sig Using `Object`s with added and removed keys can cause occasional edge case bugs, such as if a key is named `"hasOwnProperty"`. Consider using a `Map` or `Set` if you’re storing collections of objects. -Examples of **correct** code wth this rule: +Examples of **correct** code with this rule: ```ts const container: { [i: string]: number } = { diff --git a/packages/eslint-plugin/docs/rules/no-empty-function.md b/packages/eslint-plugin/docs/rules/no-empty-function.md index 2b37c4da396e..44f815c75d43 100644 --- a/packages/eslint-plugin/docs/rules/no-empty-function.md +++ b/packages/eslint-plugin/docs/rules/no-empty-function.md @@ -1,12 +1,12 @@ -# Disallow Empty Functions (@typescript-eslint/no-empty-function) +# Disallow Empty Functions (no-empty-function) Empty functions can reduce readability because readers need to guess whether it’s intentional or not. So writing a clear comment for empty functions is a good practice. ## Rule Details -The `@typescript-eslint/no-empty-function` rule extends the `no-empty-function` rule from ESLint core, and adds support for handling Typescript specific code that would otherwise trigger the rule. +The `@typescript-eslint/no-empty-function` rule extends the `no-empty-function` rule from ESLint core, and adds support for handling TypeScript specific code that would otherwise trigger the rule. -One example of valid Typescript specific code that would otherwise trigger the `no-empty-function` rule is the use of [parameter properties](https://www.typescriptlang.org/docs/handbook/classes.html#parameter-properties) in constructor functions: +One example of valid TypeScript specific code that would otherwise trigger the `no-empty-function` rule is the use of [parameter properties](https://www.typescriptlang.org/docs/handbook/classes.html#parameter-properties) in constructor functions: ```typescript class Person { diff --git a/packages/eslint-plugin/docs/rules/no-explicit-any.md b/packages/eslint-plugin/docs/rules/no-explicit-any.md index 861eb0566e23..55d42a0b1ddf 100644 --- a/packages/eslint-plugin/docs/rules/no-explicit-any.md +++ b/packages/eslint-plugin/docs/rules/no-explicit-any.md @@ -105,7 +105,7 @@ const defaults = { }; ``` -### ignoreRestArgs +### `ignoreRestArgs` A boolean to specify if arrays from the rest operator are considered okay. `false` by default. diff --git a/packages/eslint-plugin/docs/rules/no-extra-parens.md b/packages/eslint-plugin/docs/rules/no-extra-parens.md index d7942ec1b169..9cd0cc48ab42 100644 --- a/packages/eslint-plugin/docs/rules/no-extra-parens.md +++ b/packages/eslint-plugin/docs/rules/no-extra-parens.md @@ -1,10 +1,10 @@ -# disallow unnecessary parentheses (no-extra-parens) +# disallow unnecessary parentheses (`no-extra-parens`) This rule restricts the use of parentheses to only where they are necessary. ## Rule Details -This rule extends the base [eslint/no-extra-parens](https://eslint.org/docs/rules/no-extra-parens) rule. +This rule extends the base [`eslint/no-extra-parens`](https://eslint.org/docs/rules/no-extra-parens) rule. It supports all options and features of the base rule plus TS type assertions. ## How to use @@ -19,4 +19,4 @@ It supports all options and features of the base rule plus TS type assertions. ## Options -See [eslint/no-extra-parens options](https://eslint.org/docs/rules/no-extra-parens#options). +See [`eslint/no-extra-parens` options](https://eslint.org/docs/rules/no-extra-parens#options). diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index 9af9aebf1e62..350ffa80a94a 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -54,7 +54,7 @@ const defaults = { }; ``` -### ignoreVoid +### `ignoreVoid` This allows to easily suppress false-positives with void operator. @@ -76,4 +76,4 @@ remain unhandled. ## Related to -- Tslint: ['no-floating-promises'](https://palantir.github.io/tslint/rules/no-floating-promises/) +- TSLint: ['no-floating-promises'](https://palantir.github.io/tslint/rules/no-floating-promises/) diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index 215890a2e832..c7903cd0bea9 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -1,11 +1,11 @@ -# Disallow Magic Numbers (@typescript-eslint/no-magic-numbers) +# Disallow Magic Numbers (`no-magic-numbers`) 'Magic numbers' are numbers that occur multiple times in code without an explicit meaning. They should preferably be replaced by named constants. ## Rule Details -The `@typescript-eslint/no-magic-numbers` rule extends the `no-magic-numbers` rule from ESLint core, and adds support for handling Typescript specific code that would otherwise trigger the rule. +The `@typescript-eslint/no-magic-numbers` rule extends the `no-magic-numbers` rule from ESLint core, and adds support for handling TypeScript specific code that would otherwise trigger the rule. See the [ESLint documentation](https://eslint.org/docs/rules/no-magic-numbers) for more details on the `no-magic-numbers` rule. @@ -21,9 +21,9 @@ See the [ESLint documentation](https://eslint.org/docs/rules/no-magic-numbers) f In addition to the options supported by the `no-magic-numbers` rule in ESLint core, the rule adds the following options: -### ignoreNumericLiteralTypes +### `ignoreNumericLiteralTypes` -A boolean to specify if numbers used in Typescript numeric literal types are considered okay. `false` by default. +A boolean to specify if numbers used in TypeScript numeric literal types are considered okay. `false` by default. Examples of **incorrect** code for the `{ "ignoreNumericLiteralTypes": false }` option: @@ -41,7 +41,7 @@ Examples of **correct** code for the `{ "ignoreNumericLiteralTypes": true }` opt type SmallPrimes = 2 | 3 | 5 | 7 | 11; ``` -### ignoreReadonlyClassProperties +### `ignoreReadonlyClassProperties` Examples of **incorrect** code for the `{ "ignoreReadonlyClassProperties": false }` option: @@ -69,9 +69,9 @@ class Foo { } ``` -### ignoreEnums +### `ignoreEnums` -A boolean to specify if enums used in Typescript are considered okay. `false` by default. +A boolean to specify if enums used in TypeScript are considered okay. `false` by default. Examples of **incorrect** code for the `{ "ignoreEnums": false }` option: diff --git a/packages/eslint-plugin/docs/rules/no-misused-promises.md b/packages/eslint-plugin/docs/rules/no-misused-promises.md index cd8a2f8b9570..ffca96632a7e 100644 --- a/packages/eslint-plugin/docs/rules/no-misused-promises.md +++ b/packages/eslint-plugin/docs/rules/no-misused-promises.md @@ -1,6 +1,6 @@ # Avoid using promises in places not designed to handle them (no-misused-promises) -This rule forbids using promises in places where the Typescript compiler +This rule forbids using promises in places where the TypeScript compiler allows them but they are not handled properly. These situations can often arise due to a missing `await` keyword or just a misunderstanding of the way async functions are handled/awaited. @@ -108,7 +108,7 @@ like this: ## When Not To Use It If you do not use Promises in your codebase or are not concerned with possible -misuses of them outside of what the Typescript compiler will check. +misuses of them outside of what the TypeScript compiler will check. ## Related to @@ -116,4 +116,4 @@ misuses of them outside of what the Typescript compiler will check. ## Further Reading -- [Typescript void function assignability](https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void) +- [TypeScript void function assignability](https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void) diff --git a/packages/eslint-plugin/docs/rules/no-namespace.md b/packages/eslint-plugin/docs/rules/no-namespace.md index 61a4ef856713..86ddeeb1e49b 100644 --- a/packages/eslint-plugin/docs/rules/no-namespace.md +++ b/packages/eslint-plugin/docs/rules/no-namespace.md @@ -7,7 +7,7 @@ This rule still allows the use of TypeScript module declarations to describe ext ## Rule Details -This rule aims to standardise the way modules are declared. +This rule aims to standardize the way modules are declared. ## Options @@ -36,7 +36,7 @@ Examples of **correct** code for the default `{ "allowDeclarations": false, "all declare module 'foo' {} ``` -### allowDeclarations +### `allowDeclarations` Examples of **incorrect** code for the `{ "allowDeclarations": true }` option: @@ -68,7 +68,7 @@ Examples of **correct** code for the `{ "allowDeclarations": false }` option: declare module 'foo' {} ``` -### allowDefinitionFiles +### `allowDefinitionFiles` Examples of **incorrect** code for the `{ "allowDefinitionFiles": true }` option: diff --git a/packages/eslint-plugin/docs/rules/no-type-alias.md b/packages/eslint-plugin/docs/rules/no-type-alias.md index 285837f29359..c1f2cd9934b8 100644 --- a/packages/eslint-plugin/docs/rules/no-type-alias.md +++ b/packages/eslint-plugin/docs/rules/no-type-alias.md @@ -90,7 +90,7 @@ or more of the following you may pass an object with the options set as follows: - `allowMappedTypes` set to `"always"` will allow you to use type aliases as mapping tools (Defaults to `"never"`) - `allowTupleTypes` set to `"always"` will allow you to use type aliases with tuples (Defaults to `"never"`) -### allowAliases +### `allowAliases` This applies to primitive types and reference types. @@ -228,7 +228,7 @@ type Foo = Bar | Baz; type Foo = Bar & Baz; ``` -### allowCallbacks +### `allowCallbacks` This applies to function types. @@ -250,7 +250,7 @@ type Foo = (name: string, age: number) => string | Person; type Foo = (name: string, age: number) => string & Person; ``` -### allowConditionalTypes +### `allowConditionalTypes` This applies to conditional types. @@ -260,7 +260,7 @@ Examples of **correct** code for the `{ "allowConditionalTypes": "always" }` opt type Foo = T extends number ? number : null; ``` -### allowConstructors +### `allowConstructors` This applies to constructor types. @@ -274,7 +274,7 @@ Examples of **correct** code for the `{ "allowConstructors": "always" }` option: type Foo = new () => void; ``` -### allowLiterals +### `allowLiterals` This applies to literal types (`type Foo = { ... }`). @@ -381,7 +381,7 @@ type Foo = { name: string } | { age: number }; type Foo = { name: string } & { age: number }; ``` -### allowMappedTypes +### `allowMappedTypes` This applies to literal types. @@ -480,7 +480,7 @@ type Foo = { readonly [P in keyof T]: T[P] } & type Foo = { [P in keyof T]?: T[P] } & { [P in keyof U]?: U[P] }; ``` -### allowTupleTypes +### `allowTupleTypes` This applies to tuple types (`type Foo = [number]`). diff --git a/packages/eslint-plugin/docs/rules/no-untyped-public-signature.md b/packages/eslint-plugin/docs/rules/no-untyped-public-signature.md index 7ffafd5a5ae7..0c26412d4a1d 100644 --- a/packages/eslint-plugin/docs/rules/no-untyped-public-signature.md +++ b/packages/eslint-plugin/docs/rules/no-untyped-public-signature.md @@ -42,7 +42,7 @@ private foo(param1) { This rule, in its default state, does not require any argument. -### ignoredMethods +### `ignoredMethods` You may pass method names you would like this rule to ignore, like so: diff --git a/packages/eslint-plugin/docs/rules/no-unused-expressions.md b/packages/eslint-plugin/docs/rules/no-unused-expressions.md index e1a86449181e..797a5269991b 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-expressions.md +++ b/packages/eslint-plugin/docs/rules/no-unused-expressions.md @@ -4,7 +4,7 @@ This rule aims to eliminate unused expressions which have no effect on the state ## Rule Details -This rule extends the base [eslint/no-unused-expressions](https://eslint.org/docs/rules/no-unused-expressions) rule. +This rule extends the base [`eslint/no-unused-expressions`](https://eslint.org/docs/rules/no-unused-expressions) rule. It supports all options and features of the base rule. This version adds support for numerous typescript features. @@ -20,6 +20,6 @@ This version adds support for numerous typescript features. ## Options -See [eslint/no-unused-expressions options](https://eslint.org/docs/rules/no-unused-expressions#options). +See [`eslint/no-unused-expressions` options](https://eslint.org/docs/rules/no-unused-expressions#options). Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-unused-expressions.md) diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md b/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md index 7ee9a6d84324..18d08304bc3e 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars-experimental.md @@ -6,11 +6,11 @@ Variables that are declared and not used anywhere in the code are most likely an This rule leverages the TypeScript compiler's unused variable checks to report. This means that with all rule options set to `false`, it should report the same errors as if you used both the `noUnusedLocals` and `noUnusedParameters` compiler options. -This rule is vastly different to, and maintains no compatability with the base eslint version of the rule. +This rule is vastly different to, and maintains no compatibility with the base ESLint version of the rule. ### Limitations -There are two limitations to this rule when compared with eslint's `no-unused-vars` rule, which are imposed by the fact that it directly uses TypeScript's implementation. +There are two limitations to this rule when compared with ESLint's `no-unused-vars` rule, which are imposed by the fact that it directly uses TypeScript's implementation. 1. This rule only works on files that TypeScript deems is a module (i.e. it has an `import` or an `export` statement). 2. The rule is significantly less configurable, as it cannot deviate too far from the base implementation. @@ -46,7 +46,7 @@ const defaultOptions: Options = { }; ``` -### ignoredNamesRegex +### `ignoredNamesRegex` This option accepts a regex string to match names against. Any matched names will be ignored and have no errors reported. @@ -73,7 +73,7 @@ type _UnusedType = {}; **_NOTE:_** The TypeScript compiler automatically ignores imports, function arguments, type parameter declarations, and object destructuring variables prefixed with an underscore. As this is hard-coded into the compiler, we cannot change this. -Examples of valid code based on the unchangable compiler settings +Examples of valid code based on the unchangeable compiler settings ```ts import _UnusedDefault, { _UnusedNamed } from 'foo'; @@ -82,7 +82,7 @@ export class Foo<_UnusedGeneric> {} const { prop: _unusedDesctructure } = foo; ``` -## ignoreArgsIfArgsAfterAreUsed +## `ignoreArgsIfArgsAfterAreUsed` When true, this option will ignore unused function arguments if the arguments proceeding arguments are used. diff --git a/packages/eslint-plugin/docs/rules/no-unused-vars.md b/packages/eslint-plugin/docs/rules/no-unused-vars.md index f6091165b7ce..7c7d13966c55 100644 --- a/packages/eslint-plugin/docs/rules/no-unused-vars.md +++ b/packages/eslint-plugin/docs/rules/no-unused-vars.md @@ -122,14 +122,14 @@ By default this rule is enabled with `all` option for variables and `after-used` } ``` -### vars +### `vars` The `vars` option has two settings: - `all` checks all variables for usage, including those in the global scope. This is the default setting. - `local` checks only that locally-declared variables are used but will allow global variables to be unused. -#### vars: local +#### `vars: local` Examples of **correct** code for the `{ "vars": "local" }` option: @@ -140,7 +140,7 @@ Examples of **correct** code for the `{ "vars": "local" }` option: some_unused_var = 42; ``` -### varsIgnorePattern +### `varsIgnorePattern` The `varsIgnorePattern` option specifies exceptions not to check for usage: variables whose names match a regexp pattern. For example, variables whose names contain `ignored` or `Ignored`. @@ -154,7 +154,7 @@ var secondVar = 2; console.log(secondVar); ``` -### args +### `args` The `args` option has three settings: @@ -162,7 +162,7 @@ The `args` option has three settings: - `all` - all named arguments must be used. - `none` - do not check arguments. -#### args: after-used +#### `args: after-used` Examples of **incorrect** code for the default `{ "args": "after-used" }` option: @@ -187,7 +187,7 @@ Examples of **correct** code for the default `{ "args": "after-used" }` option: })(); ``` -#### args: all +#### `args: all` Examples of **incorrect** code for the `{ "args": "all" }` option: @@ -202,7 +202,7 @@ Examples of **incorrect** code for the `{ "args": "all" }` option: })(); ``` -#### args: none +#### `args: none` Examples of **correct** code for the `{ "args": "none" }` option: @@ -214,7 +214,7 @@ Examples of **correct** code for the `{ "args": "none" }` option: })(); ``` -### ignoreRestSiblings +### `ignoreRestSiblings` The `ignoreRestSiblings` option is a boolean (default: `false`). Using a [Rest Property](https://github.com/tc39/proposal-object-rest-spread) it is possible to "omit" properties from an object, but by default the sibling properties are marked as "unused". With this option enabled the rest property's siblings are ignored. @@ -226,7 +226,7 @@ Examples of **correct** code for the `{ "ignoreRestSiblings": true }` option: var { type, ...coords } = data; ``` -### argsIgnorePattern +### `argsIgnorePattern` The `argsIgnorePattern` option specifies exceptions not to check for usage: arguments whose names match a regexp pattern. For example, variables whose names begin with an underscore. @@ -241,7 +241,7 @@ function foo(x, _y) { foo(); ``` -### caughtErrors +### `caughtErrors` The `caughtErrors` option is used for `catch` block arguments validation. @@ -250,7 +250,7 @@ It has two settings: - `none` - do not check error objects. This is the default setting. - `all` - all named arguments must be used. -#### caughtErrors: none +#### `caughtErrors: none` Not specifying this rule is equivalent of assigning it to `none`. @@ -266,7 +266,7 @@ try { } ``` -#### caughtErrors: all +#### `caughtErrors: all` Examples of **incorrect** code for the `{ "caughtErrors": "all" }` option: @@ -282,7 +282,7 @@ try { } ``` -### caughtErrorsIgnorePattern +### `caughtErrorsIgnorePattern` The `caughtErrorsIgnorePattern` option specifies exceptions not to check for usage: catch arguments whose names match a regexp pattern. For example, variables whose names begin with a string 'ignore'. diff --git a/packages/eslint-plugin/docs/rules/no-use-before-define.md b/packages/eslint-plugin/docs/rules/no-use-before-define.md index d439d0111a00..5c2c9fd47ffc 100644 --- a/packages/eslint-plugin/docs/rules/no-use-before-define.md +++ b/packages/eslint-plugin/docs/rules/no-use-before-define.md @@ -98,7 +98,7 @@ let myVar: StringOrNumber; This rule accepts `"nofunc"` string as an option. `"nofunc"` is the same as `{ "functions": false, "classes": true }`. -### functions +### `functions` Examples of **correct** code for the `{ "functions": false }` option: @@ -109,7 +109,7 @@ f(); function f() {} ``` -### classes +### `classes` Examples of **incorrect** code for the `{ "classes": false }` option: @@ -134,7 +134,7 @@ function foo() { class A {} ``` -### variables +### `variables` Examples of **incorrect** code for the `{ "variables": false }` option: @@ -157,7 +157,7 @@ function baz() { var foo = 1; ``` -### typedefs +### `typedefs` Examples of **correct** code for the `{ "typedefs": false }` option: diff --git a/packages/eslint-plugin/docs/rules/prefer-includes.md b/packages/eslint-plugin/docs/rules/prefer-includes.md index 1ea37102b1d3..e93f248d2b65 100644 --- a/packages/eslint-plugin/docs/rules/prefer-includes.md +++ b/packages/eslint-plugin/docs/rules/prefer-includes.md @@ -1,4 +1,4 @@ -# Enforce `includes` method over `indexOf` method (@typescript-eslint/prefer-includes) +# Enforce `includes` method over `indexOf` method (prefer-includes) Until ES5, we were using `String#indexOf` method to check whether a string contains an arbitrary substring or not. Until ES2015, we were using `Array#indexOf` method to check whether an array contains an arbitrary value or not. diff --git a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md index 99ae0cb635ad..95d25f72d9ca 100644 --- a/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md +++ b/packages/eslint-plugin/docs/rules/prefer-namespace-keyword.md @@ -1,11 +1,11 @@ # Require the use of the `namespace` keyword instead of the `module` keyword to declare custom TypeScript modules. (prefer-namespace-keyword) In an effort to prevent further confusion between custom TypeScript modules and the new ES2015 modules, starting -with TypeScript v1.5 the keyword `namespace` is now the preferred way to declare custom TypeScript modules. +with TypeScript `v1.5` the keyword `namespace` is now the preferred way to declare custom TypeScript modules. ## Rule Details -This rule aims to standardise the way modules are declared. +This rule aims to standardize the way modules are declared. ## When Not To Use It diff --git a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md index f0ef0872d4eb..ef65adbca2ea 100644 --- a/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +++ b/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md @@ -15,7 +15,7 @@ function myFunc(foo: string | null) { } ``` -Because the nullish coalescing operator _only_ coalesces when the original value is `null` or `undefined`, it is much safer than relying upon logical OR operator chaining `||`; which coalesces on any _falsey_ value: +Because the nullish coalescing operator _only_ coalesces when the original value is `null` or `undefined`, it is much safer than relying upon logical OR operator chaining `||`; which coalesces on any _falsy_ value: ```ts const emptyString = ''; @@ -59,11 +59,11 @@ const defaultOptions = [ ]; ``` -### ignoreConditionalTests +### `ignoreConditionalTests` Setting this option to `true` (the default) will cause the rule to ignore any cases that are located within a conditional test. -Generally expressions within conditional tests intentionally use the falsey fallthrough behaviour of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs. +Generally expressions within conditional tests intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs. If you're looking to enforce stricter conditional tests, you should consider using the `strict-boolean-expressions` rule. @@ -95,11 +95,11 @@ for (let i = 0; a ?? b; i += 1) {} a ?? b ? true : false; ``` -### ignoreMixedLogicalExpressions +### `ignoreMixedLogicalExpressions` -Setting this option to `true` (the default) will cause the rule to ignore any logical or expressions thare are part of a mixed logical expression (with `&&`). +Setting this option to `true` (the default) will cause the rule to ignore any logical or expressions that are part of a mixed logical expression (with `&&`). -Generally expressions within mixed logical expressions intentionally use the falsey fallthrough behaviour of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs. +Generally expressions within mixed logical expressions intentionally use the falsy fallthrough behavior of the logical or operator, meaning that fixing the operator to the nullish coalesce operator could cause bugs. If you're looking to enforce stricter conditional tests, you should consider using the `strict-boolean-expressions` rule. @@ -133,11 +133,11 @@ a ?? (b && c && d); **_NOTE:_** Errors for this specific case will be presented as suggestions (see below), instead of fixes. This is because it is not always safe to automatically convert `||` to `??` within a mixed logical expression, as we cannot tell the intended precedence of the operator. Note that by design, `??` requires parentheses when used with `&&` or `||` in the same expression. -### forceSuggestionFixer +### `forceSuggestionFixer` Setting this option to `true` will cause the rule to use ESLint's "suggested fix" mode for all fixes. _This option is provided as to aid in transitioning your codebase onto this rule_. -Suggestion fixes cannot be automatically applied via the `--fix` CLI command, but can be _manually_ chosen to be applied one at a time via an IDE or similar. This makes it safe to run autofixers on an existing codebase without worrying about potential runtime behaviour changes from this rule's fixer. +Suggestion fixes cannot be automatically applied via the `--fix` CLI command, but can be _manually_ chosen to be applied one at a time via an IDE or similar. This makes it safe to run autofixers on an existing codebase without worrying about potential runtime behavior changes from this rule's fixer. ## When Not To Use It diff --git a/packages/eslint-plugin/docs/rules/prefer-readonly.md b/packages/eslint-plugin/docs/rules/prefer-readonly.md index f75a3c349cbe..8aad12befe44 100644 --- a/packages/eslint-plugin/docs/rules/prefer-readonly.md +++ b/packages/eslint-plugin/docs/rules/prefer-readonly.md @@ -48,7 +48,7 @@ class Container { This rule, in its default state, does not require any argument. -### onlyInlineLambdas +### `onlyInlineLambdas` You may pass `"onlyInlineLambdas": true` as a rule option within an object to restrict checking only to members immediately assigned a lambda value. diff --git a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md index 282907851b82..9e55a09595cb 100644 --- a/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md +++ b/packages/eslint-plugin/docs/rules/prefer-regexp-exec.md @@ -8,7 +8,7 @@ This rule is aimed at enforcing the more performant way of applying regular expr From [`String#match` on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match): -> If the regular expression does not include the g flag, returns the same result as RegExp.exec(). +> If the regular expression does not include the g flag, returns the same result as `RegExp.exec()`. From [Stack Overflow](https://stackoverflow.com/questions/9214754/what-is-the-difference-between-regexp-s-exec-function-and-string-s-match-fun) diff --git a/packages/eslint-plugin/docs/rules/quotes.md b/packages/eslint-plugin/docs/rules/quotes.md index e707a94b3d36..0a484e3fae7d 100644 --- a/packages/eslint-plugin/docs/rules/quotes.md +++ b/packages/eslint-plugin/docs/rules/quotes.md @@ -2,7 +2,7 @@ ## Rule Details -This rule extends the base [eslint/quotes](https://eslint.org/docs/rules/quotes) rule. +This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule. It supports all options and features of the base rule. ## How to use @@ -17,6 +17,6 @@ It supports all options and features of the base rule. ## Options -See [eslint/quotes options](https://eslint.org/docs/rules/quotes#options). +See [`eslint/quotes` options](https://eslint.org/docs/rules/quotes#options). Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/quotes.md) diff --git a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md index ead78b3c3d2e..4b56f999867b 100644 --- a/packages/eslint-plugin/docs/rules/require-array-sort-compare.md +++ b/packages/eslint-plugin/docs/rules/require-array-sort-compare.md @@ -10,7 +10,7 @@ This rule prevents to invoke `Array#sort()` method without `compare` argument. The language specification also noted this trap. -> NOTE 2: Method calls performed by the ToString abstract operations in steps 5 and 7 have the potential to cause SortCompare to not behave as a consistent comparison function.
> https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare +> NOTE 2: Method calls performed by the `ToString` abstract operations in steps 5 and 7 have the potential to cause `SortCompare` to not behave as a consistent comparison function.
> https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare ## Rule Details diff --git a/packages/eslint-plugin/docs/rules/require-await.md b/packages/eslint-plugin/docs/rules/require-await.md index cbc86681727c..1b7b819154d5 100644 --- a/packages/eslint-plugin/docs/rules/require-await.md +++ b/packages/eslint-plugin/docs/rules/require-await.md @@ -1,4 +1,4 @@ -# Disallow async functions which have no await expression (@typescript-eslint/require-await) +# Disallow async functions which have no await expression (require-await) Asynchronous functions that don’t use `await` might not need to be asynchronous functions and could be the unintentional result of refactoring. @@ -32,7 +32,7 @@ One way to resolve these errors is to remove the `async` keyword. However doing Another way to resolve these errors is to add an `await` keyword to the return statements. However doing so can cause a conflict with the [`no-return-await`](https://eslint.org/docs/rules/no-return-await) rule (if enabled), which warns against using `return await` since the return value of an `async` function is always wrapped in `Promise.resolve` anyway. -With the additional typing information available in Typescript code, this extension to the `require-await` rule is able to look at the _actual_ return types of an `async` function (before being implicitly wrapped in `Promise.resolve`), and avoid the need for an `await` expression when the return value is already a promise. +With the additional typing information available in TypeScript code, this extension to the `require-await` rule is able to look at the _actual_ return types of an `async` function (before being implicitly wrapped in `Promise.resolve`), and avoid the need for an `await` expression when the return value is already a promise. See the [ESLint documentation](https://eslint.org/docs/rules/require-await) for more details on the `require-await` rule. diff --git a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md index 7b5af55a84ff..179ededd25b9 100644 --- a/packages/eslint-plugin/docs/rules/restrict-plus-operands.md +++ b/packages/eslint-plugin/docs/rules/restrict-plus-operands.md @@ -21,7 +21,7 @@ This rule has an object option: - `"checkCompoundAssignments": false`: (default) does not check compound assignments (`+=`) - `"checkCompoundAssignments": true` -### checkCompoundAssignments +### `checkCompoundAssignments` Examples of **incorrect** code for the `{ "checkCompoundAssignments": true }` option: diff --git a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md index afd6976a227a..0cb1dd63e0bc 100644 --- a/packages/eslint-plugin/docs/rules/restrict-template-expressions.md +++ b/packages/eslint-plugin/docs/rules/restrict-template-expressions.md @@ -39,7 +39,7 @@ const defaults = { }; ``` -### allowNumber +### `allowNumber` Examples of additional **correct** code for this rule with `{ allowNumber: true }`: @@ -49,7 +49,7 @@ const msg1 = `arg = ${arg}`; const msg2 = `arg = ${arg || 'zero'}`; ``` -### allowBoolean +### `allowBoolean` Examples of additional **correct** code for this rule with `{ allowBoolean: true }`: @@ -59,7 +59,7 @@ const msg1 = `arg = ${arg}`; const msg2 = `arg = ${arg || 'not truthy'}`; ``` -### allowNullable +### `allowNullable` Examples of additional **correct** code for this rule with `{ allowNullable: true }`: diff --git a/packages/eslint-plugin/docs/rules/return-await.md b/packages/eslint-plugin/docs/rules/return-await.md index 606b501a7d28..eb7c41ef8fdb 100644 --- a/packages/eslint-plugin/docs/rules/return-await.md +++ b/packages/eslint-plugin/docs/rules/return-await.md @@ -1,4 +1,4 @@ -# Require/Disallow returning awaited values in specific contexts (@typescript-eslint/return-await) +# Require/Disallow returning awaited values in specific contexts (return-await) Returning an awaited promise can make sense for better stack trace information as well as for consistent error handling (returned promises will not be caught in an async function try/catch). diff --git a/packages/eslint-plugin/docs/rules/semi.md b/packages/eslint-plugin/docs/rules/semi.md index 77f8a7134617..2a93d22a3135 100644 --- a/packages/eslint-plugin/docs/rules/semi.md +++ b/packages/eslint-plugin/docs/rules/semi.md @@ -4,11 +4,11 @@ This rule enforces consistent use of semicolons after statements. ## Rule Details -This rule extends the base [eslint/semi](https://eslint.org/docs/rules/semi) rule. +This rule extends the base [`eslint/semi`](https://eslint.org/docs/rules/semi) rule. It supports all options and features of the base rule. This version adds support for numerous typescript features. -See also the [@typescript-eslint/member-delimiter-style](member-delimiter-style.md) rule, +See also the [`@typescript-eslint/member-delimiter-style`](member-delimiter-style.md) rule, which allows you to specify the delimiter for `type` and `interface` members. ## How to use @@ -23,6 +23,6 @@ which allows you to specify the delimiter for `type` and `interface` members. ## Options -See [eslint/semi options](https://eslint.org/docs/rules/semi#options). +See [`eslint/semi` options](https://eslint.org/docs/rules/semi#options). Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/semi.md) diff --git a/packages/eslint-plugin/docs/rules/space-before-function-paren.md b/packages/eslint-plugin/docs/rules/space-before-function-paren.md index 99c9bcdd9dd0..a25ea5002600 100644 --- a/packages/eslint-plugin/docs/rules/space-before-function-paren.md +++ b/packages/eslint-plugin/docs/rules/space-before-function-paren.md @@ -1,6 +1,6 @@ -# Require or disallow a space before function parenthesis (space-before-function-paren) +# Require or disallow a space before function parenthesis (`space-before-function-paren`) -When formatting a function, whitespace is allowed between the function name or `function` keyword and the opening paren. Named functions also require a space between the `function` keyword and the function name, but anonymous functions require no whitespace. For example: +When formatting a function, whitespace is allowed between the function name or `function` keyword and the opening parenthesis. Named functions also require a space between the `function` keyword and the function name, but anonymous functions require no whitespace. For example: ```ts @@ -21,7 +21,7 @@ Style guides may require a space after the `function` keyword for anonymous func ## Rule Details -This rule extends the base [eslint/func-call-spacing](https://eslint.org/docs/rules/space-before-function-paren) rule. +This rule extends the base [`eslint/space-before-function-paren`](https://eslint.org/docs/rules/space-before-function-paren) rule. It supports all options and features of the base rule. This version adds support for generic type parameters on function calls. @@ -37,6 +37,6 @@ This version adds support for generic type parameters on function calls. ## Options -See [eslint/space-before-function-paren options](https://eslint.org/docs/rules/space-before-function-paren#options). +See [`eslint/space-before-function-paren` options](https://eslint.org/docs/rules/space-before-function-paren#options). Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/space-before-function-paren.md) diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index 3dccaa925e9b..7f9324a417fe 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -14,7 +14,7 @@ With `{ "path": "never", "types": "never", "lib": "never" }` options set, the fo /// ``` -Examples of **incorrect** code for the `{ "types": "prefer-import" }` option. Note that these are only errors when **both** stlyes are used for the **same** module: +Examples of **incorrect** code for the `{ "types": "prefer-import" }` option. Note that these are only errors when **both** styles are used for the **same** module: ```ts /// diff --git a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md index baaef081941f..68075c277680 100644 --- a/packages/eslint-plugin/docs/rules/type-annotation-spacing.md +++ b/packages/eslint-plugin/docs/rules/type-annotation-spacing.md @@ -286,4 +286,4 @@ If you don't want to enforce spacing for your type annotations, you can safely t ## Compatibility -- TSLint: [typedef-whitespace](https://palantir.github.io/tslint/rules/typedef-whitespace/) +- TSLint: [`typedef-whitespace`](https://palantir.github.io/tslint/rules/typedef-whitespace/) diff --git a/packages/eslint-plugin/docs/rules/typedef.md b/packages/eslint-plugin/docs/rules/typedef.md index 89bc1d41e6f7..1efd2fa04378 100644 --- a/packages/eslint-plugin/docs/rules/typedef.md +++ b/packages/eslint-plugin/docs/rules/typedef.md @@ -1,4 +1,4 @@ -# Require type annotations to exist (typedef) +# Require type annotations to exist (`typedef`) TypeScript cannot always infer types for all places in code. Some locations require type annotations for their types to be inferred. @@ -59,7 +59,7 @@ For example, with the following configuration: - Type annotations on variables are required - Options otherwise adhere to the defaults -### arrayDestructuring +### `arrayDestructuring` Whether to enforce type annotations on variables declared using array destructuring. @@ -78,7 +78,7 @@ const [b]: [number] = [2]; const [c, d]: [boolean, string] = [true, 'text']; ``` -### arrowParameter +### `arrowParameter` Whether to enforce type annotations for parameters of arrow functions. @@ -106,7 +106,7 @@ const mapper = { }; ``` -### memberVariableDeclaration +### `memberVariableDeclaration` Whether to enforce type annotations on member variables of classes. @@ -128,7 +128,7 @@ class ContainsText { } ``` -### objectDestructuring +### `objectDestructuring` Whether to enforce type annotations on variables declared using object destructuring. @@ -146,7 +146,7 @@ const { length }: { length: number } = 'text'; const [b, c]: [number, number] = Math.random() ? [1, 2] : [3, 4]; ``` -### parameter +### `parameter` Whether to enforce type annotations for parameters of functions and methods. @@ -206,7 +206,7 @@ class Logger { } ``` -### propertyDeclaration +### `propertyDeclaration` Whether to enforce type annotations for properties of interfaces and types. @@ -228,7 +228,7 @@ type Members = { }; ``` -### variableDeclaration +### `variableDeclaration` Whether to enforce type annotations for variable declarations, excluding array and object destructuring. @@ -261,4 +261,4 @@ In general, if you do not consider the cost of writing unnecessary type annotati ## Compatibility -- TSLint: [typedef](https://palantir.github.io/tslint/rules/typedef) +- TSLint: [`typedef`](https://palantir.github.io/tslint/rules/typedef) diff --git a/packages/eslint-plugin/docs/rules/unified-signatures.md b/packages/eslint-plugin/docs/rules/unified-signatures.md index 7fe46beceafc..11f79b10c5b7 100644 --- a/packages/eslint-plugin/docs/rules/unified-signatures.md +++ b/packages/eslint-plugin/docs/rules/unified-signatures.md @@ -4,7 +4,7 @@ Warns for any two overloads that could be unified into one by using a union or a ## Rule Details -This rule aims to keep the source code as maintanable as posible by reducing the amount of overloads. +This rule aims to keep the source code as maintainable as possible by reducing the amount of overloads. Examples of **incorrect** code for this rule: diff --git a/packages/eslint-plugin/src/configs/README.md b/packages/eslint-plugin/src/configs/README.md index 48b3f27444ef..d9c5d8e39104 100644 --- a/packages/eslint-plugin/src/configs/README.md +++ b/packages/eslint-plugin/src/configs/README.md @@ -2,13 +2,9 @@ These configs exist for your convenience. They contain configuration intended to save you time and effort when configuring your project by disabling rules known to conflict with this repository, or cause issues in TypeScript codebases. -## All +## `eslint-recommended` -TODO when all config is added. - -## eslint-recommended - -The `eslint-recommended` ruleset is meant to be used after extending `eslint:recommended`. It disables rules that are already checked by the Typescript compiler and enables rules that promote using the more modern constructs Typescript allows for. +The `eslint-recommended` ruleset is meant to be used after extending `eslint:recommended`. It disables rules that are already checked by the TypeScript compiler and enables rules that promote using the more modern constructs TypeScript allows for. ```cjson { @@ -19,7 +15,7 @@ The `eslint-recommended` ruleset is meant to be used after extending `eslint:rec } ``` -## Recommended +## `recommended` The recommended set is an **_opinionated_** set of rules that we think you should use because: diff --git a/packages/experimental-utils/README.md b/packages/experimental-utils/README.md index 0dd9299b2b9c..d1358ea7532e 100644 --- a/packages/experimental-utils/README.md +++ b/packages/experimental-utils/README.md @@ -1,10 +1,10 @@ -# @typescript-eslint/experimental-utils +# `@typescript-eslint/experimental-utils` (Experimental) Utilities for working with TypeScript + ESLint together. ## Note -This package has inherited its version number from the @typescript-eslint project. +This package has inherited its version number from the `@typescript-eslint` project. Meaning that even though this package is `1.x.y`, you shouldn't expect 100% stability between minor version bumps. i.e. treat it as a `0.x.y` package. @@ -14,19 +14,11 @@ Once it is stable, it will be renamed to `@typescript-eslint/util` for a `2.0.0` ## Exports -| Name | Description | -| ------------------- | ---------------------------------------------------------------------------------------------- | -| [`TSESTree`] | Types for the TypeScript flavour of ESTree created by `@typescript-eslint/typescript-estree`. | -| [`AST_NODE_TYPES`] | An enum with the names of every single _node_ found in `TSESTree`. | -| [`AST_TOKEN_TYPES`] | An enum with the names of every single _token_ found in `TSESTree`. | -| [`TSESLint`] | Types for ESLint, correctly typed to work with the types found in `TSESTree`. | -| [`ESLintUtils`] | Tools for creating eslint rules with TypeScript. | -| [`ParserServices`] | The parser services provided when parsing a file using `@typescript-eslint/typescript-estree`. | - -[`ast_node_types`]: ../packages/typescript-estree/src/ts-estree/ast-node-types.ts -[`ast_token_types`]: ../packages/typescript-estree/src/ts-estree/ast-node-types.ts -[`eslintutils`]: ./src/eslint-utils -[`eslintutils.createrule`]: ./src/eslint-utils/createRule.ts -[`parserservices`]: ../packages/typescript-estree/src/ts-estree/parser.ts -[`tsestree`]: ../packages/typescript-estree/src/ts-estree/ts-estree.ts -[`tseslint`]: ./src/ts-eslint +| Name | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| [`TSESTree`](../packages/typescript-estree/src/ts-estree/ts-estree.ts) | Types for the TypeScript flavor of ESTree created by `@typescript-eslint/typescript-estree`. | +| [`AST_NODE_TYPES`](../packages/typescript-estree/src/ts-estree/ast-node-types.ts) | An enum with the names of every single _node_ found in `TSESTree`. | +| [`AST_TOKEN_TYPES`](../packages/typescript-estree/src/ts-estree/ast-node-types.ts) | An enum with the names of every single _token_ found in `TSESTree`. | +| [`TSESLint`](./src/ts-eslint) | Types for ESLint, correctly typed to work with the types found in `TSESTree`. | +| [`ESLintUtils`](./src/eslint-utils) | Tools for creating ESLint rules with TypeScript. | +| [`ParserServices`](../packages/typescript-estree/src/ts-estree/parser.ts) | The parser services provided when parsing a file using `@typescript-eslint/typescript-estree`. | diff --git a/packages/parser/README.md b/packages/parser/README.md index 3ee42a4b5ddc..06a5a2abd3c3 100644 --- a/packages/parser/README.md +++ b/packages/parser/README.md @@ -10,13 +10,21 @@ Commitizen friendly

-## Installation: +## Getting Started + +**[You can find our Getting Started docs here](../../docs/getting-started/linting/README.md)** + +These docs walk you through setting up ESLint, this parser, and our plugin. If you know what you're doing and just want to quick start, read on... + +## Quick-start + +### Installation ```sh -npm install @typescript-eslint/parser --save-dev +yarn add -D @typescript-eslint/parser ``` -## Usage +### Usage In your ESLint configuration file, set the `parser` property: @@ -34,101 +42,115 @@ The core rules built into ESLint, such as `indent` have no knowledge of such con Instead, you also need to make use of one more plugins which will add or extend rules with TypeScript-specific features. -By far the most common case will be installing the [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) plugin, but there are also other relevant options available such a [@typescript-eslint/eslint-plugin-tslint](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin-tslint). +By far the most common case will be installing the [`@typescript-eslint/eslint-plugin`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) plugin, but there are also other relevant options available such a [`@typescript-eslint/eslint-plugin-tslint`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin-tslint). ## Configuration The following additional configuration options are available by specifying them in [`parserOptions`](https://eslint.org/docs/user-guide/configuring#specifying-parser-options) in your ESLint configuration file. -- **`ecmaFeatures.jsx`** - default `false`. Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html). +```ts +interface ParserOptions { + ecmaFeatures?: { + jsx?: boolean; + }; + project?: string | string[]; + tsconfigRootDir?: string; + extraFileExtensions?: string[]; + warnOnUnsupportedTypeScriptVersion?: boolean; +} +``` - NOTE: this setting does not affect known file types (.js, .jsx, .ts, .tsx, .json) because the typescript compiler has its own internal handling for known file extensions. The exact behaviour is as follows: +### `parserOptions.ecmaFeatures.jsx` - - if `parserOptions.project` is _not_ provided: - - `.js`, `.jsx`, `.tsx` files are parsed as if this is true. - - `.ts` files are parsed as if this is false. - - unknown extensions (`.md`, `.vue`) will respect this setting. - - if `parserOptions.project` is provided (i.e. you are using rules with type information): - - `.js`, `.jsx`, `.tsx` files are parsed as if this is true. - - `.ts` files are parsed as if this is false. - - "unknown" extensions (`.md`, `.vue`) **are parsed as if this is false**. +Default `false`. -- **`useJSXTextNode`** - default `true`. Please set `false` if you use this parser on ESLint v4. If this is `false`, the parser creates the AST of JSX texts as the legacy style. +Enable parsing JSX when `true`. More details can be found [here](https://www.typescriptlang.org/docs/handbook/jsx.html). -- **`project`** - default `undefined`. This option allows you to provide a path to your project's `tsconfig.json`. **This setting is required if you want to use rules which require type information**. You may want to use this setting in tandem with the `tsconfigRootDir` option below. +**NOTE:** this setting does not affect known file types (`.js`, `.jsx`, `.ts`, `.tsx`, `.json`) because the typescript compiler has its own internal handling for known file extensions. The exact behavior is as follows: - - Accepted values: +- if `parserOptions.project` is _not_ provided: + - `.js`, `.jsx`, `.tsx` files are parsed as if this is true. + - `.ts` files are parsed as if this is false. + - unknown extensions (`.md`, `.vue`) will respect this setting. +- if `parserOptions.project` is provided (i.e. you are using rules with type information): + - `.js`, `.jsx`, `.tsx` files are parsed as if this is true. + - `.ts` files are parsed as if this is false. + - "unknown" extensions (`.md`, `.vue`) **are parsed as if this is false**. - ```js - // path - project: './tsconfig.json'; +### `parserOptions.project` - // glob pattern - project: './packages/**/tsconfig.json'; +Default `undefined`. - // array of paths and/or glob patterns - project: [ - './packages/**/tsconfig.json', - './separate-package/tsconfig.json', - ]; - ``` +This option allows you to provide a path to your project's `tsconfig.json`. **This setting is required if you want to use rules which require type information**. You may want to use this setting in tandem with the `tsconfigRootDir` option below. - - If you use project references, TypeScript will not automatically use project references to resolve files. This means that you will have to add each referenced tsconfig to the `project` field either separately, or via a glob. +- Accepted values: - - TypeScript will ignore files with duplicate filenames in the same folder (for example, `src/file.ts` and `src/file.js`). TypeScript purposely ignore all but one of the files, only keeping the one file with the highest priority extension (the extension priority order (from highest to lowest) is `.ts`, `.tsx`, `.d.ts`, `.js`, `.jsx`). For more info see #955. + ```js + // path + project: './tsconfig.json'; - - Note that if this setting is specified and `createDefaultProgram` is not, you must only lint files that are included in the projects as defined by the provided `tsconfig.json` files. If your existing configuration does not include all of the files you would like to lint, you can create a separate `tsconfig.eslint.json` as follows: + // glob pattern + project: './packages/**/tsconfig.json'; - ```jsonc - { - // extend your base config so you don't have to redefine your compilerOptions - "extends": "./tsconfig.json", - "include": [ - "src/**/*.ts", - "test/**/*.ts", - "typings/**/*.ts", - // etc + // array of paths and/or glob patterns + project: ['./packages/**/tsconfig.json', './separate-package/tsconfig.json']; + ``` - // if you have a mixed JS/TS codebase, don't forget to include your JS files - "src/**/*.js" - ] - } - ``` +- If you use project references, TypeScript will not automatically use project references to resolve files. This means that you will have to add each referenced tsconfig to the `project` field either separately, or via a glob. -- **`tsconfigRootDir`** - default `undefined`. This option allows you to provide the root directory for relative tsconfig paths specified in the `project` option above. +- TypeScript will ignore files with duplicate filenames in the same folder (for example, `src/file.ts` and `src/file.js`). TypeScript purposely ignore all but one of the files, only keeping the one file with the highest priority extension (the extension priority order (from highest to lowest) is `.ts`, `.tsx`, `.d.ts`, `.js`, `.jsx`). For more info see #955. -- **`extraFileExtensions`** - default `undefined`. This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation. E.g. a `.vue` file +- Note that if this setting is specified and `createDefaultProgram` is not, you must only lint files that are included in the projects as defined by the provided `tsconfig.json` files. If your existing configuration does not include all of the files you would like to lint, you can create a separate `tsconfig.eslint.json` as follows: -- **`warnOnUnsupportedTypeScriptVersion`** - default `true`. This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported + ```jsonc + { + // extend your base config so you don't have to redefine your compilerOptions + "extends": "./tsconfig.json", + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "typings/**/*.ts", + // etc -- **`createDefaultProgram`** - default `false`. This option allows you to request that when the `project` setting is specified, files will be allowed when not included in the projects defined by the provided `tsconfig.json` files. **Using this option will incur significant performance costs. This option is primarily included for backwards-compatibility.** See the **`project`** section above for more information. + // if you have a mixed JS/TS codebase, don't forget to include your JS files + "src/**/*.js" + ] + } + ``` -### .eslintrc.json +### `tsconfigRootDir` -```json -{ - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "useJSXTextNode": true, - "project": "./tsconfig.json", - "tsconfigRootDir": "../../", - "extraFileExtensions": [".vue"] - } -} -``` +Default `undefined`. + +This option allows you to provide the root directory for relative tsconfig paths specified in the `project` option above. + +### `extraFileExtensions` + +Default `undefined`. + +This option allows you to provide one or more additional file extensions which should be considered in the TypeScript Program compilation. E.g. a `.vue` file + +### `warnOnUnsupportedTypeScriptVersion` + +Default `true`. + +This option allows you to toggle the warning that the parser will give you if you use a version of TypeScript which is not explicitly supported + +### `createDefaultProgram` + +Default `false`. + +This option allows you to request that when the `project` setting is specified, files will be allowed when not included in the projects defined by the provided `tsconfig.json` files. **Using this option will incur significant performance costs. This option is primarily included for backwards-compatibility.** See the **`project`** section above for more information. ## Supported TypeScript Version -Please see https://github.com/typescript-eslint/typescript-eslint for the supported TypeScript version. +Please see [`typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint) for the supported TypeScript version. **Please ensure that you are using a supported version before submitting any issues/bug reports.** ## Reporting Issues -Please use the @typescript-eslint/parser issue template when creating your issue and fill out the information requested as best you can. This will really help us when looking into your issue. +Please use the `@typescript-eslint/parser` issue template when creating your issue and fill out the information requested as best you can. This will really help us when looking into your issue. ## License diff --git a/packages/typescript-estree/README.md b/packages/typescript-estree/README.md index aca6f215dcb1..83db9c4b71e6 100644 --- a/packages/typescript-estree/README.md +++ b/packages/typescript-estree/README.md @@ -24,7 +24,7 @@ In fact, it is already used within these hyper-popular open-source projects to p ## Installation ```sh -npm install @typescript-eslint/typescript-estree --save-dev +yarn add -D @typescript-eslint/typescript-estree ``` ## API @@ -51,7 +51,7 @@ Parses the given string of code with the options provided and returns an ESTree- * enable parsing JSX. For more details, see https://www.typescriptlang.org/docs/handbook/jsx.html * * NOTE: this setting does not effect known file types (.js, .jsx, .ts, .tsx, .json) because the - * typescript compiler has its own internal handling for known file extensions. + * TypeScript compiler has its own internal handling for known file extensions. * * Exact behaviour: * - .js, .jsx, .tsx files are parsed as if this is true @@ -105,7 +105,7 @@ const ast = parser.parse(code, { ### version -Exposes the current version of typescript-estree as specified in package.json. +Exposes the current version of `typescript-estree` as specified in `package.json`. Example usage: @@ -114,7 +114,7 @@ const parser = require('@typescript-eslint/typescript-estree'); const version = parser.version; ``` -### AST_NODE_TYPES +### `AST_NODE_TYPES` Exposes an object that contains the AST node types produced by the parser. @@ -146,7 +146,7 @@ Please check the current list of open and known issues and ensure the issue has A couple of years after work on this parser began, the TypeScript Team at Microsoft began [officially supporting TypeScript parsing via Babel](https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/). -I work closely with the TypeScript Team and we are gradually aliging the AST of this project with the one produced by Babel's parser. To that end, I have created a full test harness to compare the ASTs of the two projects which runs on every PR, please see the code for more details. +I work closely with the TypeScript Team and we are gradually aligning the AST of this project with the one produced by Babel's parser. To that end, I have created a full test harness to compare the ASTs of the two projects which runs on every PR, please see the code for more details. ## Build/Test Commands diff --git a/tests/performance/README.md b/tests/performance/README.md index 18dfdd118159..ff1fd5864821 100644 --- a/tests/performance/README.md +++ b/tests/performance/README.md @@ -18,7 +18,7 @@ docker exec -it {{ RUNNING_CONTAINER_ID_HERE }} bash Or by using the docker extension in VSCode and right clicking on the running container. -Every time you make an update to the local built packages (e.g. parser or eslint-plugin), you need to rerun +Every time you make an update to the local built packages (e.g. `parser` or `eslint-plugin`), you need to rerun the utility script _within_ the running container. For example, you will run something like the following (where `root@a91d93f9ffc3` refers to what's running in your container): diff --git a/yarn.lock b/yarn.lock index d5244e2d13b6..d32b5a041415 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1593,6 +1593,11 @@ all-contributors-cli@^6.11.0: request "^2.72.0" yargs "^14.0.0" +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + integrity sha1-06ioOzGapneTZisT52HHkRQiMG4= + ansi-escapes@^3.0.0, ansi-escapes@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" @@ -1736,7 +1741,7 @@ array-includes@^3.0.3: define-properties "^1.1.2" es-abstract "^1.7.0" -array-union@^1.0.2: +array-union@^1.0.1, array-union@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= @@ -1795,6 +1800,13 @@ async-limiter@~1.0.0: resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== +async@^2.1.4: + version "2.6.3" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" + integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + dependencies: + lodash "^4.17.14" + async@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/async/-/async-3.1.0.tgz#42b3b12ae1b74927b5217d8c0016baaf62463772" @@ -2174,6 +2186,13 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" + integrity sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc= + dependencies: + restore-cursor "^1.0.1" + cli-cursor@^2.0.0, cli-cursor@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" @@ -2277,6 +2296,11 @@ commander@^2.12.1, commander@^2.20.0, commander@~2.20.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.1.tgz#3863ce3ca92d0831dcf2a102f5fb4b5926afd0f9" integrity sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg== +commander@^2.8.1: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + commitizen@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/commitizen/-/commitizen-4.0.3.tgz#c19a4213257d0525b85139e2f36db7cc3b4f6dae" @@ -2316,7 +2340,7 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@^1.5.0: +concat-stream@^1.4.7, concat-stream@^1.5.0: version "1.6.2" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== @@ -2507,6 +2531,14 @@ cosmiconfig@^5.1.0, cosmiconfig@^5.2.0, cosmiconfig@^5.2.1: js-yaml "^3.13.1" parse-json "^4.0.0" +create-thenable@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/create-thenable/-/create-thenable-1.0.2.tgz#e2031720ccc9575d8cfa31f5c146e762a80c0534" + integrity sha1-4gMXIMzJV12M+jH1wUbnYqgMBTQ= + dependencies: + object.omit "~2.0.0" + unique-concat "~0.2.2" + cross-spawn@^6.0.0, cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" @@ -3166,6 +3198,11 @@ execa@^2.0.3: signal-exit "^3.0.2" strip-final-newline "^2.0.0" +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + integrity sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g= + exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -3218,11 +3255,20 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@~3.0.2: +extend@^3.0.0, extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== +external-editor@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-1.1.1.tgz#12d7b0db850f7ff7e7081baf4005700060c4600b" + integrity sha1-Etew24UPf/fnCBuvQAVwAGDEYAs= + dependencies: + extend "^3.0.0" + spawn-sync "^1.0.15" + tmp "^0.0.29" + external-editor@^3.0.3: version "3.1.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495" @@ -3314,7 +3360,7 @@ figgy-pudding@^3.4.1, figgy-pudding@^3.5.1: resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.1.tgz#862470112901c727a0e495a80744bd5baa1d6790" integrity sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w== -figures@^1.7.0: +figures@^1.3.5, figures@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" integrity sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4= @@ -3435,11 +3481,18 @@ flush-write-stream@^1.0.0: inherits "^2.0.3" readable-stream "^2.3.6" -for-in@^1.0.2: +for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= +for-own@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + integrity sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4= + dependencies: + for-in "^1.0.1" + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -3756,6 +3809,17 @@ globby@^10.0.1: merge2 "^1.2.3" slash "^3.0.0" +globby@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" + integrity sha1-9abXDoOV4hyFj7BInWTfAkJNUGw= + dependencies: + array-union "^1.0.1" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + globby@^9.2.0: version "9.2.0" resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d" @@ -3925,6 +3989,11 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" +hunspell-spellchecker@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/hunspell-spellchecker/-/hunspell-spellchecker-1.0.2.tgz#a10b0bd2fa00a65ab62a4c6b734ce496d318910e" + integrity sha1-oQsL0voAplq2Kkxrc0zkltMYkQ4= + husky@^3.0.9: version "3.0.9" resolved "https://registry.yarnpkg.com/husky/-/husky-3.0.9.tgz#a2c3e9829bfd6b4957509a9500d2eef5dbfc8044" @@ -4073,6 +4142,26 @@ inquirer@6.5.0: strip-ansi "^5.1.0" through "^2.3.6" +inquirer@^1.0.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-1.2.3.tgz#4dec6f32f37ef7bb0b2ed3f1d1a5c3f545074918" + integrity sha1-TexvMvN+97sLLtPx0aXD9UUHSRg= + dependencies: + ansi-escapes "^1.1.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + external-editor "^1.1.0" + figures "^1.3.5" + lodash "^4.3.0" + mute-stream "0.0.6" + pinkie-promise "^2.0.0" + run-async "^2.2.0" + rx "^4.1.0" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + inquirer@^6.2.0, inquirer@^6.2.1: version "6.5.2" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca" @@ -4838,7 +4927,7 @@ jest@^24.9.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@^3.13.1: +js-yaml@^3.10.0, js-yaml@^3.13.1: version "3.13.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847" integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw== @@ -5230,7 +5319,7 @@ lodash@4.17.14: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba" integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw== -lodash@4.17.15, lodash@^4.11.2, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.2.1: +lodash@4.17.15, lodash@^4.11.2, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.2.1, lodash@^4.3.0: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== @@ -5356,6 +5445,26 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +markdown-spellcheck@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/markdown-spellcheck/-/markdown-spellcheck-1.3.1.tgz#e901b04631e759ad8903470db3261013c2712602" + integrity sha512-9uyovbDg3Kh2H89VDtqOkXKS9wuRgpLvOHXzPYWMR71tHQZWt2CAf28EIpXNhkFqqoEjXYAx+fXLuKufApYHRQ== + dependencies: + async "^2.1.4" + chalk "^2.0.1" + commander "^2.8.1" + globby "^6.1.0" + hunspell-spellchecker "^1.0.2" + inquirer "^1.0.0" + js-yaml "^3.10.0" + marked "^0.3.5" + sinon-as-promised "^4.0.0" + +marked@^0.3.5: + version "0.3.19" + resolved "https://registry.yarnpkg.com/marked/-/marked-0.3.19.tgz#5d47f709c4c9fc3c216b6d46127280f40b39d790" + integrity sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg== + marked@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/marked/-/marked-0.7.0.tgz#b64201f051d271b1edc10a04d1ae9b74bb8e5c0e" @@ -5591,6 +5700,11 @@ multimatch@^3.0.0: arrify "^1.0.1" minimatch "^3.0.4" +mute-stream@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db" + integrity sha1-SJYrGeFp/R38JAs/HnMXYnu8R9s= + mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" @@ -5632,6 +5746,11 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" +native-promise-only@~0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/native-promise-only/-/native-promise-only-0.8.1.tgz#20a318c30cb45f71fe7adfbf7b21c99c1472ef11" + integrity sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE= + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -5898,6 +6017,14 @@ object.getownpropertydescriptors@^2.0.3: define-properties "^1.1.2" es-abstract "^1.5.1" +object.omit@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + integrity sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo= + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + object.pick@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" @@ -5927,6 +6054,11 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + integrity sha1-ofeDj4MUxRbwXs78vEzP4EtO14k= + onetime@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" @@ -5991,7 +6123,12 @@ os-name@^3.1.0: macos-release "^2.2.0" windows-release "^3.1.0" -os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: +os-shim@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917" + integrity sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc= + +os-tmpdir@^1.0.0, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= @@ -6817,6 +6954,14 @@ resolve@1.x, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.3.2, r dependencies: path-parse "^1.0.6" +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + integrity sha1-NGYfRohjJ/7SmRR5FSJS35LapUE= + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" + restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" @@ -6903,6 +7048,11 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" +rx@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" + integrity sha1-pfE/957zt0D+MKqAP7CfmIBdR4I= + rxjs@^6.3.3, rxjs@^6.4.0: version "6.5.3" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.3.tgz#510e26317f4db91a7eb1de77d9dd9ba0a4899a3a" @@ -7023,6 +7173,14 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= +sinon-as-promised@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/sinon-as-promised/-/sinon-as-promised-4.0.3.tgz#c0545b1685fd813588a4ed697012487ed11d151b" + integrity sha1-wFRbFoX9gTWIpO1pcBJIftEdFRs= + dependencies: + create-thenable "~1.0.0" + native-promise-only "~0.8.1" + sisteransi@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.3.tgz#98168d62b79e3a5e758e27ae63c4a053d748f4eb" @@ -7154,6 +7312,14 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +spawn-sync@^1.0.15: + version "1.0.15" + resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476" + integrity sha1-sAeZVX63+wyDdsKdROih6mfldHY= + dependencies: + concat-stream "^1.4.7" + os-shim "^0.1.2" + spdx-correct@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" @@ -7572,6 +7738,13 @@ through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= +tmp@^0.0.29: + version "0.0.29" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.29.tgz#f25125ff0dd9da3ccb0c2dd371ee1288bb9128c0" + integrity sha1-8lEl/w3Z2jzLDC3Tce4SiLuRKMA= + dependencies: + os-tmpdir "~1.0.1" + tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" @@ -7808,6 +7981,11 @@ union-value@^1.0.0: is-extendable "^0.1.1" set-value "^2.0.1" +unique-concat@~0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/unique-concat/-/unique-concat-0.2.2.tgz#9210f9bdcaacc5e1e3929490d7c019df96f18712" + integrity sha1-khD5vcqsxeHjkpSQ18AZ35bxhxI= + unique-filename@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230"