eslint-config-taro
raw JSON → 4.2.0 verified Sat Apr 25 auth: no javascript
ESLint configuration for Taro projects, providing linting rules for React/JSX and Vue (optional). Current stable version 4.2.0, released as part of Taro monorepo. Requires ESLint ^8 and supports both Taro 3 and 4. Integrates with eslint-plugin-react, eslint-plugin-react-hooks, and optionally eslint-plugin-vue. Designed for cross-platform app development. Differentiator: official config from Taro team with rules tuned for Taro's component system and JSX transformations. Release cadence follows Taro releases (~monthly).
Common errors
error Cannot find module 'eslint-plugin-react-hooks' ↓
cause Missing peer dependency eslint-plugin-react-hooks.
fix
Run: npm install eslint-plugin-react-hooks --save-dev
error ESLint couldn't find the config 'taro'. ↓
cause eslint-config-taro not installed or not in node_modules.
fix
Run: npm install eslint-config-taro --save-dev
error Configuration for rule 'react/jsx-uses-react' is invalid ↓
cause Outdated eslint-plugin-react version incompatible with Taro config.
fix
Update eslint-plugin-react to ^7.33.2 or later.
Warnings
breaking eslint-config-taro v4 requires ESLint ^8 and drops support for ESLint <8. ↓
fix Upgrade ESLint to ^8.0.0.
breaking In v4, the config is ESM-only. CommonJS require() may fail unless using .eslintrc.cjs. ↓
fix Rename .eslintrc to .eslintrc.cjs or use dynamic import.
deprecated eslint-plugin-vue is optional but must be installed explicitly; not automatically included. ↓
fix If using Vue, add eslint-plugin-vue as a devDependency.
gotcha Using extends: ['taro'] without eslint-plugin-react-hooks installed will cause ESLint to crash. ↓
fix Install eslint-plugin-react-hooks as a devDependency.
deprecated Config v3.x is deprecated; upgrade to v4 for future updates. ↓
fix Update eslint-config-taro to ^4.0.0.
Install
npm install eslint-config-taro yarn add eslint-config-taro pnpm add eslint-config-taro Imports
- default export wrong
const taroConfig = require('eslint-config-taro')correctimport taroConfig from 'eslint-config-taro' - extends in ESLint config wrong
"extends": ["eslint-config-taro"]correct"extends": ["taro"] - extends for Vue support wrong
"extends": ["taro"] // without /vue will not enable Vue rulescorrect"extends": ["taro/vue"]
Quickstart
// .eslintrc.cjs
module.exports = {
root: true,
extends: ['taro'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
settings: {
react: {
version: 'detect'
}
},
rules: {
// custom rules
}
};