-
Notifications
You must be signed in to change notification settings - Fork 889
Conversation
* For example: ``` "rules": { "align": { "mode": "off", "options": ["parameters", "arguments"] } } ``` * See it run: `npm run compile && node ./lib/tslint-cli.js src/ruleLoader.ts` * Support mode: "warn", update proseFormatter to deal with warnings
…ixes) * Refactor formatters to reduce duplication * Add isWarning() to test Rule classes - these seem to be compiled from somewhere? Couldn't find source ts. * Started work on getting all tests to pass
Thanks for your interest in palantir/tslint, @olore! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
@@ -12,6 +12,7 @@ var Rule = (function (_super) { | |||
Rule.prototype.apply = function (sourceFile) { | |||
return this.applyWithWalker(new NoFailWalker(sourceFile, this.getOptions())); | |||
}; | |||
Rule.prototype.isWarning = function() { return false; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't figure out where these files were generated from, so I just modified by hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the .ts files were checked in
@@ -45,19 +43,11 @@ describe("Stylish Formatter", () => { | |||
|
|||
const maxPositionTuple = `${maxPositionObj.line + 1}:${maxPositionObj.character + 1}`; | |||
|
|||
const expectedResult = colors.enabled ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test was never run with colors disabled, so I removed the ternary
src/language/rule/abstractRule.ts
Outdated
@@ -29,6 +30,8 @@ export abstract class AbstractRule implements IRule { | |||
|
|||
if (Array.isArray(value) && value.length > 1) { | |||
ruleArguments = value.slice(1); | |||
} else if (value.options) { | |||
ruleArguments = arrayify(value.options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow the tslint.json maintainer to no be forced to put a single value in an array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to use separate array for warnings instead of extending RuleFailure
interface with mode
property? (or level
more speaking, however differs from config field)
In any case formatters should be updated, and I think it is easier to add field check, than comparing 2 arrays if they want group errors by file.
BTW may be it make sens to use level
instead of mode
since it is more widely used in such context?
Extend RuleViolation to include a RuleLevel (ERROR|WARN)
@IllusionMH That makes a lot of sense to me. In fact it's where I started, but because of the huge number of changes, I backed it out. What do you think about moving RuleFailure to RuleViolation? A RuleViolation will have a level that can either be WARNING or ERROR. To me, it's a cleaner solution, I was just apprehensive about making so many changes (100+ files). |
I think there is no need for 100+ files change (although this level of changes probably will be required for rule test configuration files). Probably I incorrectly used
which lead to incomprehension. My rough estimation of changes to add File File File File Update formatters and utils tests (14 files) and At this moment I'm not 100% sure if this is the best solution, since |
Thanks @IllusionMH ! We were on the same page. I ended up with so many changes because I couldn't get past the name RuleFailure, so I renamed it RuleViolation. Each Violation can either be an ERROR or a WARNING (aka a RuleLevel). Hopefully this makes sense. Appreciate the feedback and suggestions. |
After reading through some of the PRs and Issues, I think I underestimated how many custom rules are out there, and changing RuleFailure to RuleViolation will affect all of them :( I will change back to RuleFailure Update: 31 files changed instead of 115 👍 |
@nchen63 All requested changes have been made. Three outstanding items -
|
the tests fail on my machine too. It's failing because honestly, you should get rid of the some examples:
this might get complicated later on with inheriting default severity. For example, does a new default severity just override the old default or does it wipe out all of the custom levels? Do we need a "default" severity? |
Thanks for the insight. That shouldn't be a problem. I was apprehensive about killing the legacy stuff, but it definitely felt like extra baggage. Now you feel my pain with trying to do a default severity 😄 |
I don't think you should necessarily kill the legacy stuff. You should actually leave it mostly unchanged since they test order of inheritance more than anything else. |
I believe I have addressed all items. Thanks for your input. |
ping @nchen63 -- what are the remaining actions here and what is the feature rollout plan? |
…fig-options # Conflicts: # CHANGELOG.md
@olore nice work we are now on our way to 5.0! |
Has this been released? |
@tugberkugurlu not in a regular release, but you can try it in this prerelease: https://github.com/palantir/tslint/releases/tag/5.0.0-dev.0 |
We're working on the TSLint integration in WebStorm. Can you please point me to a comment or code describing the difference between |
|
palantir#1738 added support rule severity but forgot to update the example for the stylish formatter.
#1738 added support rule severity but forgot to update the example for the stylish formatter.
PR checklist
What changes did you make?
Allow a "mode" for each rule in tslint.json. Anything other than "off" and the rule will run, a value of "warn" will exit with a return code of 0
Is there anything you'd like reviewers to focus on?