Socket
Socket
Sign inDemoInstall

eslint-plugin-vue

Package Overview
Dependencies
100
Maintainers
5
Versions
166
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-plugin-vue

Official ESLint plugin for Vue.js


Version published
Weekly downloads
2.9M
decreased by-1.33%
Maintainers
5
Install size
6.45 MB
Created
Weekly downloads
 

Package description

What is eslint-plugin-vue?

The eslint-plugin-vue npm package is a plugin for ESLint specifically designed for Vue.js applications. It provides linting rules that are tailored to the Vue.js framework, helping developers to write consistent and error-free code by following best practices and avoiding common mistakes.

What are eslint-plugin-vue's main functionalities?

Style Guide Enforcement

Enforces a style guide by limiting the number of attributes per line in Vue templates. This helps in maintaining readability and consistency in the codebase.

"vue/max-attributes-per-line": ["error", { "singleline": 3, "multiline": { "max": 1, "allowFirstLine": false } }]

Component Naming

Ensures that component names in templates are written in a specific case, such as PascalCase, which is a common convention in Vue.js projects.

"vue/component-name-in-template-casing": ["error", "PascalCase"]

Avoiding Deprecated Features

Prevents the use of deprecated features like the 'slot' attribute, encouraging developers to use the updated syntax and features of Vue.js.

"vue/no-deprecated-slot-attribute": "error"

Prop Validation

Ensures that every prop has a default value, which can prevent bugs and make the components more predictable.

"vue/require-default-prop": "error"

Script Indentation

Enforces consistent indentation in the script section of Vue single-file components, which improves code readability and maintainability.

"vue/script-indent": ["error", 2, { "baseIndent": 1, "switchCase": 1, "ignores": [] }]

Other packages similar to eslint-plugin-vue

Readme

Source

eslint-plugin-vue

NPM version NPM downloads CircleCI License

Official ESLint plugin for Vue.js

:book: Documentation

Please refer to the official website.

:anchor: Versioning Policy

This plugin follows Semantic Versioning and ESLint's Semantic Versioning Policy.

:newspaper: Releases

This project uses GitHub Releases.

:beers: Contribution Guide

Contributing is welcome! See the ESLint Vue Plugin Developer Guide.

Working With Rules

Be sure to read the official ESLint guide before you start writing a new rule.

To see what an abstract syntax tree (AST) of your code looks like, you may use AST Explorer. After opening AST Explorer, select Vue as the syntax and vue-eslint-parser as the parser.

The default JavaScript parser must be replaced because Vue.js single file components are not plain JavaScript, but a custom file format. vue-eslint-parser is a replacement parser that generates an enhanced AST with nodes that represent specific parts of the template syntax, as well as the contents of the <script> tag.

To learn more about certain nodes in a produced AST, see the ESTree project page and the vue-eslint-parser AST documentation.

vue-eslint-parser provides a few useful parser services to help traverse the produced AST and access template tokens:

  • context.parserServices.defineTemplateBodyVisitor(visitor, scriptVisitor)
  • context.parserServices.getTemplateBodyTokenStore()

Check out an example rule to see usage of these services.

Be aware that depending on the code samples you write in tests, the RuleTester parser property must be set accordingly (this can be done on a test by test basis). See an example here.

If you're stuck, remember there are many rules available for reference. If you can't find the right solution, don't hesitate to reach out in issues – we're happy to help!

:lock: License

See the LICENSE file for license rights and limitations (MIT).

Keywords

FAQs

Last updated on 14 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc