Add a lint for removing .only from tests.
This commit is contained in:
parent
9ebec131b9
commit
6e2528fa31
|
@ -43,9 +43,18 @@
|
|||
"no-useless-escape": "off",
|
||||
"no-undef": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"local-rules/no-budibase-imports": "error",
|
||||
"local-rules/no-budibase-imports": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["**/*.spec.ts"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"extends": ["eslint:recommended"],
|
||||
"rules": {
|
||||
"local-rules/no-test-com": "error",
|
||||
"local-rules/email-domain-example-com": "error"
|
||||
"local-rules/email-domain-example-com": "error",
|
||||
"local-rules/remove-only-from-tests": "warn",
|
||||
"no-console": "warn"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -25,8 +25,7 @@ module.exports = {
|
|||
docs: {
|
||||
description:
|
||||
"disallow the use of 'test.com' in strings and replace it with 'example.com'",
|
||||
category: "Possible Errors",
|
||||
recommended: false,
|
||||
recommended: true,
|
||||
},
|
||||
schema: [], // no options
|
||||
fixable: "code", // Indicates that this rule supports automatic fixing
|
||||
|
@ -58,8 +57,7 @@ module.exports = {
|
|||
docs: {
|
||||
description:
|
||||
"enforce using the example.com domain for generator.email calls",
|
||||
category: "Possible Errors",
|
||||
recommended: false,
|
||||
recommended: true,
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [],
|
||||
|
@ -89,4 +87,31 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
},
|
||||
"remove-only-from-tests": {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
docs: {
|
||||
description: "reminds you to move .only from tests before committing.",
|
||||
recommended: true,
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
create: function (context) {
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === "MemberExpression" &&
|
||||
(node.callee.object.name === "it" ||
|
||||
node.callee.object.name === "describe") &&
|
||||
node.callee.property.name === "only"
|
||||
) {
|
||||
context.report({
|
||||
node: node.callee,
|
||||
message: "Remember to remove .only from tests before committing.",
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue