Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(whitelist-snapshots): option for whitelisting snapshots #288

Merged
merged 15 commits into from Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion docs/rules/no-large-snapshots.md
Expand Up @@ -98,7 +98,7 @@ line 4

## Options

This rule has option for modifying the max number of lines allowed for a
This rule has an option for modifying the max number of lines allowed for a
snapshot:

In an `eslintrc` file:
Expand All @@ -110,3 +110,25 @@ In an `eslintrc` file:
}
...
```

In addition there is an option for whitelisting large snapshot files. Since
`//eslint` comments will be removed when a `.snap` file is updated, this option
provides a way of whitelisting large snapshots. The list of whitelistedSnapshots
is keyed first on the relative filepath of the snapshot file. You can then
provide an array of strings to match the snapshot names against. If you're using
a `.eslintrc.js` file, you can use regular expressions AND strings.

In an `.eslintrc.js` file:

```javascript
...
"rules": {
"jest/no-large-snapshots": ["error",
{
"whitelistedSnapshots": {
"relative/path/to/file.js.snap": ["snapshot name 1", /a big snapshot \d+/]
}
}]
}
...
```
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -40,6 +40,7 @@
"@babel/preset-env": "^7.4.4",
"@commitlint/cli": "^8.0.0",
"@commitlint/config-conventional": "^8.0.0",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"eslint": "^5.1.0",
"eslint-config-prettier": "^4.1.0",
Expand Down