Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

New: Control of minimumSeverity #723

Closed
wants to merge 6 commits into from

Conversation

stramel
Copy link
Contributor

@stramel stramel commented May 9, 2017

  • CHANGELOG.md has been updated

I really think it would be good to add a way to differentiate erroring and logging.

Took a shot at allowing control over minimumSeverity. Will replace #709 to fix #699.

@FredKSchott @rictic PTAL :)

src/lint/lint.ts Outdated
@@ -45,10 +45,9 @@ export async function lint(options: Options, config: ProjectConfig) {
const rules = lintLib.registry.getRules(ruleCodes || lintOptions.rules);
const filter = new WarningFilter({
warningCodesToIgnore: new Set(lintOptions.ignoreWarnings || []),
minimumSeverity: Severity.WARNING
minimumSeverity: options.minSeverity || lintOptions.minSeverity || Severity.WARNING,
Copy link
Contributor Author

@stramel stramel May 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would still need to add minSeverity to the polymer-project-config lint section.

Side Note: It seems that trailing comma is mixed in this repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't compile because project config doesn't have minSeverity. Options:

  • don't include the reference
  • reference it using a string literal lintOptions['minSeverity']

In either case we should have a TODO here to add it to project config

CHANGELOG.md Outdated
@@ -2,6 +2,7 @@

## Unreleased

- **Updated `lint` Command**: `polymer lint` now has finer control over what is output and causes the command to fail.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be more explicit here. Mention the new flag and how to use it.

src/lint/lint.ts Outdated
@@ -45,10 +45,9 @@ export async function lint(options: Options, config: ProjectConfig) {
const rules = lintLib.registry.getRules(ruleCodes || lintOptions.rules);
const filter = new WarningFilter({
warningCodesToIgnore: new Set(lintOptions.ignoreWarnings || []),
minimumSeverity: Severity.WARNING
minimumSeverity: options.minSeverity || lintOptions.minSeverity || Severity.WARNING,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't compile because project config doesn't have minSeverity. Options:

  • don't include the reference
  • reference it using a string literal lintOptions['minSeverity']

In either case we should have a TODO here to add it to project config

src/lint/lint.ts Outdated
@@ -45,10 +45,9 @@ export async function lint(options: Options, config: ProjectConfig) {
const rules = lintLib.registry.getRules(ruleCodes || lintOptions.rules);
const filter = new WarningFilter({
warningCodesToIgnore: new Set(lintOptions.ignoreWarnings || []),
minimumSeverity: Severity.WARNING
minimumSeverity: options.minSeverity || lintOptions.minSeverity || Severity.WARNING,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, warning severity should really be a string enum rather than the numeric enum I used -.-

I guess there's still time for a breaking change there if we're very quick.

In any case, for now, you'll need to convert the string to the enum value, something like:

function severityStringToValue(maybeSeverity: string): Severity|undefined {
  maybeSeverity = maybeSeverity.trim().toLowerCase();
  switch (maybeSeverity) {
    case 'error': return Severity.ERROR;
    case 'warning': return Severity.WARNING;
    case 'info': return Severity.INFO;
    default: return undefined;
  }
}

Then check for undefined and throw a useful error in before constructing the WarningFilter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you if you would like to switch it or I can take a stab at it.

Also, it seems the analyzer has an inverse of this Severity to String. Maybe it would make sense to expose those in the Warning model so this doesn't get duplicated somewhere else? Just a thought.

I will add this for now.

@stramel
Copy link
Contributor Author

stramel commented May 10, 2017

There is a bit of conversation going on in Polymer/polymer-project-config#20 in case anyone wants to follow.

@FredKSchott
Copy link
Contributor

Lets keep the discussion in Polymer/polymer-project-config#20 since it's already started there. Closing this PR for now, to be re-opened based on what we decide in Polymer/polymer-project-config#20

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants