Skip to main content
interlace
Plugin: import-nextRules

no-amd

Prevents AMD require/define calls

💼 This rule is enabled in the following configs: recommended, typescript.

Rule Details

AMD (define / require with a dependency array) predates ES modules; bundlers and type checkers understand import / export far better. This rule reports an AMD module:

  • a call to the global define, in any form: dependency array and factory, a bare factory, a named module, an object;
  • a call to the global require with a dependency array and a callback (require(['a'], (a) => ...)).

The rule decides by binding: a define or require that the file imports or declares is another function that shares the name, and is not AMD. A member call (customElements.define(...)) is not AMD, and require('m') with a string is CommonJS (see no-commonjs).

❌ Incorrect

define(['./dep'], function (dep) {
  return dep;
});
require(['./dep'], (dep) => dep.start());

✅ Correct

import dep from './dep';
import { define } from './registry';
define('widget', Widget);
customElements.define('x-app', App);

Options

[
  {
    "type": "object",
    "properties": {
      "allow": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "File globs (or path substrings) where AMD is allowed."
      },
      "suggestES6": {
        "type": "boolean",
        "default": true,
        "description": "Has no effect; accepted so existing configs keep validating."
      }
    },
    "additionalProperties": false
  }
]
  • allow (default []): file globs (or path substrings) where AMD is accepted, e.g. ["**/legacy/**"]. A glob matches any run of whole path segments, so vendor/** matches an absolute filename.
  • suggestES6: has no effect; accepted so existing configs keep validating.

When Not To Use It

In a codebase that ships AMD modules on purpose, e.g. for a RequireJS loader.

Use this rule

npm install -D oxlint-plugin-import-next
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-import-next"],  "rules": {    "import-next/no-amd": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-import-next'],    rules: {      'import-next/no-amd': 'error',    },  },});

oxlint-plugin-import-next re-exports eslint-plugin-import-next/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.

Did this rule catch something? Star the repo to get new CWE coverage as we ship it — or follow the AI-code-security benchmarks behind these rules.