-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include meta.docs.url for all rules
- Loading branch information
Showing
12 changed files
with
345 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
'use strict'; | ||
|
||
module.exports = context => { | ||
if (context.getFilename().endsWith('.snap')) { | ||
const lineLimit = (context.options[0] && context.options[0].maxSize) || 50; | ||
module.exports = { | ||
meta: { | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-large-snapshots.md', | ||
}, | ||
}, | ||
create(context) { | ||
if (context.getFilename().endsWith('.snap')) { | ||
const lineLimit = | ||
(context.options[0] && context.options[0].maxSize) || 50; | ||
|
||
return { | ||
ExpressionStatement: node => { | ||
const startLine = node.loc.start.line; | ||
const endLine = node.loc.end.line; | ||
const lineCount = endLine - startLine; | ||
return { | ||
ExpressionStatement: node => { | ||
const startLine = node.loc.start.line; | ||
const endLine = node.loc.end.line; | ||
const lineCount = endLine - startLine; | ||
|
||
if (lineCount > lineLimit) { | ||
context.report({ | ||
message: | ||
'Expected Jest snapshot to be smaller than {{ lineLimit }} lines but was {{ lineCount }} lines long', | ||
data: { lineLimit, lineCount }, | ||
node, | ||
}); | ||
} | ||
}, | ||
}; | ||
} | ||
if (lineCount > lineLimit) { | ||
context.report({ | ||
message: | ||
'Expected Jest snapshot to be smaller than {{ lineLimit }} lines but was {{ lineCount }} lines long', | ||
data: { lineLimit, lineCount }, | ||
node, | ||
}); | ||
} | ||
}, | ||
}; | ||
} | ||
|
||
return {}; | ||
return {}; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.