eslint-plugin-vtex

raw JSON →
2.3.0 verified Sat Apr 25 auth: no javascript

VTEX's custom ESLint plugin providing rules like prefer-early-return and enforce-explicit-enum-values. Current stable version is 2.3.0. The plugin is actively maintained by VTEX and ships TypeScript type definitions. It supports ESLint versions 6, 7, and 8. Unlike generic ESLint plugins, this one targets VTEX-specific coding conventions, making it essential for projects within the VTEX ecosystem. The plugin is released on npm and follows semantic versioning.

error ESLint couldn't find the plugin "eslint-plugin-vtex". The package is not installed, or the plugin name is misspelled.
cause Using the full npm package name in the plugins array instead of the abbreviated name.
fix
Change plugins: ["eslint-plugin-vtex"] to plugins: ["vtex"]
error Definition for rule 'prefer-early-return' was not found.
cause Missing the plugin prefix in the rule name.
fix
Use 'vtex/prefer-early-return' instead of 'prefer-early-return'
gotcha Plugin name must be 'vtex' not 'eslint-plugin-vtex' in the plugins array.
fix Set plugins: ["vtex"]
gotcha Rule names must be prefixed with 'vtex/' in the rules object.
fix Use 'vtex/prefer-early-return' instead of 'prefer-early-return'
breaking Dropped support for ESLint <6 in version 2.0.0.
fix Upgrade ESLint to version 6 or later.
npm install eslint-plugin-vtex
yarn add eslint-plugin-vtex
pnpm add eslint-plugin-vtex

Enables the vtex plugin and its two custom rules in an ESLint config file.

// .eslintrc.json
{
  "plugins": ["vtex"],
  "rules": {
    "vtex/prefer-early-return": "warn",
    "vtex/enforce-explicit-enum-values": "error"
  }
}