Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Mismatched configuration for a linter should fail the lint run (fix #405)#412

Merged
Atry merged 5 commits into
hhvm:mainfrom
Atry:405
Nov 30, 2021
Merged

Mismatched configuration for a linter should fail the lint run (fix #405)#412
Atry merged 5 commits into
hhvm:mainfrom
Atry:405

Conversation

@Atry

@Atry Atry commented Nov 26, 2021

Copy link
Copy Markdown
Contributor

I added a cwd parameter to LinterCLI for the test purpose so we could test it without actual chdir, in case of interfering other tests.

@Atry Atry requested a review from lexidor November 26, 2021 19:16
@Atry Atry marked this pull request as draft November 26, 2021 19:28
@Atry Atry marked this pull request as ready for review November 26, 2021 19:29
@Atry Atry force-pushed the 405 branch 6 times, most recently from 9cd7bd1 to 17e9f24 Compare November 26, 2021 21:08

@lexidor lexidor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh wow a missing throw, I am going to make a linter for this. I believe this already exists for Javascript. Don't use new for side effects

Comment thread src/__Private/LinterCLI.hack Outdated

if (C\is_empty($roots)) {
$config = LintRunConfig::getForPath(\getcwd());
$config = LintRunConfig::getForPath($this->cwd ?? \getcwd());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do you need this rather than specifying a root?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is a warning if I specify the root

Warning: PATH arguments contain a hhast-lint.json

@fredemmott fredemmott left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • It shouldn't be called cwd, as it's very decoupled from the working directory. Given all it's used for is specifying the path to the config file, it'd be clearer to take an optional full path to the configuration file (using LintRunConfig::getFromConfigFile())
  • I don't see a need for this to be a special-cased thing, especially in a CLI class that can already have optionals; what do you think about adding a --config-file= argument instead, and making the whole thing more flexible?
  • Let's also change that warning to include ", but $ABSOLUTE_PATH_TO_ACTIVE_CONFIG will be used"

@Atry Atry marked this pull request as draft November 30, 2021 20:05
@Atry Atry force-pushed the 405 branch 3 times, most recently from 9ef40de to 67e0616 Compare November 30, 2021 21:41
@Atry Atry marked this pull request as ready for review November 30, 2021 22:18
@Atry

Atry commented Nov 30, 2021

Copy link
Copy Markdown
Contributor Author

The --config-file flag is added

@Atry Atry requested a review from fredemmott November 30, 2021 22:19
Comment thread tests/LinterConfigTest.hack Outdated
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants