Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
auvred committed Apr 30, 2024
2 parents c65abae + 7984ef7 commit 7bea876
Show file tree
Hide file tree
Showing 75 changed files with 1,276 additions and 294 deletions.
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"Airbnb",
"Airbnb's",
"ambiently",
"allowdefaultprojectforfiles",
"Armano",
"astexplorer",
"Astro",
Expand Down Expand Up @@ -150,6 +151,7 @@
"unoptimized",
"unprefixed",
"upsert",
"useprojectservice",
"Waiblinger",
"warnonunsupportedtypescriptversion",
"Zacher"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ jobs:
uses: ./.github/actions/prepare-build

- name: Figure out and apply the next canary version
run: npx nx run repo-tools:apply-canary-version
run: OVERRIDE_MAJOR_VERSION=8 npx nx run repo-tools:apply-canary-version

- name: Publish all packages to npm with the canary tag
# NOTE: this needs to be npx, rather than yarn, to make sure the authenticated npm registry is used
run: npx lerna publish premajor --loglevel=verbose --canary --exact --force-publish --yes --dist-tag rc-v8
run: npx nx release publish --tag rc-v8 --verbose
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## 7.8.0 (2024-04-29)


### 🚀 Features

- **rule-tester:** assert suggestion messages are unique ([#8995](https://github.com/typescript-eslint/typescript-eslint/pull/8995))
- **typescript-estree:** add maximumDefaultProjectFileMatchCount and wide allowDefaultProjectForFiles glob restrictions ([#8925](https://github.com/typescript-eslint/typescript-eslint/pull/8925))

### 🩹 Fixes

- **eslint-plugin:** [no-unsafe-argument] handle tagged templates ([#8746](https://github.com/typescript-eslint/typescript-eslint/pull/8746))
- **eslint-plugin:** [prefer-optional-chain] suggests optional chaining during strict null equality check ([#8717](https://github.com/typescript-eslint/typescript-eslint/pull/8717))
- **eslint-plugin:** [consistent-type-assertions] handle tagged templates ([#8993](https://github.com/typescript-eslint/typescript-eslint/pull/8993))
- **eslint-plugin:** [no-unsafe-return] handle union types ([#9001](https://github.com/typescript-eslint/typescript-eslint/pull/9001))
- **eslint-plugin:** [no-unused-vars] clear error report range ([#8640](https://github.com/typescript-eslint/typescript-eslint/pull/8640))
- **utils:** export ESLint backwards-compat functions ([#8976](https://github.com/typescript-eslint/typescript-eslint/pull/8976))

### ❤️ Thank You

- auvred @auvred
- Josh Goldberg ✨
- jsfm01 @jsfm01
- Kim Sang Du @developer-bandi
- YeonJuan @yeonjuan

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.

## 7.7.1 (2024-04-22)


Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<p align="center">
👆
</p>
<p align="center">
Using ESLint v9? See: <a href="https://github.com/typescript-eslint/typescript-eslint/issues/8211">ESLint v9 Support</a>.
</p>
<!-- markdownlint-enable MD033 -->

## Code Contributors
Expand Down
34 changes: 32 additions & 2 deletions docs/getting-started/Legacy_ESLint_Setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,40 @@ ESLint will lint all TypeScript compatible files within the current folder, and

## Next Steps

We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit _Typed Rules_ for a setup guide](./Typed_Linting.mdx).

If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](../troubleshooting/FAQ.mdx).

### Additional Configs

We recommend you consider enabling the following two configs:

- [`strict`](../users/Shared_Configurations.mdx#strict): a superset of `recommended` that includes more opinionated rules which may also catch bugs.
- [`stylistic`](../users/Shared_Configurations.mdx#stylistic): additional rules that enforce consistent styling without significantly catching bugs or changing logic.

```js title=".eslintrc.cjs"
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
// Remove this line
'plugin:@typescript-eslint/recommended',
// Added lines start
'plugin:@typescript-eslint/strict',
'plugin:@typescript-eslint/stylistic',
// Added lines end
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
root: true,
};
```

You can read more about these in our [shared configurations docs](../users/Shared_Configurations.mdx).

### Typed Linting

We also provide a plethora of powerful rules that utilize the power of TypeScript's type information.
[Visit the next page for a typed rules setup guide](./Typed_Linting.mdx).

### Documentation Resources

- You can read more about configuring ESLint [in their documentation on configuration](https://eslint.org/docs/user-guide/configuring).
Expand Down
43 changes: 31 additions & 12 deletions docs/getting-started/Quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ pagination_next: getting-started/typed-linting
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Quickstart

This page is a quick-start for [ESLint's new "flat" config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) to go from zero to linting with our recommended rules on your TypeScript code as quickly as possible.

:::note
This page is a quick-start guide for [ESLint's new "flat" config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) to help you go from zero to linting as quick as possible.

- For the same guide but for [ESLint's legacy format](https://eslint.org/docs/latest/use/configure/configuration-files) — see [Legacy ESLint Setup](./Legacy_ESLint_Setup.mdx).
- For quickstart information on linting with type information — see [Typed Linting](./Typed_Linting.mdx).

:::

## Quickstart

These steps will get you running ESLint with our recommended rules on your TypeScript code as quickly as possible.

### Step 1: Installation

First, install the required packages for [ESLint](https://eslint.org), [TypeScript](https://typescriptlang.org), and [our tooling](../packages/TypeScript_ESLint.mdx):
Expand Down Expand Up @@ -82,18 +81,38 @@ ESLint will lint all TypeScript compatible files within the current folder, and
- `'@eslint/js'` / `eslint.configs.recommended` turns on [eslint's recommended config](https://www.npmjs.com/package/@eslint/js).
- `...tseslint.configs.recommended` turns on [our recommended config](../users/Shared_Configurations.mdx#recommended).

See [ESLint's Configuration Files docs](https://eslint.org/docs/user-guide/configuring/configuration-files-new) for more details on configuring ESLint.

## Next Steps

We provide a plethora of powerful rules that utilize the power of TypeScript's type information.
If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](../troubleshooting/FAQ.mdx).

[Visit the next page for a setup guide](./Typed_Linting.mdx 'Visit the next page for a typed rules setup guide').
### Additional Configs

If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](../troubleshooting/FAQ.mdx).
We recommend you consider enabling the following two configs:

- [`strict`](../users/Shared_Configurations.mdx#strict): a superset of `recommended` that includes more opinionated rules which may also catch bugs.
- [`stylistic`](../users/Shared_Configurations.mdx#stylistic): additional rules that enforce consistent styling without significantly catching bugs or changing logic.

```js title="eslint.config.js"
export default tseslint.config(
eslint.configs.recommended,
// Remove this line
...tseslint.configs.recommended,
// Add this line
...tseslint.configs.strict,
// Add this line
...tseslint.configs.stylistic,
);
```

You can read more about these in our [shared configurations docs](../users/Shared_Configurations.mdx).

### Typed Linting

We also provide a plethora of powerful rules that utilize the power of TypeScript's type information.
[Visit the next page for a typed rules setup guide](./Typed_Linting.mdx).

### Documentation Resources
## Documentation Resources

- 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 typescript-eslint in [our rules documentation](/rules).
- You can read more about the rules provided by typescript-eslint in our [rules documentation](/rules).
80 changes: 65 additions & 15 deletions docs/getting-started/Typed_Linting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ To tap into TypeScript's additional powers, there are two small changes you need
<Tabs groupId="eslint-config">
<TabItem value="Flat Config">

1. Add `TypeChecked` to the name of any preset configs you're using, namely `recommended`, `strict`, and `stylistic`.
2. Add `languageOptions.parserOptions` to tell our parser how to find the TSConfig for each source file.

```js title="eslint.config.js"
export default tseslint.config(
eslint.configs.recommended,
Expand All @@ -39,13 +42,16 @@ For CommonJS modules and/or older versions of Node.js, [use `__dirname` or an al

In more detail:

- `tseslint.configs.recommendedTypeChecked` is another [recommended configuration](../users/Shared_Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
- `parserOption.project` tells our parser how to find the TSConfig for each source file (`true` indicates to find the closest `tsconfig.json` for each source file)
- If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.mdx).
- `tseslint.configs.recommendedTypeChecked` is another [shared configuration](../users/Shared_Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
- `parserOptions.project: true` indicates to find the closest `tsconfig.json` for each source file (see [Parser#project](../packages/Parser.mdx#project)).
- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory (see [Parser#tsconfigRootDir](../packages/Parser.mdx#tsconfigrootdir)).

</TabItem>
<TabItem value="Legacy Config">

1. Add `-type-checked` to the name of any preset configs you're using, namely `recommended`, `strict`, and `stylistic`.
2. Add `parserOptions` to tell our parser how to find the TSConfig for each source file.

```js title=".eslintrc.cjs"
/* eslint-env node */
module.exports = {
Expand All @@ -70,9 +76,8 @@ module.exports = {

In more detail:

- `plugin:@typescript-eslint/recommended-type-checked` is another [recommended configuration](../users/Shared_Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
- `parserOptions.project` tells our parser how to find the TSConfig for each source file (`true` indicates to find the closest `tsconfig.json` for each source file)
- If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.mdx).
- `plugin:@typescript-eslint/recommended-type-checked` is another [shared configuration](../users/Shared_Configurations.mdx) we provide. This one contains recommended rules that additionally require type information.
- `parserOptions.project: true` indicates to find the closest `tsconfig.json` for each source file (see [Parser#project](../packages/Parser.mdx#project)).
- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory (see [Parser#tsconfigRootDir](../packages/Parser.mdx#tsconfigrootdir)).

</TabItem>
Expand All @@ -86,7 +91,57 @@ See [our TSConfig inclusion FAQ](../troubleshooting/FAQ.mdx#i-get-errors-telling
With that done, run the same lint command you ran before.
You may see new rules reporting errors based on type information!

## Specifying TSConfigs
## Shared Configurations

If you enabled the [`strict` shared config](../users/Shared_Configurations.mdx#strict) and/or [`stylistic` shared config](../users/Shared_Configurations.mdx#stylistic) in a previous step, be sure to replace them with [`strictTypeChecked`](../users/Shared_Configurations.mdx#strict-type-checked) and [`stylisticTypeChecked`](../users/Shared_Configurations.mdx#stylistic-type-checked) respectively to add their type-checked rules.

<Tabs groupId="eslint-config">
<TabItem value="Flat Config">

```js title="eslint.config.js"
export default tseslint.config(
eslint.configs.recommended,
// Removed lines start
...tseslint.configs.strict,
...tseslint.configs.stylistic,
// Removed lines end
// Added lines start
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// Added lines end
// ...
);
```

</TabItem>
<TabItem value="Legacy Config">

```js title=".eslintrc.cjs"
/* eslint-env node */
module.exports = {
extends: [
'eslint:recommended',
// Removed lines start
'plugin:@typescript-eslint/strict',
'plugin:@typescript-eslint/stylistic',
// Removed lines end
// Added lines start
'plugin:@typescript-eslint/strict-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
// Added lines end
],
// ...
};
```

</TabItem>
</Tabs>

You can read more about the rules provided by typescript-eslint in our [rules docs](/rules) and [shared configurations docs](../users/Shared_Configurations.mdx).

## FAQs

### Can I customize the TSConfig used for typed linting?

The `project` option can be turned on with either:

Expand Down Expand Up @@ -134,8 +189,6 @@ See [the `@typescript-eslint/parser` docs for more details](../packages/Parser.m
If your project is a multi-package monorepo, see [our docs on configuring a monorepo](./typed-linting/Monorepos.mdx).
:::

## FAQs

### How can I disable type-aware linting for a subset of files?

You can combine ESLint's [overrides](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-based-on-glob-patterns) config in conjunction with our [`disable-type-checked`](../users/Shared_Configurations.mdx#disable-type-checked) config to turn off type-aware linting on specific subsets of files.
Expand All @@ -147,6 +200,7 @@ You can combine ESLint's [overrides](https://eslint.org/docs/latest/use/configur
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
Expand All @@ -156,7 +210,7 @@ export default tseslint.config(
},
// Added lines start
{
files: ['*.js'],
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
},
// Added lines end
Expand All @@ -171,6 +225,7 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -209,11 +264,6 @@ This means that generally they usually only run a complete lint before a push, o

**We strongly recommend you do use type-aware linting**, but the above information is included so that you can make your own, informed decision.

### I get errors telling me "The file must be included in at least one of the projects provided"

You're using an outdated version of `@typescript-eslint/parser`.
Update to the latest version to see a more informative version of this error message, explained in our [Troubleshooting and FAQs page](../troubleshooting/FAQ.mdx#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file).

## Troubleshooting

If you're having problems getting this working, please have a look at our [Troubleshooting and FAQs page](../troubleshooting/FAQ.mdx).

0 comments on commit 7bea876

Please sign in to comment.