npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-local-import-ext

v0.2.0

Published

Enforce file extension style in import declarations (fixable with --fix)

Readme

License: MIT TypeScript Vitest codecov

npm npm

eslint-plugin-local-import-ext

📝 Enforce the style of file extensions in import declarations.

🔧 This rule is automatically fixable by the --fix CLI option.

Targets local imports (paths starting with ./ or ../) and performs safe autofixes when run with --fix.

It recognizes many common extensions by default (.js, .mjs, .cjs, .ts, .tsx, .jsx, .vue, .json, images, styles, etc.) and supports Vite-style import query suffixes (e.g. ?raw).

[!NOTE] This ESLint plugin was created as a temporary workaround until the OXC/OXLint issue #19431 (https://github.com/oxc-project/oxc/issues/19431) is resolved. It helps catch missing local import file extensions during linting.

Recommended migration (disable import/extensions and enable this rule):

{
  "rules": {
    "import/extensions": "off",
    "local-import-ext/require-local-extension": ["error", { "js": "always", "ts": "never" }]
  }
}

Install

npm install eslint-plugin-local-import-ext

Quick usage

Below are two example ways to enable the rule in an OXLint/ESLint config: a minimal "Basic" example and a more explicit "Full" example (recommended for repo-wide consistency).

Basic OXLint config

{
  "plugins": ["import-ext"],
  "jsPlugins": ["eslint-plugin-local-import-ext"],
  "rules": {
    "local-import-ext/require-local-extension": [
      "error",
      {
        "js": "always",
        "ts": "never"
      }
    ]
  }
}

Full OXLint config (recommended)

{
  "plugins": ["import-ext"],
  "jsPlugins": ["eslint-plugin-local-import-ext"],
  "settings": {
    "localImportExt": {
      "preferredFixExt": ".js",
      "extRules": { "js": "always", "ts": "never" },
      "allowedExts": [".js",".mjs",".cjs",".ts",".tsx",".jsx",".vue",".json"],
      "excludedFolders": ["demos/**","test/**"],
      "ignorePackages": true
    }
  },
  "rules": {
    "local-import-ext/require-local-extension": [
      "error",
      {
        "preferredFixExt": ".js",
        "extRules": { "js": "always", "ts": "never" },
        "excludedFolders": ["demos/**","test/**"],
        "ignorePackages": true
      }
    ]
  }
}

Configuration options

Options can be passed either as rule options or via settings.localImportExt.

Key options:

  • excludedFolders: array of repo-relative folder globs to ignore (e.g. tests, demos).

  • allowedExts: array of allowed extensions for the rule.

  • preferredFixExt: single extension (string) the fixer should prefer when offering fixes (defaults to .js).

  • disallowedExts: array of extensions to explicitly avoid when fixing.

  • extRules: object mapping extensions to "always" or "never" (also supports the n-style mapping described below).

  • ignorePackages: when true, package imports (bare specifiers) are ignored and the rule only enforces local imports. This matches import/extensions compatibility where "ignorePackages" omits package imports from enforcement.

Two common config styles are supported:

  • object form (recommended):
{
  "rules": {
    "local-import-ext/require-local-extension": [
      "error",
      {
        "preferredFixExt": ".js",
        "extRules": { "js": "always", "ts": "never" },
        "excludedFolders": ["demos/aurelia/test"]
      }
    ]
  }
}
  • n-style shorthand (like eslint-plugin-n):
{
  "rules": {
    "local-import-ext/require-local-extension": [
      "error",
      {
        "js": "always",
        "ts": "never",
        "excludedFolders": ["demos/aurelia/test"]
      }
    ]
  }
}

How the fixer chooses an extension

  • The fixer prefers preferredFixExt (default .js).
  • If preferredFixExt is explicitly disallowed via extRules/disallowedExts (e.g. "ts": "never"), the fixer picks the first non-disallowed extension from its internal discovery order.
  • Crucially, the autofixer now only offers a fix when the chosen target file actually exists on disk (either base + ext or base/index + ext). This prevents converting to extensions that don't exist in your repo.

Behavior notes

  • Query/hash suffixes are preserved (e.g. ./file?raw -> ./file.js?raw).
  • Original quote style (' or ") is preserved.
  • Directory imports that resolve to an index file are supported (the fixer will append /index.js when that file exists).
  • Asset and style imports are ignored if their extensions are included in allowedExts.