Super-linter: Use repos default linter configuration instead of Super-Linter defined one

Created on 17 Sep 2020  路  12Comments  路  Source: github/super-linter

Today, Super-Linter offers two ways to use linters configuration :

  • Send the name of a configuration file using env variables LINTER_RULES_PATH and _LINTERNAME_ _CONFIG_FILE
  • Use Super-Linter default configuration

In my opinion, there is a missing third option:

  • use repository configuration, meaning do not send the path to a config file to the linter CLI, but let it find it itself

We could trigger that if _LINTERNAME_ _CONFIG_FILE was set with value DEFAULT
This would also solve the casse where linter config is defined in package.json (that Super-Linter can not access today)

In the code, it would do something like for example :

if GROOVY_CONFIG_FILE === "DEFAULT"
    call npm-groovy-lint 
else if GROOVY_CONFIG_FILE === null
    call npm-groovy-lint -c  "$LINTER_RULES_PATH/$DEFAULT_GROOVY_CONFIG_FILE" // = TEMPLATE/.groovylintrc.json
else 
    call npm-groovy-lint -c "$LINTER_RULES_PATH/$GROOVY_CONFIG_FILE" 
enhancement

Most helpful comment

Today, Super-Linter offers two ways to use linters configuration :

  • Send the name of a configuration file using env variables LINTER_RULES_PATH and _LINTERNAME_ _CONFIG_FILE
  • Use Super-Linter default configuration

In my opinion, there is a missing third option:

  • use repository configuration, meaning do not send the path to a config file to the linter CLI, but let it find it itself

We could trigger that if _LINTERNAME_ _CONFIG_FILE was set with value DEFAULT
This would also solve the casse where linter config is defined in package.json (that Super-Linter can not access today)

In the code, it would do something like for example :

if GROOVY_CONFIG_FILE === "DEFAULT"
    call npm-groovy-lint 
else if GROOVY_CONFIG_FILE === null
    call npm-groovy-lint -c  "$LINTER_RULES_PATH/$DEFAULT_GROOVY_CONFIG_FILE" // = TEMPLATE/.groovylintrc.json
else 
    call npm-groovy-lint -c "$LINTER_RULES_PATH/$GROOVY_CONFIG_FILE" 

I think this is a good idea too. This would also improve the user experience for folks who are migrating over to super-linter from repos where they are running linters individually, such as stylelint, and are used to the cosmiconfig functionality that is built into stylelint to locate and load the config file by default.

All 12 comments

So something like .clang-format is read by default and then applies the defaults from here?

Today, Super-Linter offers two ways to use linters configuration :

  • Send the name of a configuration file using env variables LINTER_RULES_PATH and _LINTERNAME_ _CONFIG_FILE
  • Use Super-Linter default configuration

In my opinion, there is a missing third option:

  • use repository configuration, meaning do not send the path to a config file to the linter CLI, but let it find it itself

We could trigger that if _LINTERNAME_ _CONFIG_FILE was set with value DEFAULT
This would also solve the casse where linter config is defined in package.json (that Super-Linter can not access today)

In the code, it would do something like for example :

if GROOVY_CONFIG_FILE === "DEFAULT"
    call npm-groovy-lint 
else if GROOVY_CONFIG_FILE === null
    call npm-groovy-lint -c  "$LINTER_RULES_PATH/$DEFAULT_GROOVY_CONFIG_FILE" // = TEMPLATE/.groovylintrc.json
else 
    call npm-groovy-lint -c "$LINTER_RULES_PATH/$GROOVY_CONFIG_FILE" 

I think this is a good idea too. This would also improve the user experience for folks who are migrating over to super-linter from repos where they are running linters individually, such as stylelint, and are used to the cosmiconfig functionality that is built into stylelint to locate and load the config file by default.

The global idea is a new value meaning "i don't want to send a config file as parameter to the linter CLI, i want this CLI to load its config the way it is programmed to"

Examples:

  • eslint will look for a .eslintrc.json file, if not found it will look for a property eslint in package.json, etc ...
  • some linter will look for a .clang.format file at the root of the folder

We need to be able to use our repository config files without having to specify a file path to Super-Linter :)

@admiralAwkbar i think i can do it ... would such PR be interesting to you ? 馃槆

I'd be glad to help if I can get some spare cycles I've been slammed lately

Just FYI this is the default behavior for lintr

Implemented in my super-linter POC in python.... but there is a long way for it to be in production ^^

https://github.com/github/super-linter/pull/745

@nvuillam very cool 馃槂 this functionality will also be an elegant solution to #685

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

Production-ready on hard-fork Mega-Linter , just use value LINTER_DEFAULT

Example doc: https://nvuillam.github.io/mega-linter/descriptors/javascript_eslint/

Won't code it here in bash, obviously 馃槥

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 馃 label or comment on the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bbaassssiiee picture bbaassssiiee  路  5Comments

jimsmith picture jimsmith  路  5Comments

brunomartinspro picture brunomartinspro  路  4Comments

thehesiod picture thehesiod  路  4Comments

dshevtsov picture dshevtsov  路  4Comments