|
1 | 1 | # @exercism/eslint-config-javascript
|
2 | 2 |
|
3 |
| -This is the shared [`eslint`][web-eslint] configuration used by the [JavaScript track][git-javascript] (for students) and the files contributors and maintainers touch. [Shareable configs][web-shareable-configs] are designed to work with the `extends` feature of `.eslintrc` files. This means you can use the same configuration you're used to on [Exercism][web-exercism] in your on projects! |
| 3 | +This is the shared [`eslint`][web-eslint] configuration used by the [JavaScript track][git-javascript] (for students) and the files contributors and maintainers touch. |
| 4 | +[Shareable configs][web-shareable-configs] are designed to work with the `extends` feature of ESLint configuration files. |
| 5 | +This means you can use the same configuration you're used to on [Exercism][web-exercism] in your on projects! |
4 | 6 |
|
5 | 7 | ## Usage
|
6 | 8 |
|
7 |
| -To use the configuration for students, open your [eslint configuration][web-eslint-configuration] file, and add the following value to `extends`. For example, for JSON based configuration files: |
| 9 | +To use the configuration for students, open your [eslint configuration][web-eslint-configuration] file, and import the following file for the flat config. |
| 10 | +For example, for flat config configuration files: |
8 | 11 |
|
9 |
| -```json |
10 |
| -{ |
11 |
| - "extends": "@exercism/eslint-config-javascript" |
12 |
| -} |
| 12 | +```javascript |
| 13 | +import baseConfig from '@exercism/eslint-config-javascript'; |
| 14 | + |
| 15 | +// ... |
| 16 | +export default [ |
| 17 | + ...baseConfig, |
| 18 | + // ... your configuration |
| 19 | +]; |
13 | 20 | ```
|
14 | 21 |
|
15 |
| -To use the configuration used by contributors and maintainers, add the following to `extends`: |
| 22 | +To use the configuration used by contributors and maintainers, add the following: |
| 23 | + |
| 24 | +```javascript |
| 25 | +import baseConfig from '@exercism/eslint-config-javascript/maintainers'; |
16 | 26 |
|
17 |
| -```json |
18 |
| -{ |
19 |
| - "extends": "@exercism/eslint-config-javascript/maintainers" |
20 |
| -} |
| 27 | +// ... |
| 28 | +export default [ |
| 29 | + ...baseConfig, |
| 30 | + // ... your configuration |
| 31 | +]; |
21 | 32 | ```
|
22 | 33 |
|
23 | 34 | ## Students configuration
|
24 | 35 |
|
25 |
| -Find the student configuration [here](index.js). It's goal is to help detect and prevent common problems, without making _any_ decisions about code-style. |
| 36 | +Find the student configuration [here](index.mjs). |
| 37 | +It's goal is to help detect and prevent common problems, without making _any_ decisions about code-style. |
26 | 38 |
|
27 | 39 | The rules are based on:
|
28 | 40 |
|
29 | 41 | - [`eslint:recommended`][web-eslint-recommended]
|
30 |
| -- [`plugin:import`][git-eslint-plugin-import] |
31 | 42 | - A few extra rules that catch common issues but are not enabled via the recommended plugin. See [this PR][git-javascript-pr-1094] for a bit of discussion and rationale.
|
32 | 43 |
|
33 |
| -Because the [Exercism JavaScript track][git-javascript] is primarily focussing on running the exercises on Node, only `node` and `es2021` are turned on as environment, but when extending this configuration, you can add more (or turn those off). |
| 44 | +Because the [Exercism JavaScript track][git-javascript] is primarily focussing on running the exercises on Node, only `node` globals are turned on in the environment, but when extending this configuration, you can add more (or turn those off). |
34 | 45 |
|
35 | 46 | ## Maintainers configuration
|
36 | 47 |
|
37 |
| -Similar to the students configuration, and found [here](maintainers.js), it also includes the [`prettier` plugin][git-eslint-plugin-prettier] because we use [`prettier`][web-prettier] to achieve consistent code formatting. This plugin turns _off_ rules that conflict with formatting. |
| 48 | +Similar to the students configuration, and found [here](maintainers.mjs), it also includes the [`prettier` plugin][git-eslint-plugin-prettier] because we use [`prettier`][web-prettier] to achieve consistent code formatting. |
| 49 | +This plugin turns _off_ rules that conflict with formatting. |
38 | 50 |
|
39 | 51 | Additionally, it doesn't have warnings but errors for most/all of the rules in the students configuration.
|
40 | 52 |
|
41 | 53 | ## Tooling configuration
|
42 | 54 |
|
43 |
| -Because the tooling (such as the [JavaScript Analyzer][git-javascript-analyzer], [Representer][git-javascript-representer], and [Test Runner][git-javascript-test-runner]) are written in TypeScript, they don't use the same configuration files. If you're looking for those, or to build your own tools in TypeScript, go to [@exercism/eslint-config-tooling][git-eslint-config-tooling]. |
| 55 | +Because the tooling (such as the [JavaScript Analyzer][git-javascript-analyzer], [Representer][git-javascript-representer], and [Test Runner][git-javascript-test-runner]) are written in TypeScript, they don't use the same configuration files. |
| 56 | +If you're looking for those, or to build your own tools in TypeScript, go to [@exercism/eslint-config-tooling][git-eslint-config-tooling]. |
| 57 | + |
| 58 | +## Development |
| 59 | + |
| 60 | +If you want to work on this repository, install the dependencies using `corepack` and `pnpm`: |
| 61 | + |
| 62 | +```shell |
| 63 | +corepack enable pnpm |
| 64 | +corepack pnpm install |
| 65 | +``` |
| 66 | + |
| 67 | +Because pnpm is configured to use isolated `node_modules` (symlinked), everything such as your tools and plugins inside your editor should keep working as expected. |
44 | 68 |
|
45 | 69 | [git-eslint-config-tooling]: https://github.com/exercism/eslint-config-tooling
|
46 | 70 | [git-eslint-plugin-import]: https://github.com/benmosher/eslint-plugin-import
|
|
0 commit comments