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

Issue 173: Added ability to provide Custom Rulesets #172

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

amthorn
Copy link

@amthorn amthorn commented Apr 10, 2021

Custom rulesets is a standard with many linters and provides flexibility for users to create their own linting rules that may apply only to their company or project.

What I changed

  1. Added -r (--ruleset) flag for supplying a custom ruleset js file
  2. Defined the syntax of the ruleset file, which closely matches the "reference.js" file syntax with the single addition of a function key to provide the logic for the rule.
  3. Added custom ruleset key into both the cli and json reporters so users can see when their custom rulesets are being used
  4. Updated README file to document how users can implement this feature with an example command and example ruleset file
  5. Added a mocha test for ensuring that a test custom ruleset accurately reports issues defined within it for a custom dockerfile
  6. Updated help doc with new flag and with example of usage, updated README to reflect this change.

Why I changed it

I work for Cisco Systems that is implementing a dockerfile linter. I am using this repository in that effort and i have to patch this package to be able to supply my own custom rulesets for Cisco Standards. I am also patching this library to be able to provide a "severity" to choose whether or not certain rules cause the exit code to be non-zero. But that is something i can submit if this PR is approved.

How I tested it

I only needed to add a single test to verify rulesets work appropriately by adding a custom test ruleset and a custom negative test dockerfile into the examples folder. Here is the result of "npm run test"

  74 passing (106ms)

--------------------|----------|----------|----------|----------|-------------------|
File                |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
--------------------|----------|----------|----------|----------|-------------------|
All files           |    98.11 |    93.99 |    98.91 |    98.08 |                   |
 lib                |    97.98 |    94.26 |    98.68 |    97.95 |                   |
  apk.js            |      100 |      100 |      100 |      100 |                   |
  apt.js            |      100 |      100 |      100 |      100 |                   |
  checks.js         |       97 |    94.59 |      100 |    96.97 |        95,149,203 |
  command_parser.js |    97.96 |    90.91 |      100 |    97.96 |                85 |
  index.js          |    97.02 |    92.31 |    95.65 |    96.99 |... 24,301,302,304 |
  messages.js       |      100 |      100 |      100 |      100 |                   |
  parser.js         |      100 |    93.62 |      100 |      100 |          59,67,93 |
  reference.js      |      100 |      100 |      100 |      100 |                   |
 lib/reporter       |    98.81 |       90 |      100 |    98.78 |                   |
  cli_reporter.js   |    97.44 |       90 |      100 |    97.44 |                40 |
  json_reporter.js  |      100 |      100 |      100 |      100 |                   |
  reporter.js       |      100 |     87.5 |      100 |      100 |                17 |
--------------------|----------|----------|----------|----------|-------------------|

Thanks:) Let me know if you need anything.

@amthorn amthorn changed the title Added ability to provide Custom Rulesets Issue 173: Added ability to provide Custom Rulesets Apr 10, 2021
@chase-replicated chase-replicated deleted the branch replicatedhq:main December 9, 2021 00:02
@chase-replicated chase-replicated changed the base branch from master to main December 9, 2021 02:32
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.

2 participants