Hexo ESLint Configuration
raw JSON → 6.0.0 verified Sat Apr 25 auth: no javascript
The official ESLint shareable config for Hexo projects. Current version 6.0.0 requires Node >=18 and ESLint >=9.17.0, and has migrated to ESLint's flat config system (eslint.config.js), breaking from the legacy .eslintrc format used in prior versions. It includes overrides for Hexo's code style and supports TypeScript via a separate import (eslint-config-hexo/ts). Use this to enforce consistent linting rules across Hexo plugins and themes. Differentiator: tailored specifically for Hexo, not a generic config.
Common errors
error Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'eslint-config-hexo' ↓
cause Attempting to import an ESM-only package from a CommonJS context without proper handling, or package not installed.
fix
Ensure eslint-config-hexo is installed: npm install eslint-config-hexo --save-dev. If using require, use require('eslint-config-hexo').
error Configuration for rule "no-console" is invalid ↓
cause The 'no-console' rule was enabled in v5 but user may have misconfigured it.
fix
Set 'no-console' to 'off' or 'warn' in your config: rules: { 'no-console': 'off' }
error ESLint couldn't find the config 'eslint-config-hexo' ↓
cause Package not installed or not in node_modules.
fix
Run npm install eslint-config-hexo --save-dev
Warnings
breaking v6.0.0 migrated to ESLint flat config (eslint.config.js). Legacy .eslintrc files are no longer supported. ↓
fix Replace .eslintrc.* with eslint.config.js. Import config as an array and spread it.
breaking v6.0.0 requires Node.js >=18 and ESLint >=9.17.0. Older Node or ESLint versions will fail. ↓
fix Update Node.js to >=18 and ESLint to >=9.17.0.
deprecated v5.0.0 enabled no-console rule, which was not enabled before. Existing code with console.log may now fail linting. ↓
fix Disable 'no-console' rule in your config if console is allowed.
gotcha The TypeScript config (eslint-config-hexo/ts) is only available from an undocumented subpath. Not all users may know to import from '/ts'. ↓
fix Import TypeScript rules from 'eslint-config-hexo/ts' as a separate array.
Install
npm install eslint-config-hexo yarn add eslint-config-hexo pnpm add eslint-config-hexo Imports
- hexoConfig (default) wrong
const hexoConfig = require('eslint-config-hexo')correctimport hexoConfig from 'eslint-config-hexo' - hexoTsLintConfig (TypeScript) wrong
const hexoTsLintConfig = require('eslint-config-hexo/ts')correctimport hexoTsLintConfig from 'eslint-config-hexo/ts' - FlatConfig export
const hexoConfig = require('eslint-config-hexo')
Quickstart
// eslint.config.js
import hexoConfig from 'eslint-config-hexo';
import hexoTsLintConfig from 'eslint-config-hexo/ts';
export default [
...hexoConfig,
...hexoTsLintConfig,
{
rules: {
'no-console': 'warn',
'@typescript-eslint/no-explicit-any': 'off'
}
}
];