eslint-config-unjs

raw JSON →
0.6.2 verified Sat Apr 25 auth: no javascript

ESLint flat config preset for unjs projects, currently at v0.6.2. It integrates eslint recommended rules, eslint-plugin-unicorn, typescript-eslint, and eslint-plugin-markdown. This package is designed exclusively for ESLint's new flat config system (ESLint v9+). It provides a single exported function that accepts options for ignoring paths, overriding rules, and customizing markdown-specific rules. The package ships TypeScript types and is actively maintained with frequent dependency updates. Key differentiators include its tailored rule set for the unjs ecosystem and support for type-generated rule configurations via eslint-typegen.

error Cannot find module 'eslint-config-unjs' or its corresponding type declarations.
cause Missing npm install or using CommonJS require.
fix
Run npm install -D eslint-config-unjs and use import (ESM) instead of require.
error Error: Failed to load config 'eslint-config-unjs' to extend from.
cause Attempting to use preset in legacy .eslintrc with 'extends' field.
fix
Migrate to flat config (eslint.config.mjs) and use import unjs from 'eslint-config-unjs'.
error Parsing error: The keyword 'export' is reserved.
cause ES module syntax used in a CommonJS file (e.g., .js without type: module).
fix
Rename file to .mjs or add "type": "module" in package.json.
breaking ESLint flat config only: This preset does not support legacy .eslintrc configuration. Requires ESLint v9 and flat config.
fix Migrate to flat config: use eslint.config.mjs and call import unjs from 'eslint-config-unjs'.
breaking v0.3.0 dropped support for ESLint <9 and legacy config. All previous versions (0.2.x) are incompatible.
fix Upgrade ESLint to v9 and rewrite config as flat config.
deprecated Some unicorn rules may change between minor versions. Check changelog when upgrading.
fix Review unicorn plugin updates and adjust rules accordingly.
gotcha The unjs function returns an array, not a single object. Attempting to use it directly as a config object will fail.
fix Spread the result if merging with other configs: export default [ ...unjs(...), ...otherConfigs ];
gotcha Types for rules are not auto-generated in this package; you must use eslint-typegen separately.
fix Install @antfu/eslint-typegen and run it to generate rule types.
npm install eslint-config-unjs
yarn add eslint-config-unjs
pnpm add eslint-config-unjs

Creates an ESLint flat config using unjs preset with custom ignores, rule overrides, and markdown-specific overrides.

import unjs from 'eslint-config-unjs';

export default unjs({
  ignores: [
    'dist',
    'node_modules',
    '*.config.*',
  ],
  rules: {
    'unicorn/filename-case': ['error', { case: 'kebabCase' }],
    '@typescript-eslint/no-unused-vars': 'warn',
  },
  markdown: {
    rules: {
      'unicorn/filename-case': 'off',
    },
  },
});