Skip to content

Commit df4f158

Browse files
committed
Docs(eslint-config-typescript): Update readme according the new flat config support
1 parent 6b14b1a commit df4f158

File tree

1 file changed

+46
-53
lines changed

1 file changed

+46
-53
lines changed
Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,50 @@
11
# @alma-oss/eslint-config-typescript
22

3-
These configuration files are suitable to lint TypeScript code.
3+
> ESLint configuration for TypeScript projects
44
5-
## Setup
5+
## 📦 Installation
66

7-
To lint TypeScript files using ESLint and this ruleset you must
8-
9-
1. Install ESLint & this ruleset
10-
1. Tell the TypeScript parser where your _tsconfig.json_ file is (not doing so will cause some TS-syntax-specific rules to not work at all)
11-
1. Extend one or more of the included rulesets
12-
13-
See the example _.eslintrc.js_ file below for more details and make sure you read the [Parser’s docs][ts-parser-configuration] about its settings.
7+
```sh
8+
npm install --save-dev eslint @alma-oss/eslint-config-typescript
9+
# or
10+
yarn add --dev eslint @alma-oss/eslint-config-typescript
11+
```
1412

15-
## Configurations
13+
## 🧩 Rulesets
1614

1715
- **`@alma-oss/eslint-config-typescript`**
1816

19-
Suitable for linting TypeScript source files.
20-
21-
Together with this ruleset, you should also choose one base ruleset depending on your target platform:
17+
A generic ruleset that focuses on code correctness.
2218

23-
- [`@alma-oss/eslint-config-node`][eslint-config-node]
24-
- [`@alma-oss/eslint-config-react`][eslint-config-react]
19+
- **`@alma-oss/eslint-config-typescript/optional`**
2520

26-
### `@alma-oss/eslint-config-typescript/react`
21+
Additional ruleset that might provide useful tips and hints how to improve your code.
2722

28-
React specific overrides.
29-
30-
## Optional Configurations
31-
32-
### `@alma-oss/eslint-config-typescript/optional`
23+
> For new projects, it is recommended to enable this ruleset. For existing projects, it is only recommended for the brave.
3324
34-
Use this ruleset together with any of the above version-specific rulesets. Provides additional insights into potential inconsistencies in the project.
25+
- **`@alma-oss/eslint-config-typescript/style`**
3526

36-
> For new projects, it is recommended to enable this ruleset. For existing projects, it is only recommended for the brave.
27+
Ruleset that focuses on code style (indentation, spacing, naming, syntax preference etc.).
3728

38-
## Coding Styles
29+
- **`@alma-oss/eslint-config-typescript/react`**
3930

40-
### `@alma-oss/eslint-config-typescript/style`
31+
Ruleset that provides additional customizations for the `@alma-oss/eslint-config-react` ruleset when working with TypeScript.
4132

42-
This ruleset includes rules which deal with how the code looks like and not how it works. It helps keeping the code clean and consistent. 🎨
33+
## 👨‍💻 Usage
4334

4435
A full configuration for a TypeScript on Node.js project:
4536

4637
```js
4738
// eslint.config.js
48-
import { defineConfig } from 'eslint/config';
39+
import typescript from '@alma-oss/eslint-config-typescript';
40+
import optional from '@alma-oss/eslint-config-typescript/optional';
41+
import style from '@alma-oss/eslint-config-typescript/style';
4942

43+
/** @type {Array<import("eslint").Linter.Config>} */
5044
export default defineConfig({
51-
extends: [
52-
'@alma-oss/eslint-config-node/v10',
53-
'@alma-oss/eslint-config-node/optional',
54-
'@alma-oss/eslint-config-typescript',
55-
'@alma-oss/eslint-config-typescript/style',
56-
],
45+
...typescript,
46+
...optional,
47+
...style,
5748

5849
parserOptions: {
5950
// The project field is required in order for some TS-syntax-specific rules to function at all
@@ -70,21 +61,17 @@ A full configuration for a TypeScript on React project:
7061
```js
7162
// eslint.config.mjs
7263
import { defineConfig, globalIgnores } from 'eslint/config';
73-
import { FlatCompat } from '@eslint/eslintrc';
74-
import react from '@alma-oss/eslint-config-react';
75-
import reactOptional from '@alma-oss/eslint-config-react/optional';
76-
import ts from '@alma-oss/eslint-config-typescript';
77-
import tsReact from '@alma-oss/eslint-config-typescript/react';
78-
79-
const compat = new FlatCompat({
80-
baseDirectory: import.meta.dirname,
81-
});
64+
import typescript from '@alma-oss/eslint-config-typescript';
65+
import react from '@alma-oss/eslint-config-typescript/react';
66+
import optional from '@alma-oss/eslint-config-typescript/optional';
67+
import style from '@alma-oss/eslint-config-typescript/style';
8268

8369
export default defineConfig([
70+
...typescript,
8471
...react,
85-
...reactOptional,
86-
...ts,
87-
...tsReact,
72+
...optional,
73+
...style,
74+
8875
{
8976
parserOptions: {
9077
// The project field is required in order for some TS-syntax-specific rules to function at all
@@ -95,13 +82,9 @@ export default defineConfig([
9582
]);
9683
```
9784

98-
To actually lint .ts files, you must pass the `--ext` flag to ESLint:
99-
100-
```sh
101-
eslint --ext ts --report-unused-disable-directives .
102-
```
85+
## 🔌 Integration
10386

104-
## VSCode integration
87+
### Visual Studio Code
10588

10689
The [vscode-eslint](https://github.com/Microsoft/vscode-eslint) plugin for integrating ESLint into VSCode does not automatically parse TypeScript files. To do so, you must inform ESLint to enable on TypeScript files by adding this configuration to your settings (File > Preferences > Settings):
10790

@@ -116,6 +99,16 @@ The [vscode-eslint](https://github.com/Microsoft/vscode-eslint) plugin for integ
11699

117100
> Notice we are adding `javascriptreact` and `typescriptreact` above. It won’t harm adding those, but you can always omit these languages if not using them.
118101
119-
[eslint-config-node]: https://www.npmjs.com/package/@alma-oss/eslint-config-node
102+
## 🙌 Contributing
103+
104+
We’re always looking for contributors to help us fix bugs, build new features,
105+
or help us improve the project documentation. If you’re interested, definitely
106+
check out our [Contributing Guide][contributing]! 👀
107+
108+
## 📝 License
109+
110+
Licensed under the [MIT][license].
111+
120112
[eslint-config-react]: https://www.npmjs.com/package/@alma-oss/eslint-config-react
121-
[ts-parser-configuration]: https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser#configuration
113+
[contributing]: https://github.com/lmc-eu/code-quality-tools/blob/main/CONTRIBUTING.md
114+
[license]: https://github.com/lmc-eu/code-quality-tools/blob/main/LICENSE.md

0 commit comments

Comments
 (0)