Custom Gusto ESLint rules.
Install ESLint:
$ npm install --save-dev eslint
Install the Gusto plugin:
$ npm install --save-dev Gusto/eslint-plugin-gusto
Add plugins
section to your .eslintrc
and add the Gusto plugin:
{
"plugins": ["gusto"]
}
Then enable all of the rules that you would like to use.
- Write your rule in
src/
. - Add the rule to
src/index.js
. - Write a test in
test/lib/rules/
. - Build files to
lib/
usingyarn build
. - Run test with
yarn test
- Run lint with
yarn lint
- Create a PR
- Get a review
- Squash & Merge
- Publish (instructions [TODO])
- Write publish instructions in
README.md
- Can
$image_path
rule be removed from ZP? - Re-write rules in non-deprecated format (note at top of https://eslint.org/docs/developer-guide/working-with-rules)
- Move detailed rule descriptions into their own
.md
files and link from the mainREADME.md
- Figure out why rule namespace is @gusto/gusto/...
- Create a CI workflow to run tests (and auto-publish?)
With certain exceptions, most properties of the global Payroll
object (Models
, Views
,
Collections
, etc.) should be converted to use CommonJS imports/exports.
The following patterns are considered warnings:
/*eslint global-payroll-properties: 2*/
const company = new Payroll.Models.Company();
The following patterns are not considered warnings:
/*eslint global-payroll-properties: 2*/
import Company from '../models/company';
const company = new Company();
/*eslint global-payroll-properties: [2, {"exceptions": ["Store"]}]*/
const company = Payroll.Store.company;
"global-payroll-properties": [2, {"exceptions": <array of strings>}]
Array of property names that are permitted to be used on the global Payroll
object.
This rule allows you to configure a blacklist of strings that should not be used in your code.
The following patterns are considered warnings:
/*eslint string-literal-blacklist: [2, "$image_path("]*/
const img = <img src="$image_path(some/where/image.png)" />;
const img = <img src={`$image_path(some/where/image.png)`} />;
const src = '$image_path(some/where/image.png)';
const src = `$image_path(some/where/image.png)`;
The following patterns are not considered warnings:
/*eslint string-literal-blacklist: [2, "$image_path("]*/
const img = <img src="some/where/image.png" />;
const img = <img src={`some/where/image.png`} />;
const src = 'some/where/image.png';
const src = `some/where/image.png`;
This rule needs set of strings to blacklist, listed after the warning level:
"string-literal-blacklist": [2, <array of strings>]