1 | # @fluidframework/eslint-config-fluid
|
2 |
|
3 | This package contains a shared ESLint config used by all the packages in the Fluid Framework repo.
|
4 |
|
5 | It exports the following shared ESLint configs:
|
6 |
|
7 | ## Configurations
|
8 |
|
9 | ### Minimal
|
10 |
|
11 | This is the minimal config for use in Fluid Framework libraries, only intended for internal-only packages, test libraries, etc.
|
12 | Whenever possible, the [recommended](#recommended) or [strict](#strict) configs should be used instead.
|
13 |
|
14 | This configuration should never be used in published packages.
|
15 | It is only suitable for early prototyping and repository-internal testing libraries.
|
16 |
|
17 | Imported via `@fluidframework/eslint-config-fluid/minimal`.
|
18 |
|
19 | ### Recommended
|
20 |
|
21 | This is the standard config for use in Fluid Framework libraries.
|
22 | It is also the default library export.
|
23 |
|
24 | This configuration is recommended for all libraries in the repository, though use of the [strict](#strict) config is preferred whenever reasonable.
|
25 |
|
26 | Imported via `@fluidframework/eslint-config-fluid` (or `@fluidframework/eslint-config-fluid/recommended`).
|
27 |
|
28 | ### Strict
|
29 |
|
30 | The strictest config for use in Fluid Framework libraries.
|
31 | Recommended for highest code quality enforcement.
|
32 |
|
33 | In particular, use of this config is encouraged for libraries with public facing APIs, and those used as external-facing examples (e.g. those mentioned on `fluidframework.com`).
|
34 |
|
35 | Imported via `@fluidframework/eslint-config-fluid/strict`.
|
36 |
|
37 | ## Changing the lint config
|
38 |
|
39 | If you want to change the shared lint config (that is, this package), you need to do the following:
|
40 |
|
41 | 1. Make the change in the config.
|
42 | 2. Publish a pre-release package.
|
43 | 3. Update the core packages to use the pre-release lint config.
|
44 |
|
45 | When updating the lint config (step 1), run `npm run build` and commit any resulting changes.
|
46 |
|
47 | ### Tracking lint config changes over time
|
48 |
|
49 | One question that comes up often when we make changes to our lint config is, "what changed?" This applies even when we
|
50 | don't make any changes other than upgrading deps, because the dependency upgrade might include a new rule.
|
51 |
|
52 | ESLint provides a way to print the config that would apply to a file (`--print-config`), so we use this capability to
|
53 | print out the applied config as a JSON file. As we make changes to the config, we can print out the config again and get
|
54 | a diff to review as part of a PR -- just like we do with API reports for code changes.
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | ## Scripts
|
62 |
|
63 | | Script | Description |
|
64 | |--------|-------------|
|
65 | | `build` | `npm run print-config` |
|
66 | | `cleanup-printed-configs` | Clean up the printed configs. Removes the `parser` property and sorts the JSON. |
|
67 | | `format` | `npm run prettier:fix` |
|
68 | | `prettier` | `prettier --check .` |
|
69 | | `prettier:fix` | `prettier --write .` |
|
70 | | `print-config` | Print all the eslint configs. |
|
71 | | `print-config:default` | Print the eslint config for regular TypeScript files (`eslint --config index.js --print-config src/file.ts`). |
|
72 | | `print-config:minimal` | `eslint --config ./minimal.js --print-config ./src/file.ts > ./printed-configs/minimal.json` |
|
73 | | `print-config:react` | `eslint --config ./index.js --print-config ./src/file.tsx > ./printed-configs/react.json` |
|
74 | | `print-config:recommended` | `eslint --config ./recommended.js --print-config ./src/file.ts > ./printed-configs/recommended.json` |
|
75 | | `print-config:strict` | `eslint --config ./strict.js --print-config ./src/file.ts > ./printed-configs/strict.json` |
|
76 | | `print-config:test` | Print the eslint config for test files (`eslint --config index.js --print-config src/test/file.ts`). |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | See [GitHub](https://github.com/microsoft/FluidFramework) for more details on the Fluid Framework and packages within.
|