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.

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.
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.
npm install eslint-plugin-light
yarn add eslint-plugin-light
pnpm add eslint-plugin-light

Install and configure eslint-plugin-light with all rules and recommended parser.

// 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: [] }],
  },
};