-
Notifications
You must be signed in to change notification settings - Fork 199
Generalize Mocha rules to all testing frameworks #455
Comments
As we are transitioning from Mocha to Jest, and we weren't sure if you would integrate Jest-specific rules, I was considering creating a new package for those, but that would be great too! However, I wonder how much this be made generic. For example, while #453 adds exceptions for Mocha, that would not apply to Jest. Similarly, Mocha recommends against using arrow functions (which has led to a Mocha-aware |
One concerning point about splitting into new packages is the added maintenance overhead. We could...
Perhaps we should have recommended rulesets per test framework with just the test-specific rules? The |
Maybe you could do something similar to what I have set up at work. It's like the recommended rulesets that you mentioned. We have a standard tslint config that we use on all projects. That config is published on our internal npm registry, and the {
"extends": ["@company/tslint-config"]
} That npm package also contains additional rulesets that are specific to certain types of projects. So, for example, if the project was something that would run in the browser, then you'd have a config that looks like this: {
"extends": [
"@company/tslint-config",
"@company/tslint-config/rulesets/browser"
]
} And there's also a ruleset for unit tests that you would use in a {
"extends": [
"../tslint.json",
"@company/tslint-config/rulesets/testing"
]
} Using that same concept, maybe you could split the rules up into categories (react, mocha, chai, jest, etc), and have a config for each category that just specifies a To allow all of that, you'd need a (published) directory structure that's something like this:
The So if you wanted to use the mocha rules (as well as the standard rules), but wanted to control which ones are enabled, you'd have a config like this: {
"extends": [
"tslint-microsoft-contrib", // Allows the base rules to be used
"tslint-microsoft-contrib/mocha" // Allows the mocha rules to be used
]
} But if you wanted to use the mocha rules and have the recommended rules enabled, then you could use a config like this: {
"extends": [
"tslint-microsoft-contrib", // Allows the base rules to be used
"tslint-microsoft-contrib/mocha/recommended" // Uses the recommended mocha rules
]
} Thinking about it a bit more, a config for just specifying the rules directory and another for a recommended ruleset is probably overkill, but I would advocate for splitting up the rules into a directory per category (the root config just has specifies multiple rule directories), because that will make the code base easier to navigate. |
💀 It's time! 💀TSLint is being deprecated; therefore, it and tslint-microsoft-contrib are no longer accepting pull requests for major new changes or features. See palantir/tslint#4534. 😱 If you'd like to see this change implemented, you have two choices:
👋 It was a pleasure open sourcing with you! If you believe this message was posted here in error, please comment so we can re-open the issue! |
These rules should be renamed (maybe replace "mocha" with "test"?) and changed so that any Mocha-specific API names are configurable to allow any test framework. For example, Jest allows
xdescribe
in addition todescribe
.mocha-avoid-only
mocha-no-side-effect-code
mocha-unneeded-done
Following up on #453.
The text was updated successfully, but these errors were encountered: