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 | ### Recommended
|
10 |
|
11 | This is the standard config for use in Fluid Framework libraries.
|
12 | It is also the default library export.
|
13 |
|
14 | This configuration is recommended for all libraries in the repository, though use of the [strict](#strict) config is preferred whenever reasonable.
|
15 |
|
16 | Imported via `@fluidframework/eslint-config-fluid` (or `@fluidframework/eslint-config-fluid/recommended`).
|
17 |
|
18 | ### Strict
|
19 |
|
20 | The strictest config for use in Fluid Framework libraries.
|
21 | Recommended for highest code quality enforcement.
|
22 |
|
23 | 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`).
|
24 |
|
25 | Imported via `@fluidframework/eslint-config-fluid/strict`.
|
26 |
|
27 | ## Changing the lint config
|
28 |
|
29 | If you want to change the shared lint config (that is, this package), you need to do the following:
|
30 |
|
31 | 1. Make the change in the config.
|
32 | 2. Publish a pre-release package.
|
33 | 3. Update the core packages to use the pre-release lint config.
|
34 |
|
35 | When updating the lint config (step 1), run `npm run build` and commit any resulting changes.
|
36 |
|
37 | ### Tracking lint config changes over time
|
38 |
|
39 | One question that comes up often when we make changes to our lint config is, "what changed?" This applies even when we
|
40 | don't make any changes other than upgrading deps, because the dependency upgrade might include a new rule.
|
41 |
|
42 | ESLint provides a way to print the config that would apply to a file (`--print-config`), so we use this capability to
|
43 | 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
|
44 | a diff to review as part of a PR -- just like we do with API reports for code changes.
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | ## Scripts
|
52 |
|
53 | | Script | Description |
|
54 | |--------|-------------|
|
55 | | `build` | `npm run print-config` |
|
56 | | `build:readme` | `markdown-magic --files "**/*.md"` |
|
57 | | `cleanup-printed-configs` | Clean up the printed configs. Removes the `parser` property and sorts the JSON. |
|
58 | | `format` | `npm run prettier:fix` |
|
59 | | `prettier` | `prettier --check .` |
|
60 | | `prettier:fix` | `prettier --write .` |
|
61 | | `print-config` | Print all the eslint configs. |
|
62 | | `print-config:default` | Print the eslint config for regular TypeScript files (`eslint --config index.js --print-config src/file.ts`). |
|
63 | | `print-config:minimal` | `eslint --config ./minimal-deprecated.js --print-config ./src/file.ts > ./printed-configs/minimal.json` |
|
64 | | `print-config:react` | `eslint --config ./index.js --print-config ./src/file.tsx > ./printed-configs/react.json` |
|
65 | | `print-config:recommended` | `eslint --config ./recommended.js --print-config ./src/file.ts > ./printed-configs/recommended.json` |
|
66 | | `print-config:strict` | `eslint --config ./strict.js --print-config ./src/file.ts > ./printed-configs/strict.json` |
|
67 | | `print-config:test` | Print the eslint config for test files (`eslint --config index.js --print-config src/test/file.ts`). |
|
68 | | `test` | `echo TODO: add tests in @fluidframework/eslint-config-fluid` |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | See [GitHub](https://github.com/microsoft/FluidFramework) for more details on the Fluid Framework and packages within.
|