CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-eslint-plugin-import

ESLint plugin that enforces ES2015+ import/export syntax rules and prevents common issues with module imports.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

helpful-warnings-rules.mddocs/

Helpful Warnings Rules

Rules that detect problematic patterns in import/export usage, providing helpful warnings about common issues like invalid exports, deprecated imports, and misused export patterns.

Capabilities

export

Forbids any invalid exports, including re-export of the same name.

/**
 * Forbid any invalid exports, i.e. re-export of the same name
 * @type {Rule.RuleModule}
 */
"import/export": {
  meta: {
    type: "problem",
    docs: {
      category: "Static analysis", 
      description: "Forbid any invalid exports, i.e. re-export of the same name.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/export.md"
    },
    schema: []
  },
  create: (context) => Rule.RuleListener
}

Usage Examples:

// ❌ Invalid - duplicate export names
export const foo = 1;
export const foo = 2; // Error: Multiple exports of name 'foo'

// ❌ Invalid - re-export same name
export { bar } from "./module1";
export { bar } from "./module2"; // Error: Multiple exports of name 'bar'

// ✅ Valid - unique export names
export const foo = 1;
export const baz = 2;

no-deprecated

Forbids imported names marked with @deprecated documentation tag.

/**
 * Forbid imported names marked with @deprecated documentation tag
 * @type {Rule.RuleModule}
 */
"import/no-deprecated": {
  meta: {
    type: "suggestion",
    docs: {
      category: "Helpful warnings",
      description: "Forbid imported names marked with `@deprecated` documentation tag.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-deprecated.md"
    },
    schema: []
  },
  create: (context) => Rule.RuleListener
}

no-empty-named-blocks

Forbids empty named import blocks.

/**
 * Forbid empty named import blocks
 * @type {Rule.RuleModule}
 */
"import/no-empty-named-blocks": {
  meta: {
    type: "suggestion",
    docs: {
      category: "Helpful warnings",
      description: "Forbid empty named import blocks.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-empty-named-blocks.md"
    },
    schema: [],
    fixable: "code",
    hasSuggestions: true
  },
  create: (context) => Rule.RuleListener
}

Usage Examples:

// ❌ Invalid - empty named import
import { } from "./module"; // Error: Empty named import block

// ❌ Invalid - only whitespace
import {   } from "./module"; // Error: Empty named import block

// ✅ Valid - has named imports
import { foo, bar } from "./module";

// ✅ Valid - default import only
import module from "./module";

// ✅ Valid - namespace import
import * as module from "./module";

no-extraneous-dependencies

Forbids the use of extraneous packages (dependencies not declared in package.json).

/**
 * Forbid the use of extraneous packages
 * @type {Rule.RuleModule}
 */
"import/no-extraneous-dependencies": {
  meta: {
    type: "problem",
    docs: {
      category: "Helpful warnings",
      description: "Forbid the use of extraneous packages.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-extraneous-dependencies.md"
    },
    schema: [{
      type: "object",
      properties: {
        devDependencies: { 
          type: ["boolean", "array"],
          default: true
        },
        optionalDependencies: {
          type: ["boolean", "array"], 
          default: false
        },
        peerDependencies: {
          type: ["boolean", "array"],
          default: false
        },
        bundledDependencies: {
          type: ["boolean", "array"],
          default: false
        },
        packageDir: {
          type: ["string", "array"]
        }
      },
      additionalProperties: false
    }]
  },
  create: (context) => Rule.RuleListener
}

no-mutable-exports

Forbids the use of mutable exports with var or let.

/**
 * Forbid the use of mutable exports with var or let
 * @type {Rule.RuleModule}
 */
"import/no-mutable-exports": {
  meta: {
    type: "suggestion",
    docs: {
      category: "Helpful warnings",
      description: "Forbid the use of mutable exports with `var` or `let`.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-mutable-exports.md"
    },
    schema: []
  },
  create: (context) => Rule.RuleListener
}

Usage Examples:

// ❌ Invalid - mutable exports
export var count = 0; // Error: Exporting mutable 'var' binding
export let name = ""; // Error: Exporting mutable 'let' binding

// ✅ Valid - immutable exports  
export const count = 0;
export const name = "";

// ✅ Valid - function exports (immutable reference)
export function increment() { /* ... */ }

no-named-as-default

Forbids use of exported name as identifier of default export.

/**
 * Forbid use of exported name as identifier of default export
 * @type {Rule.RuleModule}
 */
"import/no-named-as-default": {
  meta: {
    type: "problem",
    docs: {
      category: "Helpful warnings",
      description: "Forbid use of exported name as identifier of default export.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-named-as-default.md"
    },
    schema: []
  },
  create: (context) => Rule.RuleListener
}

no-named-as-default-member

Forbids use of exported name as property of default export.

/**
 * Forbid use of exported name as property of default export
 * @type {Rule.RuleModule}
 */
"import/no-named-as-default-member": {
  meta: {
    type: "suggestion",
    docs: {
      category: "Helpful warnings", 
      description: "Forbid use of exported name as property of default export.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-named-as-default-member.md"
    },
    schema: []
  },
  create: (context) => Rule.RuleListener
}

Usage Examples:

// Given a module with both named and default exports:
// module.js
export const foo = "named";
export default { foo: "default" };

// ❌ Invalid - accessing named export as default member
import MyModule from "./module";
console.log(MyModule.foo); // Warning: foo is exported as named, not as default member

// ✅ Valid - use named import
import { foo } from "./module";
console.log(foo);

// ✅ Valid - use default import for default export properties
import MyModule from "./module";  
console.log(MyModule.bar); // OK if bar is not a named export

no-unused-modules

Forbids modules without exports, or exports without matching import in another module.

/**
 * Forbid modules without exports, or exports without matching import in another module
 * @type {Rule.RuleModule}
 */
"import/no-unused-modules": {
  meta: {
    type: "suggestion",
    docs: {
      category: "Helpful warnings",
      description: "Forbid modules without exports, or exports without matching import in another module.",
      url: "https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-unused-modules.md"
    },
    schema: [{
      type: "object", 
      properties: {
        src: {
          description: "files/paths to be analyzed",
          type: "array",
          minItems: 1,
          items: { type: "string", minLength: 1 }
        },
        ignoreExports: {
          description: "files/paths for which unused exports will not be reported",
          type: "array",
          minItems: 1, 
          items: { type: "string", minLength: 1 }
        },
        missingExports: {
          description: "report modules without any exports",
          type: "boolean"
        },
        unusedExports: {
          description: "report exports without any usage",
          type: "boolean"
        }
      },
      not: {
        properties: {
          unusedExports: { enum: [false] },
          missingExports: { enum: [false] }
        }
      },
      anyOf: [{
        properties: {
          unusedExports: { enum: [true] }
        },
        required: ["unusedExports"]
      }, {
        properties: {
          missingExports: { enum: [true] }
        },
        required: ["missingExports"]
      }],
      additionalProperties: false
    }]
  },
  create: (context) => Rule.RuleListener
}

Rule Configuration

All helpful warning rules can be configured in your ESLint configuration:

// ESLint flat config
export default [{
  plugins: { import: importPlugin },
  rules: {
    "import/export": "error",
    "import/no-deprecated": "warn", 
    "import/no-empty-named-blocks": "error",
    "import/no-extraneous-dependencies": ["error", {
      "devDependencies": ["**/*.test.js", "**/*.spec.js"],
      "peerDependencies": false
    }],
    "import/no-mutable-exports": "error",
    "import/no-named-as-default": "warn",
    "import/no-named-as-default-member": "warn",
    "import/no-unused-modules": ["error", {
      "unusedExports": true,
      "src": ["src/**/*.js"]
    }]
  }
}];

// Legacy ESLint config
module.exports = {
  plugins: ["import"],
  rules: {
    "import/export": "error",
    "import/no-deprecated": "warn",
    "import/no-empty-named-blocks": "error",
    "import/no-extraneous-dependencies": "error",
    "import/no-mutable-exports": "error", 
    "import/no-named-as-default": "warn",
    "import/no-named-as-default-member": "warn",
    "import/no-unused-modules": "error"
  }
};

docs

configuration-presets.md

helpful-warnings-rules.md

index.md

module-systems-rules.md

plugin-interface.md

static-analysis-rules.md

style-guide-rules.md

tile.json