Custom ESLint rules for Vanta. The TypeScript rules assume the existence of certain primitives, like the Maybe
type, and may not be useful to codebases other than Vanta's. The GraphQL rules
enforce various invariants described in our GraphQL style guide.
The public version of our GraphQL style guide can be found here.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-vanta
:
$ npm install eslint-plugin-vanta --save-dev
Add vanta
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": ["vanta"]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"vanta/rule-name": 2
}
}
- Rule definitions live in
/lib/rules/<rule-name>.ts
- Tests live in
/tests/lib/rules/<rule-name>.test.ts
- Documentation lives in
/docs/rules/<rule-name>.md
Hot tips:
- For an example GraphQL schema rule, see mutations-return-payload
- For an example TypeScript rule, see prefer-maybe
- Use https://astexplorer.net/ to explore a TypeScript or GraphQL AST so you don't have to guess which type you're dealing with!
- See also https://eslint.org/docs/developer-guide/selectors to understand ESLint selectors
- Run
npm run build-and-test
to test your rules