Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions common/build/eslint-config-fluid/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @fluidframework/eslint-config-fluid Changelog

## [8.0.0](https://github.com/microsoft/FluidFramework/releases/tag/eslint-config-fluid_v8.0_0)

### eslint-plugin-import replaced by eslint-plugin-import-x

The package now uses rules from [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x) instead of
eslint-plugin-import. Integrating this change will require renaming eslint disable comments and overrides, but the
changes are mechanical.

## [7.0.0](https://github.com/microsoft/FluidFramework/releases/tag/eslint-config-fluid_v7.0_0)

### New Rules
Expand Down
72 changes: 52 additions & 20 deletions common/build/eslint-config-fluid/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Licensed under the MIT License.
*/

const tsResolver = require("eslint-import-resolver-typescript");

/**
* Base configuration from which all of our exported configs extends.
*/
Expand All @@ -19,9 +21,9 @@ module.exports = {
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
// import/recommended is the combination of import/errors and import/warnings
"plugin:import/recommended",
"plugin:import/typescript",
// import-x/recommended is the combination of import-x/errors and import-x/warnings
"plugin:import-x/recommended",
"plugin:import-x/typescript",
],
globals: {
Atomics: "readonly",
Expand All @@ -36,7 +38,7 @@ module.exports = {
sourceType: "module",
project: "./tsconfig.json",
},
plugins: ["import", "unicorn"],
plugins: ["import-x", "unicorn"],
reportUnusedDisableDirectives: true,
rules: {
// These rules were deprecated, then removed in `@typescript-eslint/eslint-plugin` v8.
Expand Down Expand Up @@ -167,21 +169,21 @@ module.exports = {
},
],

// #region eslint-plugin-import
// #region eslint-plugin-import-x

"import/no-default-export": "error",
"import/no-deprecated": "off",
"import/no-extraneous-dependencies": "error",
"import/no-internal-modules": "error",
"import/no-unassigned-import": "error",
"import/no-unresolved": [
"import-x/no-default-export": "error",
"import-x/no-deprecated": "off",
"import-x/no-extraneous-dependencies": "error",
"import-x/no-internal-modules": "error",
"import-x/no-unassigned-import": "error",
"import-x/no-unresolved": [
"error",
{
caseSensitive: true,
},
],
"import/no-unused-modules": "error",
"import/order": [
"import-x/no-unused-modules": "error",
"import-x/order": [
"error",
{
"newlines-between": "always",
Expand Down Expand Up @@ -372,15 +374,45 @@ module.exports = {
},
],
settings: {
"import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
"import-x/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
"import-x/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".d.ts", ".cts", ".mts"],
},
"import/resolver": {
// See remark in minimal-deprecated.js on the importance of import/resolver key order.
node: {
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
"import-x/resolver": {
name: "tsResolver",
options: {
typescript: {
extensions: [
// `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used
// explicitly in imports
".ts",
".tsx",
".d.ts",
".js",
".jsx",
],
conditionNames: [
// This supports the test-only conditional export pattern used in merge-tree and id-compressor.
"allow-ff-test-exports",

// Default condition names below, see https://github.com/import-js/eslint-import-resolver-typescript#conditionnames
"types",
"import",

// APF: https://angular.io/guide/angular-package-format
"esm2020",
"es2020",
"es2015",

"require",
"node",
"node-addons",
"browser",
"default",
],
},
},
resolver: tsResolver, // required
},
},
};
66 changes: 11 additions & 55 deletions common/build/eslint-config-fluid/minimal-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/**
* Shared list of permitted imports for configuring and override the `import/no-internal-modules` rule.
* Shared list of permitted imports for configuring and override the `import-x/no-internal-modules` rule.
*/
const permittedImports = [
// Within Fluid Framework allow import of '/internal' from other FF packages.
Expand Down Expand Up @@ -69,14 +69,7 @@ module.exports = {
es2024: false,
node: true,
},
extends: [
"./base",
"plugin:eslint-comments/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"prettier",
],
extends: ["./base", "plugin:eslint-comments/recommended", "prettier"],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
Expand Down Expand Up @@ -181,7 +174,7 @@ module.exports = {
],

"eqeqeq": ["error", "smart"],
"import/no-deprecated": "error",
"import-x/no-deprecated": "error",
"max-len": [
"error",
{
Expand Down Expand Up @@ -411,13 +404,13 @@ module.exports = {
* By default, libraries should not take dependencies on node libraries.
* This rule can be disabled at the project level for libraries that are intended to be used only in node.
*/
"import/no-nodejs-modules": ["error"],
"import-x/no-nodejs-modules": ["error"],

/**
* Allow Fluid Framework to import from its own internal packages.
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-internal-modules.md
* https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-internal-modules.md
*/
"import/no-internal-modules": [
"import-x/no-internal-modules": [
"error",
{
allow: permittedImports,
Expand Down Expand Up @@ -467,8 +460,8 @@ module.exports = {
rules: {
"@typescript-eslint/no-invalid-this": "off",
"@typescript-eslint/unbound-method": "off", // This rule has false positives in many of our test projects.
"import/no-nodejs-modules": "off", // Node libraries are OK for test files.
"import/no-deprecated": "off", // Deprecated APIs are OK to use in test files.
"import-x/no-nodejs-modules": "off", // Node libraries are OK for test files.
"import-x/no-deprecated": "off", // Deprecated APIs are OK to use in test files.

// Disabled for test files
"@typescript-eslint/consistent-type-exports": "off",
Expand All @@ -482,7 +475,7 @@ module.exports = {
],

// For test files only, additionally allow import of '/test*' and '/internal/test*' exports.
"import/no-internal-modules": [
"import-x/no-internal-modules": [
"error",
{
allow: ["@fluid*/*/test*", "@fluid*/*/internal/test*"].concat(
Expand All @@ -492,49 +485,12 @@ module.exports = {
],

// Test code may leverage dev dependencies
"import/no-extraneous-dependencies": ["error", { devDependencies: true }],
"import-x/no-extraneous-dependencies": ["error", { devDependencies: true }],
},
},
],
settings: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to base.js

"import/extensions": [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx", ".d.ts"],
},
"import/resolver": {
/**
* Note: the key order of import/resolver is relevant in the completely resolved eslint config (see ./printed-configs).
* Resolvers are tried in key order, and the first one to successfully resolve the import wins. See:
* https://github.com/import-js/eslint-plugin-import/blob/c0ac54b8a721c2b1c9048838acc4d6282f4fe7a7/utils/resolve.js#L196
*
* It's important that the typescript resolver is first, as the node resolver legitimately resolves some imports to modules
* with stripped type information, which can cause silent negatives in lint rules. For example, import/no-deprecated fails
* to lint against import and usage of deprecated types when the import is resolvable and resolved using the node resolver.
*/
typescript: {
extensions: [".ts", ".tsx", ".d.ts", ".js", ".jsx"],
conditionNames: [
// This supports the test-only conditional export pattern used in merge-tree and id-compressor.
"allow-ff-test-exports",

// Default condition names below, see https://www.npmjs.com/package/eslint-import-resolver-typescript#conditionnames
"types",
"import",

// APF: https://angular.io/guide/angular-package-format
"esm2020",
"es2020",
"es2015",

"require",
"node",
"node-addons",
"browser",
"default",
],
},
},
"jsdoc": {
jsdoc: {
// The following are intended to keep js/jsx JSDoc comments in line with TSDoc syntax used in ts/tsx code.
tagNamePreference: {
arg: {
Expand Down
4 changes: 2 additions & 2 deletions common/build/eslint-config-fluid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluidframework/eslint-config-fluid",
"version": "7.0.0",
"version": "8.0.0",
"description": "Shareable ESLint config for the Fluid Framework",
"homepage": "https://fluidframework.com",
"repository": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"eslint-config-prettier": "~10.1.8",
"eslint-import-resolver-typescript": "~4.4.4",
"eslint-plugin-eslint-comments": "~3.2.0",
"eslint-plugin-import": "npm:eslint-plugin-i@~2.29.1",
"eslint-plugin-import-x": "~4.16.1",
"eslint-plugin-jsdoc": "~55.0.2",
"eslint-plugin-promise": "~7.2.1",
"eslint-plugin-react": "~7.37.5",
Expand Down
Loading
Loading