eslint-plugin-userscripts
v0.5.6
Published
Implements rules for userscripts metadata in eslint
Maintainers
Readme
eslint-plugin-userscripts
Implements rules for userscripts in eslint.
Installation
You'll first need to install ESLint:
npm install eslint --save-devNext, install eslint-plugin-userscripts:
npm install eslint-plugin-userscripts --save-devUsage 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 | ✅ |
