3.6 kBMarkdownView Raw
1# @fluidframework/eslint-config-fluid
2
3This package contains a shared ESLint config used by all the packages in the Fluid Framework repo.
4
5It exports the following shared ESLint configs:
6
7## Configurations
8
9### Recommended
10
11This is the standard config for use in Fluid Framework libraries.
12It is also the default library export.
13
14This configuration is recommended for all libraries in the repository, though use of the [strict](#strict) config is preferred whenever reasonable.
15
16Imported via `@fluidframework/eslint-config-fluid` (or `@fluidframework/eslint-config-fluid/recommended`).
17
18### Strict
19
20The strictest config for use in Fluid Framework libraries.
21Recommended for highest code quality enforcement.
22
23In 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
25Imported via `@fluidframework/eslint-config-fluid/strict`.
26
27## Changing the lint config
28
29If you want to change the shared lint config (that is, this package), you need to do the following:
30
311. Make the change in the config.
322. Publish a pre-release package.
333. Update the core packages to use the pre-release lint config.
34
35When updating the lint config (step 1), run `npm run build` and commit any resulting changes.
36
37### Tracking lint config changes over time
38
39One question that comes up often when we make changes to our lint config is, "what changed?" This applies even when we
40don't make any changes other than upgrading deps, because the dependency upgrade might include a new rule.
41
42ESLint provides a way to print the config that would apply to a file (`--print-config`), so we use this capability to
43print out the applied config as a JSON file. As we make changes to the config, we can print out the config again and get
44a diff to review as part of a PR -- just like we do with API reports for code changes.
45
46<!-- AUTO-GENERATED-CONTENT:START (PACKAGE_SCRIPTS) -->
47
48<!-- prettier-ignore-start -->
49<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
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<!-- prettier-ignore-end -->
71
72<!-- AUTO-GENERATED-CONTENT:END -->
73
74See [GitHub](https://github.com/microsoft/FluidFramework) for more details on the Fluid Framework and packages within.