Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add severity setting to ERBLint rules #1634

Merged
merged 8 commits into from
Nov 23, 2022
Merged

Conversation

mxriverlynn
Copy link
Contributor

@mxriverlynn mxriverlynn commented Nov 23, 2022

Description

This PR adds the ability to set a severity level in our custom ERBLint rules, through the use of the new SeveritySchema linter schema. The goal is to provide a configuration option for linters, allowing us to set the failure severity in a project's erb-lint.yml file. This will help us with cleaning up the deprecated components counter failures in dotcom, by allowing us to re-enable that rules but only warn about the failures, giving us time to clean up the issues in smaller PRs

For this PR, only the DeprecatetdComponentsCounter linter is using the new severity schema. Tests for the DeprecatetdComponentsCounter have been updated to ensure the severity is used as expected.

Integration

Does this change require any updates to code in production?

No change required, as the new setting is optional. Once we are ready, the following configuration in dotcom's erb-lint.yml file needs to be made:

  DeprecatedComponentsCounter:
-   enabled: false
+   enabled: true
+   severity: :info

Setting the Severity

The options for severity in ERBLint come from ERBLint::Utils::SeverityLevels in ERBLint, and include the following:

  • :info
  • :refactor
  • :convention
  • :warning
  • :error
  • :fatal

NOTE: With all other settings defaulted, only the :info severity appears to ignore the failures. setting this to :warning or any other level (including the default / removing the setting) causes it to treat linting issues as failures. This is possible to change by updating the github-lint step to include the following command-line option for ERBLint, however:

--fail-level SEVERITY        Minimum severity for exit with error code

For example: bin/bundle exec erblint --fail-severity :error should allow severity: :warning to still pass the CI step, while allowing :error and :fatal to fail the step. Without further testing, though, it's unknown how the default nil severity would behave.

Proof of Concept in dotcom

Using this branch, I ran two examples of erblint on dotcom. the first was with the severity set to :warning and the second set to :info, using this proof of concept PR in dotcom

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews

@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2022

🦋 Changeset detected

Latest commit: 3f473bc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mxriverlynn mxriverlynn temporarily deployed to review-pr-1634 November 23, 2022 15:13 Inactive
@mxriverlynn mxriverlynn temporarily deployed to github-pages November 23, 2022 15:19 Inactive
@mxriverlynn mxriverlynn marked this pull request as ready for review November 23, 2022 17:01
@mxriverlynn mxriverlynn requested review from a team, camertron and jonrohan November 23, 2022 17:01
Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

What a fantastic idea, thank you @mxriverlynn!!

.changeset/spotty-items-yell.md Outdated Show resolved Hide resolved
@mxriverlynn mxriverlynn merged commit cdc13a1 into main Nov 23, 2022
@mxriverlynn mxriverlynn deleted the mxriverlynn/erblint-warning branch November 23, 2022 18:55
@primer-css primer-css mentioned this pull request Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants