UNPKG

3.92 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### Minimal
10
11This is the minimal config for use in Fluid Framework libraries, only intended for internal-only packages, test libraries, etc.
12Whenever possible, the [recommended](#recommended) or [strict](#strict) configs should be used instead.
13
14This configuration should never be used in published packages.
15It is only suitable for early prototyping and repository-internal testing libraries.
16
17Imported via `@fluidframework/eslint-config-fluid/minimal`.
18
19### Recommended
20
21This is the standard config for use in Fluid Framework libraries.
22It is also the default library export.
23
24This configuration is recommended for all libraries in the repository, though use of the [strict](#strict) config is preferred whenever reasonable.
25
26Imported via `@fluidframework/eslint-config-fluid` (or `@fluidframework/eslint-config-fluid/recommended`).
27
28### Strict
29
30The strictest config for use in Fluid Framework libraries.
31Recommended for highest code quality enforcement.
32
33In 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
35Imported via `@fluidframework/eslint-config-fluid/strict`.
36
37## Changing the lint config
38
39If you want to change the shared lint config (that is, this package), you need to do the following:
40
411. Make the change in the config.
422. Publish a pre-release package.
433. Update the core packages to use the pre-release lint config.
44
45When updating the lint config (step 1), run `npm run build` and commit any resulting changes.
46
47### Tracking lint config changes over time
48
49One question that comes up often when we make changes to our lint config is, "what changed?" This applies even when we
50don't make any changes other than upgrading deps, because the dependency upgrade might include a new rule.
51
52ESLint provides a way to print the config that would apply to a file (`--print-config`), so we use this capability to
53print out the applied config as a JSON file. As we make changes to the config, we can print out the config again and get
54a diff to review as part of a PR -- just like we do with API reports for code changes.
55
56<!-- AUTO-GENERATED-CONTENT:START (README_PACKAGE_SCRIPTS) -->
57
58<!-- prettier-ignore-start -->
59<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
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<!-- prettier-ignore-end -->
79
80<!-- AUTO-GENERATED-CONTENT:END -->
81
82See [GitHub](https://github.com/microsoft/FluidFramework) for more details on the Fluid Framework and packages within.