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

Load package.json on init-linter #4363

Merged
merged 36 commits into from
Nov 13, 2023
Merged

Load package.json on init-linter #4363

merged 36 commits into from
Nov 13, 2023

Conversation

vdiez
Copy link
Contributor

@vdiez vdiez commented Nov 7, 2023

No description provided.

@vdiez vdiez self-assigned this Nov 8, 2023
packages/jsts/tests/analysis/analyzer.test.ts Outdated Show resolved Hide resolved
packages/jsts/tests/analysis/analyzer.test.ts Outdated Show resolved Hide resolved
packages/jsts/tests/analysis/analyzer.test.ts Outdated Show resolved Hide resolved
packages/jsts/tests/analysis/analyzer.test.ts Outdated Show resolved Hide resolved
packages/jsts/tests/analysis/analyzer.test.ts Outdated Show resolved Hide resolved
always ignore .scannerwork folder
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM! Great job!

}

async walkDirectory(dir: string, ignoredPatterns: Minimatch[]) {
const files = await fs.readdir(dir, { withFileTypes: true });
Copy link
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 to await the result here, if function is async?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because otherwise files is a promise and would not be able to iterate

continue; // is ignored pattern
}
if (file.isDirectory()) {
await this.walkDirectory(filename, ignoredPatterns);
Copy link
Contributor

Choose a reason for hiding this comment

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

why await?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not needed but to keep order of execution

protected List<String> getExcludedPaths() {
var configuration = this.context.config();
var excludedPatterns = Arrays.asList(JavaScriptPlugin.EXCLUSIONS_DEFAULT_VALUE);
var jsExcludedPatterns = configuration.get(JavaScriptPlugin.JS_EXCLUSIONS_KEY).isPresent()
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to do this, if you call getStringArray it will return [] if the property is not defined


protected List<String> getExcludedPaths() {
var configuration = this.context.config();
var excludedPatterns = Arrays.asList(JavaScriptPlugin.EXCLUSIONS_DEFAULT_VALUE);
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need this variable

@@ -126,4 +132,18 @@ protected boolean shouldAnalyzeWithProgram(List<InputFile> inputFiles) {
LOG.debug("Will use AnalysisWithProgram");
return true;
}

protected List<String> getExcludedPaths() {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should share this logic with PathAssesor, by creating utility class with static function, otherwise we will forget to keep the two places in sync

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to do this, but had doubts about the how-to

Copy link
Contributor

@saberduck saberduck left a comment

Choose a reason for hiding this comment

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

@vdiez pls see the comment about sharing the exclusion logic

Copy link

@vdiez vdiez merged commit 4057f72 into master Nov 13, 2023
14 checks passed
@vdiez vdiez deleted the load-package-json branch November 13, 2023 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants