forked from typescript-eslint/typescript-eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): streamlined Getting Started docs (typescript-eslint#5248
) * chore(website): streamlined Getting Started docs * Fix: check-spelling; lint-markdown * Fixed remaining typed-linting issues * Apply suggestions from code review Co-authored-by: Brad Zacher <brad.zacher@gmail.com> * TSLINT_RULE_ALTERNATIVES.md * Code case * Remove prettier-ignore Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
- Loading branch information
1 parent
6d19efe
commit 7ea14ae
Showing
18 changed files
with
964 additions
and
1,075 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/docs/linting /docs | ||
/docs/linting/type-linting /docs/linting/typed-linting | ||
/docs/linting/monorepo /docs/linting/typed-linting/monorepos | ||
/docs/linting/tslint /docs/linting/troubleshooting/tslint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,79 @@ | ||
--- | ||
id: getting-started | ||
title: Getting Started | ||
sidebar_label: Getting Started | ||
slug: / | ||
--- | ||
|
||
These docs will give you a quick overview of the project and all of its pieces, as well as provide guides to help you get set up. | ||
## Quickstart | ||
|
||
The docs are broken down into the following categories: | ||
These steps will get you running ESLint with our recommended rules on your TypeScript code as quickly as possible. | ||
|
||
- [I want to lint my TypeScript codebase.](./linting/README.md) | ||
### Step 1: Installation | ||
|
||
- [I want to develop an ESLint plugin in TypeScript.](./development/CUSTOM_RULES.md) | ||
First, install the required packages for [ESLint](https://eslint.io), [TypeScript](https://typescriptlang.org), and this plugin: | ||
|
||
```bash npm2yarn | ||
npm install --save-dev @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint typescript | ||
``` | ||
|
||
### Step 2: Configuration | ||
|
||
Next, create a `.eslintrc.cjs` config file in the root of your project, and populate it with the following: | ||
|
||
```js title=".eslintrc.cjs" | ||
module.exports = { | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
root: true, | ||
}; | ||
``` | ||
|
||
:::info | ||
If your project doesn't use ESM, naming the file as `.eslintrc.js` is fine. See [ESLint's Configuration Files docs](https://eslint.org/docs/user-guide/configuring/configuration-files) for more info. | ||
::: | ||
|
||
### Step 3: Running ESLint | ||
|
||
Open a terminal to the root of your project and run the following command: | ||
|
||
<Tabs groupId="npm2yarn"> | ||
<TabItem value="npm"> | ||
|
||
```bash | ||
npx eslint . | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="Yarn"> | ||
|
||
```bash | ||
yarn eslint . | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
ESLint will lint all TypeScript compatible files within the current folder, and will output the results to your terminal. | ||
|
||
## Details | ||
|
||
- 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). | ||
|
||
### Configuration Values | ||
|
||
- `parser: '@typescript-eslint/parser'` tells ESLint to use the [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/parser) package you installed to parse your source files. | ||
- 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 [`@typescript-eslint/eslint-plugin`](https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin)) package as a plugin. | ||
- This allows you to use typescript-eslint's 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/recommended` is our "recommended" config - it's just like `eslint:recommended`, except it only turns on rules from our TypeScript-specific plugin. | ||
|
||
## Next Steps | ||
|
||
We provide a plethora of powerful rules that utilize the power of TypeScript's type information. [Visit the next page for a setup guide](./linting/TYPED_LINTING.md 'Visit the next page for a typed rules setup guide'). | ||
|
||
If you're having problems getting this working, please have a look at our [Troubleshooting & FAQs](./linting/TROUBLESHOOTING.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.