eslint-plugin-light
raw JSON → 1.0.16 verified Sat Apr 25 auth: no javascript
ESLint plugin with Vue-specific rules for uni-app projects. Version 1.0.16, maintained by novlan1. Provides 5 rules focusing on Vue component imports, type coercion in templates, complex keys, JSON.parse error handling, and API import management. Designed for Node 12+ with peer dependencies on @babel/eslint-parser and ESLint 6+. Differentiates from general Vue ESLint plugins by targeting common uni-app pitfalls and offering auto-fix capabilities.
Common errors
error Error: Failed to load parser '@babel/eslint-parser' ↓
cause @babel/eslint-parser is not installed or not in node_modules.
fix
Run 'npm install @babel/eslint-parser --save-dev'.
error Definition for rule 'light/valid-vue-comp-import' was not found ↓
cause Plugin 'eslint-plugin-light' not loaded in plugins config.
fix
Add 'plugins: ["light"]' to .eslintrc.
Warnings
gotcha Plugin requires @babel/eslint-parser as parser to work with Vue files. ↓
fix Set 'parser: @babel/eslint-parser' in ESLint config.
gotcha Rules are only applicable to .vue files; ESLint config must include .vue in lint target. ↓
fix Use --ext .vue or specify in config.
gotcha No TypeScript definitions provided; plugin is JavaScript only. ↓
fix No way to add types; use @types/eslint for type hints.
Install
npm install eslint-plugin-light yarn add eslint-plugin-light pnpm add eslint-plugin-light Imports
- plugin wrong
require('eslint-plugin-light') in .eslintrccorrectmodule.exports = { plugins: ['light'] } - recommended config
extends: ['plugin:light/recommended'] - rule specific wrong
rules: { 'valid-vue-comp-import': 2 }correctrules: { 'light/valid-vue-comp-import': 'error' }
Quickstart
// Install ESLint and plugin
// npm i eslint @babel/eslint-parser eslint-plugin-light -D
// .eslintrc.js
module.exports = {
parser: '@babel/eslint-parser',
plugins: ['light'],
rules: {
'light/valid-vue-comp-import': 'error',
'light/no-plus-turn-number': 'warn',
'light/no-complex-key': 'error',
'light/json-parse-try-catch': 'error',
'light/no-import-all-in-one-api': ['error', { excludes: [] }],
},
};