@component-hook/eslint-plugin

ESLint config for component hook
8,834 4
Install
npm install @component-hook/eslint-plugin
Latest Version:1.7.0
License:MIT
Last Updated:Oct 23, 2026
Links: GitHub  ·  npm
Maintainer: tzuyi0817

@component-hook/eslint-plugin

A opinionated ESLint config preset for JavaScript, TypeScript, Vue3, React, Prettier and oxfmt.

npm npm

Features

  • Support TypeScript, Vue3 and React out-of-box.
  • Format with Prettier or oxfmt.
  • Ignores common files like dist, node_modules, coverage, and files in .gitignore.
  • Various built-in configurations can be referenced according to respective needs.
  • Reasonable defaults, best practices, and just a few lines of configuration.
  • Prefer oxlint? @component-hook/oxlint-config is generated from this preset.

Documentation

For detailed documentation and usage examples, please visit: Official Docs.

Installation

# Using npm
$ npm install @component-hook/eslint-plugin --save-dev

# Using yarn
$ yarn add @component-hook/eslint-plugin --dev

# Using pnpm
$ pnpm install @component-hook/eslint-plugin --save-dev

Compatibility Note:

Require ESLint >= 9.0.0

This package is ESM only because several bundled plugins are ESM only. Write your config as eslint.config.js in a "type": "module" project or as eslint.config.mjs. On Node.js 20.19+ / 22.12+ require() still works through require(esm), and the plugin is exposed on the default property.

Basic Usage

import componentHookPlugin from '@component-hook/eslint-plugin';

export default [
  ...componentHookPlugin.configs.basic,
  ...componentHookPlugin.configs.vue,
  componentHookPlugin.configs.prettier,
  ...componentHookPlugin.configs.sonarjs,
  componentHookPlugin.configs.security,
  ...componentHookPlugin.configs.markdown,
  {
    files: ['**/*.test.[jt]s?(x)'],
    ...componentHookPlugin.configs['testing-library/vue'],
  },
  {
    files: ['**/e2e/**/*.spec.[jt]s?(x)'],
    ...componentHookPlugin.configs.playwright,
  },
  // your custom config
];

See basic and ignores for more details.

React Presets Usage

Includes basic, react, markdown, prettier, sonarjs, security configs.

import { reactPreset } from '@component-hook/eslint-plugin';

export default reactPreset;

Vue Presets Usage

Includes basic, vue, markdown, prettier, sonarjs, security configs.

import { vuePreset } from '@component-hook/eslint-plugin';

export default vuePreset;

Formatting with oxfmt

Use configs.oxfmt instead of configs.prettier to format with oxfmt. It discovers .oxfmtrc.json (or other oxfmt config files) the same way as the oxfmt CLI, and turns off the stylistic rules that conflict with the formatter.

oxfmt also sorts top-level package.json keys by default (sortPackageJson), so the preset no longer orders them itself; it still sorts nested fields oxfmt leaves alone, such as exports conditions and dependency maps. If you stay on configs.prettier and still want package.json sorted, add prettier-plugin-packagejson, which uses the same sort-package-json order as oxfmt.

oxfmt >= 0.71.0 is a peer dependency. Most package managers install it automatically; otherwise add it yourself:

$ pnpm add -D oxfmt
import componentHookPlugin from '@component-hook/eslint-plugin';

export default [
  ...componentHookPlugin.configs.basic,
  ...componentHookPlugin.configs.vue,
  componentHookPlugin.configs.oxfmt,
  // your custom config
];

Configs

Name Type Reference
basic Linter.Config[] eslint-recommended, typescript-eslint, eslint-plugin-eslint-comments, eslint-plugin-import, eslint-plugin-unicorn, eslint-plugin-jsdoc, eslint-plugin-regexp, eslint-plugin-de-morgan, eslint-plugin-perfectionist, eslint-plugin-jsonc, eslint-plugin-yml
vue Linter.Config[] eslint-plugin-vue, typescript-eslint
react Linter.Config[] eslint-plugin-react/recommended, eslint-plugin-react-hooks/recommended, eslint-plugin-jsx-a11y/recommended
markdown Linter.Config[] @eslint/markdown
prettier Linter.Config eslint-plugin-prettier/recommended
oxfmt Linter.Config eslint-plugin-oxfmt, eslint-config-prettier
sonarjs Linter.Config[] eslint-plugin-sonarjs/recommended
security Linter.Config eslint-plugin-security/recommended
playwright Linter.Config eslint-plugin-playwright/flat/recommended
testing-library/dom Linter.Config eslint-plugin-testing-library/dom
testing-library/vue Linter.Config eslint-plugin-testing-library/vue
testing-library/react Linter.Config eslint-plugin-testing-library/react
testing-library/angular Linter.Config eslint-plugin-testing-library/angular
testing-library/marko Linter.Config eslint-plugin-testing-library/marko

Reference eslint plugin

Related Packages

eslint-plugin-vue-storefront

ESLint rules for Vue Storefront

39,292
@scayle/eslint-plugin-vue-composable

Rules to avoid unpleasant composable problems

207,394 4
@cloudflight/eslint-plugin-vue

Cloudflight eslint-plugin & eslint-config for vue

38,060
eslint-plugin-test-id

This checks is data-test-id prop is present, on some tags which are useful for e...

10,384 17
eslint-plugin-vueunused

a eslint plugin for detecting unused code in vue single file component

939

Version History

Version Released License
1.7.0 MIT
1.6.0 MIT
1.5.1 MIT
1.5.0 MIT
1.4.4 MIT
Pre-releases (17)
Version Released License
0.2.2-alpha.2 MIT
0.2.2-alpha.1 MIT
0.2.2-alpha.0 MIT
0.1.7-alpha.0 MIT
0.1.6-alpha.0 MIT