ESLint rules for jasmine-jquery
You'll first need to install ESLint:
$ npm install eslint --save-dev
Next, install eslint-plugin-jasmine-jquery
:
$ npm install eslint-plugin-jasmine-jquery --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-jasmine-jquery
globally.
Add jasmine-jquery
to the plugins section of your .eslintrc
configuration file, as well as including jasmine
and jquery
environments:
{
"plugins": [
"jasmine-jquery"
],
"env": {
"jquery": true,
"jasmine": true
}
}
Use the default settings by adding it to the extends section of your .eslintrc
:
{
"extends": [
"plugin:jasmine-jquery/recommended"
]
}
The recommended config enables all global shortcut functions by default. (All functions as of jasmine-jquery v2.1.1, see the complete list here.)
To disallow all jasmine-jquery's global shortcut functions, configure this rule:
{
"rules": {
"jasmine-jquery/no-global-shortcuts": 2
}
}
To allow certain functions, pass in an array as the second argument containing the exceptions:
{
"rules": {
"jasmine-jquery/no-global-shortcuts": [2, ["loadFixtures", "setFixtures"]]
}
}
This will throw an error for any global shortcut method except loadFixtures()
and setFixtures()
.
npm install
npm test
Report any issues or submit suggestions for rules on GitHub.
Special thanks to @nathpaiva for contributing to the project.