Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: explained tsconfigRootDir in website#6236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletiondocs/architecture/Parser.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -226,7 +226,8 @@ For example, by default it will ensure that a glob like `./**/tsconfig.json` wil

> Default `undefined`.

This option allows you to provide the root directory for relative tsconfig paths specified in the `project` option above.
This option allows you to provide the root directory for relative TSConfig paths specified in the `project` option above.
Doing so ensures running ESLint from a directory other than the root will still be able to find your TSConfig.

### `warnOnUnsupportedTypeScriptVersion`

Expand Down
22 changes: 11 additions & 11 deletionsdocs/linting/Typed_Linting.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,30 +8,30 @@ To tap into TypeScript's additional powers, there are two small changes you need

```js title=".eslintrc.js"
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
// Added lines start
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
// Added lines end
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
// Add this line
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
// Added lines start
parserOptions: {
project: ['./tsconfig.json'],
tsconfigRootDir: __dirname,
},
// Added lines end
root: true,
};
```

In more detail:

- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory.
- `plugin:@typescript-eslint/recommended-requiring-type-checking` is another [recommended configuration](./CONFIGURATIONS.mdx) we provide. This one contains recommended rules that additionally require type information.
- `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](./typed-linting/Monorepos.md).
- `plugin:@typescript-eslint/recommended-requiring-type-checking` is another recommended configuration we provide. This one contains rules that specifically require type information.
- `parserOptions.tsconfigRootDir` tells our parser the absolute path of your project's root directory (see [Parser#tsconfigRootDir](../architecture/Parser.mdx#tsconfigRootDir)).

With that done, run the same lint command you ran before.
You may see new rules reporting errors based on type information!
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp