Skip to content

Commit

Permalink
Merge branch 'lint/print-config' into lint/refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerbutler committed Apr 5, 2022
2 parents d25cec1 + 31b6b72 commit 7a6e909
Show file tree
Hide file tree
Showing 9 changed files with 2,544 additions and 35 deletions.
11 changes: 0 additions & 11 deletions common/build/eslint-config-fluid/.eslintrc.js

This file was deleted.

33 changes: 33 additions & 0 deletions common/build/eslint-config-fluid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,37 @@ It exports the following shared ESLint configs:
- `recommended`: The recommended config for Fluid Framework packages.
- `strict`: The strictest config; intended for packages with public facing APIs.

## Changing the lint config

If you want to change the shared lint config (that is, this package), you need to do the following:

1. Make the change in the config.
2. Publish a pre-release package.
3. Update the core packages to use the pre-release lint config.

### Tracking lint config changes over time

One question that comes up often when we make changes to our lint config is, "what changed?" This applies even when we
don't make any changes other than upgrading deps, because the dependency upgrade might include a new rule.

ESLint provides a way to print the config that would apply to a file (`--print-config`), so we use this capability to
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
a diff to review as part of a PR -- just like we do with API reports for code changes.

When updating the lint config, run the `build` script for this package and commit the resulting changes.

## Scripts

<!-- AUTO-GENERATED-CONTENT:START (SCRIPTS) -->
| Script | Description |
|--------|-------------|
| `build` | Build the package. |
| `build:ci` | Build the package -- called as part of CI. |
| `cleanup-printed-configs` | Clean up the printed configs. Removes the `parser` property and sorts the JSON. |
| `print-config` | Print all the eslint configs. |
| `print-config:default` | Print the eslint config for regular TypeScript files (`eslint --config index.js --print-config src/file.ts`). |
| `print-config:test` | Print the eslint config for test files (`eslint --config index.js --print-config src/test/file.ts`). |
<!-- AUTO-GENERATED-CONTENT:END -->

See [GitHub](https://github.com/microsoft/FluidFramework) for more details on the Fluid Framework and packages within.

2 changes: 1 addition & 1 deletion common/build/eslint-config-fluid/minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ module.exports = {
},
{
// Rules only for test files
"files": ["src/test/**"],
"files": ["*.spec.ts", "src/test/**"],
"rules": {
"@typescript-eslint/unbound-method": "off", // This rule has false positives in many of our test projects.
}
Expand Down
Loading

0 comments on commit 7a6e909

Please sign in to comment.