@component-hook/eslint-plugin
@component-hook/eslint-plugin
A opinionated ESLint config preset for JavaScript, TypeScript, Vue3, React, Prettier and oxfmt.
Features
- Support
TypeScript,Vue3andReactout-of-box. - Format with
Prettieroroxfmt. - 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-configis 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.jsin a"type": "module"project or aseslint.config.mjs. On Node.js 20.19+ / 22.12+require()still works throughrequire(esm), and the plugin is exposed on thedefaultproperty.
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
- eslint-recommended
- typescript-eslint
- eslint-plugin-eslint-comments
- eslint-plugin-import
- eslint-plugin-unicorn
- eslint-plugin-regexp/flat/recommended
- eslint-plugin-de-morgan
- eslint-plugin-jsdoc
- eslint-plugin-jsonc
- eslint-plugin-perfectionist
- eslint-plugin-yml
- eslint-plugin-prettier/recommended
- eslint-plugin-oxfmt
- eslint-plugin-react/recommended
- eslint-plugin-react-hooks/recommended
- eslint-plugin-jsx-a11y/recommended
- eslint-plugin-vue
- @eslint/markdown
- eslint-plugin-sonarjs/recommended
- eslint-plugin-security/recommended
- eslint-plugin-testing-library/dom
- eslint-plugin-testing-library/vue
- eslint-plugin-testing-library/react
- eslint-plugin-testing-library/angular
- eslint-plugin-testing-library/marko
- eslint-plugin-playwright/flat/recommended
Related Packages
This checks is data-test-id prop is present, on some tags which are useful for e...
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 | |
| 1.4.3 | MIT | |
| 1.4.2 | MIT | |
| 1.4.1 | MIT | |
| 1.4.0 | MIT | |
| 1.3.2 | MIT | |
| 1.3.1 | MIT | |
| 1.3.0 | MIT | |
| 1.2.2 | MIT | |
| 1.2.1 | MIT | |
| 1.2.0 | MIT | |
| 1.1.5 | MIT | |
| 1.1.4 | MIT | |
| 1.1.3 | MIT | |
| 1.1.2 | MIT | |
| 1.1.1 | MIT | |
| 1.1.0 | MIT | |
| 1.0.4 | MIT | |
| 1.0.3 | MIT | |
| 1.0.2 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT | |
| 0.2.5 | MIT | |
| 0.2.4 | MIT | |
| 0.2.3 | MIT | |
| 0.2.2 | MIT |
Showing the latest 30 of 37. See every release on npm
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 | |
| 0.1.5-alpha.1 | MIT | |
| 0.1.5-alpha.0 | MIT | |
| 0.1.4-alpha.3 | MIT | |
| 0.1.4-alpha.2 | MIT | |
| 0.1.4-alpha.1 | MIT | |
| 0.1.4-alpha.0 | MIT | |
| 0.1.3-alpha.0 | MIT | |
| 0.1.2-alpha.4 | MIT | |
| 0.1.2-alpha.3 | MIT | |
| 0.1.2-alpha.2 | MIT | |
| 0.1.2-alpha.1 | MIT | |
| 0.1.2-alpha.0 | MIT |