Skip to main content
interlace
Plugin: import-nextRules

no-webpack-loader-syntax

Forbid webpack loader syntax in imports

Rule Details

import css from 'style!css!./app.css' configures webpack's loaders inside the module specifier. The module then builds only under webpack, and the loader chain is hidden from the webpack config, where every other loader is declared. This rule reports a ! in the specifier of every way a module is loaded or re-exported: import, side-effect import, export … from, export * from, require(), import() and TypeScript's import x = require().

Declare the loaders in module.rules of the webpack config instead, and import the plain path.

❌ Incorrect

import theme from 'style!css!./theme.css';
const find = require('-babel-loader!lodash.find');

✅ Correct

import theme from './theme.css';
const find = require('lodash.find');

Options

This rule has no options.

When Not To Use It

When the code is built only by webpack and inline loader configuration is the house style.

Use this rule

npm install -D oxlint-plugin-import-next
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-import-next"],  "rules": {    "import-next/no-webpack-loader-syntax": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-import-next'],    rules: {      'import-next/no-webpack-loader-syntax': '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.