According to the docs plugins should work if they are npm modules named "eslint-plugin-"
Here's a plugin that follows that pattern. Source is here.
So, we make a new project
md foo
cd foo
npm init
... answer questions ..
npm install --save-dev eslint
npm install --save-dev eslint-plugin-require
echo "define(function(){});" > test.js
echo "{\"rules\":{\"require\": 2}}" > conf.json
node node_modules/eslint/bin/eslint.js -c conf.json --plugin eslint-plugin-require test.js
produces
~/node_modules/eslint/lib/eslint.js:569
throw new Error("Definition for rule '" + key + "' was not
^
Error: Definition for rule 'require' was not found.
change the config to
echo "{\"rules\":{\"eslint-plugin-require\": 2}}" > conf.json
nor
echo "{\"rules\":{\"require-define\": 2}}" > conf.json
nor
echo "{\"rules\":{\"require-require-define\": 2}}" > conf.json
nor
echo "{\"rules\":{\"eslint-plugin-require-define\": 2}}" > conf.json
nor
echo "{\"rules\":{\"eslint-plugin-require-require-define\": 2}}" > conf.json
does not fix it
How do I use locally installed eslint plugins?
It is fairly simple to use local plugins with a local eslint install, just not immediately obvious at first.
1. Install
Nothing different here from what you're already doing.
npm install --save-dev eslint
npm install --save-dev eslint-plugin-require
2. Configure
I'm using a .eslintrc
file in my case, but the same principle should apply if you're passing a custom config file to the CLI. Note the difference in how rules are defined when it's a plugin.
{
"plugins": [
// Tell eslint about the require plugin
"require"
],
"rules": {
// Built-in Rules
"camelcase": 2,
"no-trailing-spaces": 2,
// Require Plugin Rules (note plugin prefix)
"require/require-define": 2,
"require/require-array-syntax": 2,
"require/require-module-prefix": 2
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With