eslint-plugin-userscripts
TypeScript icon, indicating that this package has built-in type declarations

0.5.6 • Public • Published

eslint-plugin-userscripts

Implements rules for userscripts in eslint.

Installation

You'll first need to install ESLint:

npm install eslint --save-dev

Next, install eslint-plugin-userscripts:

npm install eslint-plugin-userscripts --save-dev

Usage in legacy config

Add userscripts to the plugins section of your .eslintrc configuration file:

{
  "extends": ["plugin:userscripts/recommended"]
}

Usage in recent flat config

Add an element to the config array in your eslint.config.* file :

const userscripts = require('eslint-plugin-userscripts');

module.exports = [
  // other configs
  {
    files: ['*.user.js'],
    plugins: {
      userscripts: {
        rules: userscripts.rules
      }
    },
    rules: {
      ...userscripts.configs.recommended.rules
    },
    settings: {
      userscriptVersions: {
        violentmonkey: '*'
      }
    }
  }
];

Supported Rules

Rule Description Recommended
filename-user Ensures userscripts end with .user.js
no-invalid-grant Ensures the argument passed to @grant is valid
no-invalid-metadata Ensures userscripts have valid metadata
require-name Ensures userscripts have a name
require-description Ensures userscripts have a description
require-version Ensures userscripts have a valid version
use-homepage-and-url Ensures that for each homepage attribute, homepageURL is also used
require-download-url Ensures that for each downloadURL there is a updateURL
align-attributes Ensures that attributes are spaced out and aligned
require-attribute-space-prefix Ensure that attributes are prefixed by one space
metadata-spacing Ensures there is a newline between the metadata and the code
no-invalid-headers Ensures userscripts have valid headers
compat-grant Ensures your @grant permissions are supported
compat-headers Ensures your headers are supported
better-use-match Prefers @match over @include

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.5.61,001latest

Version History

VersionDownloads (Last 7 Days)Published
0.5.61,001
0.5.51
0.5.47
0.5.30
0.5.22
0.5.10
0.5.03,494
0.4.00
0.3.00
0.2.133
0.2.121
0.2.110
0.2.10186
0.2.90
0.2.83
0.2.70
0.2.60
0.2.50
0.2.40
0.2.30
0.2.20
0.2.10
0.2.00
0.1.10
0.1.00
0.0.40
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i eslint-plugin-userscripts

Weekly Downloads

4,698

Version

0.5.6

License

MIT

Unpacked Size

93.2 kB

Total Files

30

Last publish

Collaborators

  • saiansh2525