Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: draft of new typescript-eslint website #3147

Closed
wants to merge 87 commits into from
Closed
Show file tree
Hide file tree
Changes from 85 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
e7e80a2
docs: generate simple documentation page
armano2 Feb 27, 2021
bacfc85
chore: add netlify config
armano2 Feb 27, 2021
e4e3a18
fix: update netlify config
armano2 Feb 27, 2021
17f3ef4
fix: remove netlify.toml
armano2 Feb 27, 2021
9bb88e5
fix: add sponsors to start page and update page
armano2 Feb 27, 2021
d80ce4a
fix: correct few minor issues
armano2 Feb 28, 2021
21a47b0
docs: style improvements on homepage
armano2 Feb 28, 2021
b0c94cc
docs: add missing dark mode logo
armano2 Feb 28, 2021
6102904
docs: use svg files for github icon
armano2 Feb 28, 2021
ba2f030
docs: update homepage and fix hero styles
armano2 Feb 28, 2021
695744d
docs: add note about eslint core rules
armano2 Feb 28, 2021
b89d9ff
docs: fix styles for dark theme
armano2 Feb 28, 2021
84c88b1
docs: add tslint migration guide
armano2 Feb 28, 2021
160d08d
docs: update docs
armano2 Feb 28, 2021
05aa9b2
docs: update links
armano2 Feb 28, 2021
c335534
docs: add dynamic github url for testing
armano2 Feb 28, 2021
bdf68dd
docs: wip editor
armano2 Feb 28, 2021
2772d85
docs: create basic repl
armano2 Mar 2, 2021
68f35db
fix: add missing package
armano2 Mar 2, 2021
ad76d50
fix: add missing typescript
armano2 Mar 2, 2021
242e431
fix: correct build for ssr
armano2 Mar 2, 2021
fbcfc41
fix: correct build for ssr and loading all rules
armano2 Mar 2, 2021
75fc69d
fix: add support for quickfix
armano2 Mar 2, 2021
567285d
fix: refactor update markers
armano2 Mar 2, 2021
35c7c3b
fix: setup workspaces and migrate code to typescript
armano2 Mar 2, 2021
241dd18
fix: correct build when in monorepo
armano2 Mar 2, 2021
55fad3d
fix: reduce number of files that has to be loaded
armano2 Mar 2, 2021
cbe134e
fix: yarn lock after depencency update
armano2 Mar 2, 2021
718de5e
Merge branch 'fix/yarn-lock'
armano2 Mar 2, 2021
af58a83
Merge remote-tracking branch 'origin/master' into docs-page
armano2 Mar 2, 2021
960fabf
fix: implement saving/restoring configuration
armano2 Mar 2, 2021
131e80c
docs: fix saving and restoring query params
armano2 Mar 2, 2021
382cce1
fix: optimize build size
armano2 Mar 3, 2021
940e5be
fix: disable double build on netlify
armano2 Mar 3, 2021
e6e8a8d
docs: add basic styles to playground
armano2 Mar 3, 2021
caba2c8
fix: add some imports and simplify code
armano2 Mar 3, 2021
012ce87
feat: refactor codebase to use sandbox
armano2 Mar 4, 2021
dc30446
fix: correct issue with typescript
armano2 Mar 4, 2021
3fbcd9d
fix: update playground to support options selector
armano2 Mar 4, 2021
ec08000
fix: replace text field with dropdown
armano2 Mar 4, 2021
b325278
chore: drop no longer needed files
armano2 Mar 4, 2021
153110b
build: correct issue with build
armano2 Mar 4, 2021
770f197
fix: correct code review
armano2 Mar 5, 2021
22933ee
fix: correct linting issues
armano2 Mar 5, 2021
36a1e61
chore: fix one more code review
armano2 Mar 5, 2021
eb6d737
fix: correct markdown lint issues
armano2 Mar 5, 2021
b0f3b00
test: update eslint doc validation
armano2 Mar 5, 2021
245bc6d
test: add missing spelling issues
armano2 Mar 5, 2021
0692feb
Merge remote-tracking branch 'refs/remotes/origin/master'
armano2 Mar 5, 2021
93208c2
chore: update info about tslint
armano2 Mar 5, 2021
b6da4e1
chore: add multi new line within notes
armano2 Mar 5, 2021
57d6b14
chore: fix linting issue
armano2 Mar 5, 2021
5dc55b3
chore: fix linting issue
armano2 Mar 5, 2021
a531c48
Merge branch 'master' into docs-page
armano2 Mar 6, 2021
fe35835
docs(website): add missing types and update TSLINT.md
armano2 Mar 6, 2021
7ac0fd9
docs(website): add ast viewer to repl
armano2 Mar 7, 2021
0989f05
docs(website): fix small issue with updating layout
armano2 Mar 7, 2021
8948138
docs(website): add basic interactivity to ast viewer
armano2 Mar 7, 2021
89e5a48
docs(website): correct few color issues
armano2 Mar 7, 2021
c4ef5bb
docs(website): fix issue with filtering values
armano2 Mar 7, 2021
1885bac
docs(website): fix new issue with services
armano2 Mar 7, 2021
0d99112
docs(website): add handling of fatal messages
armano2 Mar 8, 2021
9e8bdfe
docs(website): correct jsx handling
armano2 Mar 8, 2021
ff01d81
docs(website): remove unnecessary eslint disable
armano2 Mar 8, 2021
efe2661
docs(website): fix history manipulation and loading state
armano2 Mar 8, 2021
93a184d
docs(website): implement simple mouse hover highlight
armano2 Mar 8, 2021
f2202b0
docs(website): reset decoration on error
armano2 Mar 8, 2021
09c2dab
docs(website): improve ast viewer
armano2 Mar 8, 2021
58e4343
docs(website): minor style fix
armano2 Mar 8, 2021
035b82c
docs(website): improve performance
armano2 Mar 9, 2021
b532dff
Merge remote-tracking branch 'origin/master' into docs-page
armano2 Mar 9, 2021
c9467c4
chore(website): update docusaurus
armano2 Mar 10, 2021
c1a1150
Merge branch 'master'
armano2 Mar 17, 2021
bcc0808
docs(website): update
armano2 Mar 17, 2021
277283e
docs(website): update homepage
armano2 Mar 17, 2021
d3c4cf6
docs(website): enable formating of jsx and css and add simple modal
armano2 Mar 18, 2021
e49f3b7
docs(website): update docusaurus to 2.0.0-alpha.72
armano2 Mar 18, 2021
69fa84b
docs(website): add ability to pick typescript version in repl
armano2 Mar 18, 2021
38c0014
docs(website): fix ssr build
armano2 Mar 18, 2021
6b893bd
docs(website): ensure that default typescript version is correctly se…
armano2 Mar 18, 2021
c8bc133
Merge remote-tracking branch 'refs/remotes/origin/master'
armano2 Mar 19, 2021
2abb092
docs(website): correct issue with reloading page after ts version change
armano2 Mar 19, 2021
6286b12
docs(website): correct minor warnings and enable spelling checks
armano2 Mar 21, 2021
b192a43
Merge branch 'master' into HEAD
armano2 Nov 4, 2021
34e7463
docs: update website
armano2 Nov 4, 2021
4759724
chore: bump @babel to 7.16.x and update tests
armano2 Nov 7, 2021
c51339f
Merge branch 'fix-babel-7_16-tests' into docs-page
armano2 Nov 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
".cspell.json",
"yarn.lock",
".github/workflows/**",
".vscode/*.json"
".vscode/*.json",
"website/src/vendor/**",
"website/build/**",
"website/.docusaurus/**"
],
"dictionaries": [
"typescript",
Expand Down Expand Up @@ -66,6 +69,7 @@
"IIFE",
"IIFEs",
"linebreaks",
"lzstring",
"necroing",
"nocheck",
"nullish",
Expand Down Expand Up @@ -94,6 +98,7 @@
"transpiled",
"transpiles",
"transpiling",
"tsvfs",
"tsconfigs",
"tsutils",
"typedef",
Expand All @@ -104,7 +109,7 @@
],
"overrides": [
{
"filename": "**/*.{ts,js}",
"filename": "**/*.{ts,js,tsx,jsx}",
"ignoreRegExpList": ["/@[a-z]+/", "/#(end)?region/"],
"includeRegExpList": [
"/\\/\\*[\\s\\S]*?\\*\\/|([^\\\\:]|^)\\/\\/.*$/",
Expand Down
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ shared-fixtures
coverage
__snapshots__

website/build
website/.docusaurus
website/sidebars
website/webpack.plugin.js
website/babel.config.js
website/docusaurus.config.js
website/src/modules
website/src/vendor

packages/eslint-plugin-tslint/tests

# Files copied as part of the build
Expand Down
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module.exports = {
'./tsconfig.eslint.json',
'./packages/*/tsconfig.json',
'./tests/integration/tsconfig.json',
'./website/tsconfig.json',
'./tests/integration/tsconfig.json',
],
allowAutomaticSingleRunInference: true,
tsconfigRootDir: __dirname,
Expand Down Expand Up @@ -304,5 +306,12 @@ module.exports = {
'import/no-default-export': 'off',
},
},
{
files: ['website/src/**/*.ts', 'website/src/**/*.tsx'],
rules: {
'import/no-default-export': 'off',
'no-console': 'off',
},
},
],
};
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Website
website/.docusaurus
website/.cache-loader
website/build

# Runtime data
pids
*.pid
Expand Down Expand Up @@ -57,7 +62,6 @@ jspm_packages/
# next.js build output
.next


# Editor-specific metadata folders
.vs

Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ CONTRIBUTORS.md
# Ignore CHANGELOG.md files to avoid issues with automated release job
CHANGELOG.md

website/.docusaurus
website/build
website/src/vendor

# TODO - remove this once prettier supports TS4.1
packages/scope-manager/tests/fixtures/type-declaration/literal-type1.ts
packages/scope-manager/tests/fixtures/type-declaration/literal-type2.ts
Expand Down
10 changes: 7 additions & 3 deletions docs/getting-started/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Getting Started
---
title: Getting Started
sidebar_label: Getting Started
slug: /
---

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)
- [I want to lint my TypeScript codebase.](./linting/README.md)

## [(TODO) I want to write an ESLint plugin in TypeScript.](./plugin-development/README.md)
- [(TODO) I want to write an ESLint plugin in TypeScript.](./plugin-development/README.md)
107 changes: 8 additions & 99 deletions docs/getting-started/linting/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
# Troubleshooting / FAQ

## Table of Contents

- [I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code](#i-am-using-a-rule-from-eslint-core-and-it-doesnt-work-correctly-with-typescript-code)
- [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-parseroptionsextrafileextensions-to-your-config)
- [One of my lint rules isn't working correctly on a pure JavaScript file](#one-of-my-lint-rules-isnt-working-correctly-on-a-pure-javascript-file)
- [TypeScript should be installed locally](#typescript-should-be-installed-locally)
- [How can I ban `<specific language feature>`?](#how-can-i-ban-specific-language-feature)
- [Why don't I see TypeScript errors in my ESLint output?](#why-dont-i-see-typescript-errors-in-my-eslint-output)
- [I get errors from the `no-undef` rule about global variables not being defined, even though there are no TypeScript errors](#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors)
- [How do I check to see what versions are installed?](#how-do-i-check-to-see-what-versions-are-installed)
- [My linting feels really slow](#my-linting-feels-really-slow)

Comment on lines -3 to -15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getting rid of the TOC kinda ruins the experience for the repo.
I think we probably want to keep it if we can.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to focus on website or github documetation?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the FAQ is one of the few things that needs to be easy to read on both.

Other things I think it's okay to have some weirdness on github - as long as it's not too over the top.

---

<br />
<br />
<br />
Comment on lines -18 to -20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto - removing these breaks makes it much harder to read this in the github renderer

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to focus on documentation on github or on website?

id: troubleshooting
title: Troubleshooting
sidebar_label: Troubleshooting
---

## I am using a rule from ESLint core, and it doesn't work correctly with TypeScript code

Expand All @@ -38,16 +23,8 @@ If you don't find an existing extension rule, or the extension rule doesn't work

We release a new version our tooling every week. **_Please_** ensure that you [check our the latest list of "extension" rules](../../../packages/eslint-plugin/README.md#extension-rules) **_before_** filing an issue.

<br />
<br />
<br />

---

<br />
<br />
<br />

## 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.
Expand All @@ -56,16 +33,8 @@ There are a couple of solutions to this, depending on what you want to achieve.

See our docs on [type aware linting](./TYPED_LINTING.md#i-get-errors-telling-me-the-file-must-be-included-in-at-least-one-of-the-projects-provided) for solutions to this.

<br />
<br />
<br />

---

<br />
<br />
<br />

## 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:
Expand All @@ -78,47 +47,23 @@ You can use `parserOptions.extraFileExtensions` to specify an array of non-TypeS
},
```

<br />
<br />
<br />

---

<br />
<br />
<br />

## One of my lint rules isn't working correctly on a pure JavaScript file

This is to be expected - ESLint rules do not check file extensions on purpose, as it causes issues in environments that use non-standard extensions (for example, a `.vue` and a `.md` file can both contain TypeScript code to be linted).

If you have some pure JavaScript code that you do not want to apply certain lint rules to, then you can use [ESLint's `overrides` configuration](https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns) to turn off certain rules, or even change the parser based on glob patterns.

<br />
<br />
<br />

---

<br />
<br />
<br />

## TypeScript should be installed locally

Make sure that you have installed TypeScript locally i.e. by using `npm install typescript`, not `npm install -g typescript`,
or by using `yarn add typescript`, not `yarn global add typescript`. See https://github.com/typescript-eslint/typescript-eslint/issues/2041 for more information.

<br />
<br />
<br />

---

<br />
<br />
<br />

## How can I ban `<specific language feature>`?

ESLint core contains the rule [`no-restricted-syntax`](https://eslint.org/docs/rules/no-restricted-syntax). This generic rule allows you to specify a [selector](https://eslint.org/docs/developer-guide/selectors) for the code you want to ban, along with a custom error message.
Expand Down Expand Up @@ -154,16 +99,8 @@ For example, you can ban enums (or some variation of) using one of the following
}
```

<br />
<br />
<br />

---

<br />
<br />
<br />

## Why don't I see TypeScript errors in my ESLint output?

TypeScript's compiler (or whatever your build chain may be) is specifically designed and built to validate the correctness of your codebase.
Expand All @@ -173,16 +110,8 @@ Instead, our tooling exists to **_augment_** TypeScript's built in checks with l

[1] - TypeScript computes type information lazily, so us asking for the errors it would produce from the compiler would take an _additional_ ~100ms per file. This doesn't sound like a lot, but depending on the size of your codebase, it can easily add up to between several seconds to several minutes to a lint run.

<br />
<br />
<br />

---

<br />
<br />
<br />

## I get errors from the `no-undef` rule about global variables not being defined, even though there are no TypeScript errors

The `no-undef` lint rule does not use TypeScript to determine the global variables that exist - instead, it relies upon ESLint's configuration.
Expand All @@ -206,16 +135,8 @@ Note, that for a mixed project including JavaScript and TypeScript, the `no-unde

If you choose to leave on the ESLint `no-undef` lint rule, you can [manually define the set of allowed `globals` in your ESLint config](https://eslint.org/docs/user-guide/configuring/language-options#specifying-globals), and/or you can use one of the [pre-defined environment (`env`) configurations](https://eslint.org/docs/user-guide/configuring/language-options#specifying-environments).

<br />
<br />
<br />

---

<br />
<br />
<br />

## How do I check to see what versions are installed?

If you have multiple versions of our tooling, it can cause various bugs for you. This is because ESLint may load a different version each run depending on how you run it - leading to inconsistent lint results.
Expand All @@ -225,24 +146,16 @@ Installing our tooling in the root of your project does not mean that only one v
You can check what versions are installed in your project using the following commands:

```bash
$ npm list @typescript-eslint/eslint-plugin @typescript-eslint/parser
$ yarn list @typescript-eslint/eslint-plugin @typescript-eslint/parser
npm list @typescript-eslint/eslint-plugin @typescript-eslint/parser
yarn list @typescript-eslint/eslint-plugin @typescript-eslint/parser
```

If you see more than one version installed, then you will have to either use [yarn resolutions](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/) to force a single version, or you will have to downgrade your root versions to match the dependency versions.

**The best course of action in this case is to wait until your dependency releases a new version with support for our latest versions.**

<br />
<br />
<br />

---

<br />
<br />
<br />

## 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.
Expand All @@ -263,8 +176,8 @@ This plugin surfaces prettier formatting problems at lint time, helping to ensur

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}\"
```bash npm2yarn
npm run prettier --list-different \"./**/*.{ts,js,json,md}\"
```

### `eslint-plugin-import`
Expand Down Expand Up @@ -292,7 +205,3 @@ The following rules do not have equivalent checks in TypeScript, so we recommend
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/prettier) to enforce a standardized formatting.

<br />
<br />
<br />
30 changes: 17 additions & 13 deletions docs/getting-started/linting/MONOREPO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Getting Started - Monorepo Configuration
---
id: monorepo
title: Monorepo Configuration
sidebar_label: 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.
Expand All @@ -16,7 +20,7 @@ This setup is pretty easy to configure. Earlier in our docs on [typed linting](.

For example, this is how we specify all of our `tsconfig.json` within this repo.

```diff
```diff title=".eslintrc.js"
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
Expand Down Expand Up @@ -53,21 +57,21 @@ If you've only got one, you should inspect the `include` paths. If it doesn't in

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
{
```js title=".eslintrc.js"
module.exports = {
// extend your base config to share compilerOptions, etc
"extends": "./tsconfig.json",
"compilerOptions": {
extends: './tsconfig.json',
compilerOptions: {
// ensure that nobody can accidentally use this config for a build
"noEmit": true
noEmit: true,
},
"include": [
include: [
// whatever paths you intend to lint
"src",
"test",
"tools"
]
}
'src',
'test',
'tools',
],
};
```

Of course, ensure you update your `.eslintrc.js` to point at this new config file.
Expand Down