包详细信息

@fluidframework/eslint-config-fluid

microsoft3.1kMIT5.7.4

Shareable ESLint config for the Fluid Framework

自述文件

@fluidframework/eslint-config-fluid

This package contains a shared ESLint config used by all the packages in the Fluid Framework repo.

It exports the following shared ESLint configs:

Configurations

Recommended

This is the standard config for use in Fluid Framework libraries. It is also the default library export.

This configuration is recommended for all libraries in the repository, though use of the strict config is preferred whenever reasonable.

Imported via @fluidframework/eslint-config-fluid (or @fluidframework/eslint-config-fluid/recommended).

Strict

The strictest config for use in Fluid Framework libraries. Recommended for highest code quality enforcement.

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).

Imported via @fluidframework/eslint-config-fluid/strict.

Strict-Biome

A version of the "strict" config that disables rules that are supported by Biome's "recommended" lint config. This config is intended to be used in projects that use both eslint and Biome for linting. This config is considered experimental.

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.

When updating the lint config (step 1), run npm run build and commit any resulting changes.

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.

Scripts

Script Description
build npm run print-config
build:readme markdown-magic --files "**/*.md"
cleanup-printed-configs Clean up the printed configs. Removes the parser property and sorts the JSON.
format npm run prettier:fix
prettier prettier --check .
prettier:fix prettier --write .
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:minimal eslint --config ./minimal-deprecated.js --print-config ./src/file.ts > ./printed-configs/minimal.json
print-config:react eslint --config ./index.js --print-config ./src/file.tsx > ./printed-configs/react.json
print-config:recommended eslint --config ./recommended.js --print-config ./src/file.ts > ./printed-configs/recommended.json
print-config:strict eslint --config ./strict.js --print-config ./src/file.ts > ./printed-configs/strict.json
print-config:strict-biome eslint --config ./strict-biome.js --print-config ./src/file.ts > ./printed-configs/strict-biome.json
print-config:test Print the eslint config for test files (eslint --config index.js --print-config src/test/file.ts).
test echo TODO: add tests in @fluidframework/eslint-config-fluid

See GitHub for more details on the Fluid Framework and packages within.

更新日志

@fluidframework/eslint-config-fluid Changelog

5.7.4

Updates the contexts in which jsdoc/require-jsdoc is applied to make it less overzealous. Specifically, removes the "VariableDeclaration" context, which would incorrectly trigger for variables that were not exported.

Example

/**
 * foo
 */
export function foo(): void {
    // Before the fix, because the outer scope, `foo`, was exported, this variable `bar` would be incorrectly flagged as needing a JSDoc/TSDoc comment.
    // After the fix, variables inside exported functions, like `bar`, are no longer flagged.
    const bar = "baz";
    ...
}

5.7.3

Added support for two new patterns in the no-unchecked-record-access ESLint rule:

  1. Nullish Coalescing Assignment Recognition

    • The rule now recognizes nullish coalescing assignment (??=) as a valid safety check
    • Properties accessed after a nullish coalescing assignment will not trigger warnings
  2. Else Block Assignment Handling

    • Added detection for property assignments in else blocks of existence checks
    • Example pattern now supported:
        if ("key" in obj) {
            // use obj.key
        } else {
            obj.key = defaultValue;
            // use obj.key
        }
      
    • The rule understands that after the else block assignment, the property is safe to use
    • Works with both direct property access and computed property access

5.7.2

Disabled the unicorn/no-array-push-push rule, which reports false positives for methods named "push" on non-array objects.

5.6.0

New config for use with Biome linter

A new strict-biome config is available that disables all rules that Biome's recommended config includes. This config is intended to be used in projects that use both eslint and Biome for linting. This config is considered experimental.

Auto-fix behavior change for @typescript-eslint/consistent-type-exports

Update auto-fix policy for @typescript-eslint/consistent-type-exports to prefer inline type annotations, rather than splitting exports into type-only and non-type-only groups. This makes it easier to tell at a glance how the auto-fix changes affect individual exports when a list of exports is large. It also makes it easier to detect issues in edge-cases where the the rule is applied incorrectly.

E.g.:

export { type Foo, Bar } from "./baz.js";

instead of:

export type { Foo } from "./baz.js";
export { Bar } from "./baz.js";

5.5.1

Disabled rules

The formatting-related rules below have been disabled in all configs because we use biome or prettier to enforce formatting conventions. In addition, most of these rules are now deprecated because linters are decreasing their focus on formatting-related rules in favor of dedicated formatting tools.

typescript-eslint

  • @typescript-eslint/comma-spacing
  • @typescript-eslint/func-call-spacing
  • @typescript-eslint/keyword-spacing
  • @typescript-eslint/member-delimiter-style
  • @typescript-eslint/object-curly-spacing
  • @typescript-eslint/semi
  • @typescript-eslint/space-before-function-paren
  • @typescript-eslint/space-infix-ops
  • @typescript-eslint/type-annotation-spacing

eslint

All rules below are deprecated. See https://eslint.org/docs/latest/rules/#deprecated

  • array-bracket-spacing
  • arrow-spacing
  • block-spacing
  • dot-location
  • jsx-quotes
  • key-spacing
  • space-unary-ops
  • switch-colon-spacing

Better test pattern support

Update rule overrides for test code to better support patterns in the repo. Namely, adds the allowance to "**/tests" directories.

5.4.0

New no-unchecked-record-access rule

Enabled new no-unchecked-record-access rule to enforce safe property access on index signature types.

Disabled rules

The following rules have been disabled in all configs because they conflict with formatter settings:

The following rules have been disabled for test code:

The following rules have been disabled due to frequency of false-positives reported:

@typescript-eslint/explicit-function-return-type changes

The allowExpressions option for the @typescript-eslint/explicit-function-return-type rule has been set to true.

@typescript-eslint/no-explicit-any changes

The ignoreRestArgs option for the @typescript-eslint/no-explicit-any rule has been set to true.

import/no-internal-modules changes

All imports from @fluid-experimental packages are now permitted.

5.3.0

The import/order rule is enabled with the following settings:

[
    "error",
    {
        "newlines-between": "always",
        "alphabetize": {
            "order": "asc",
            "caseInsensitive": false
        }
    }
]

eslint-import-resolver-typescript preferred over node

Lint configurations previously specified both the node and typescript resolvers, with the node resolver taking precedence.

The precedence has been reversed in this release: eslint-import-resolver-typescript is now the preferred resolver.

This may result in lint rules dependent on imported types (rather than values) to correctly apply, e.g. import/no-deprecated.

allow-ff-test-exports condition enabled

The typescript import resolver now enables the "allow-ff-test-exports" condition, which adds support for linting files which reference FluidFramework test-only exports, such as id-compressor and merge-tree.

5.2.0

The import/order rule is now disabled in all configs.

5.1.0

Enables new API trimming rules.

5.0.0

Adds eslint-plugin-fluid to eslint-config-fluid. This new dependency adds new Fluid-specific rules.

4.0.0

Deprecates this package's minimal configuration. Consumers of that configuration will need to update their imports to refer to the renamed module: minimal-deprecated.js.

3.0.0

Update eslint-related dependencies

eslint has been updated to version ~8.49.0. eslint plugins have also been updated to the latest version.

Update prettier

prettier has been updated to version ~3.0.3.

Update #16699 typescript-eslint

typescript-eslint has been updated to version ~6.7.2.

2.1.0

Enable the import-no-deprecated rule

The import/no-deprecated rule is now enabled for all configs except test files.