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

feat(lint): skip build directories by default #26635

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cli/tools/lint/mod.rs
Copy link
Member

@dsherret dsherret Oct 30, 2024

Choose a reason for hiding this comment

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

The problem with doing this is we're not setting users up for success. They should be adding the following to their project:

{
  "exclude": [
    ".next"
  ]
}

...this will give them better performance because now all tooling will ignore that folder (especially the lsp).

If we do this, then we should have something in deno_config that automatically adds this (maybe if the workspace contains certain dependencies, but that would be more work for us to do on startup). Overall though, I don't think ignoring build folders is something that's hard for users to grasp and by doing this we're not teaching users about it. We're also making Deno more complex by having all these little rules where it works one way for this kind of folder and another way for another folder. Can we offer a suggestion for people to exclude these folders instead when they get lint rule errors or deno fmt --check errors in them?

Question: Why do we need this if we already ignore gitignored folders?

Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,25 @@ impl WorkspaceLinter {
}
}

const DEFAULT_IGNORED_DIRS: [&'static str; 5] =
[".config", ".next", ".vite", "dist", "target"];

Choose a reason for hiding this comment

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

maybe .docusaurus too?


fn collect_lint_files(
cli_options: &CliOptions,
files: FilePatterns,
) -> Result<Vec<PathBuf>, AnyError> {
FileCollector::new(|e| {
is_script_ext(e.path)
|| (e.path.extension().is_none() && cli_options.ext_flag().is_some())
!e.path.components().any(|comp| {
let std::path::Component::Normal(comp) = comp else {
return false;
};
if let Some(s) = comp.to_str() {
DEFAULT_IGNORED_DIRS.contains(&s)
} else {
false
}
}) && (is_script_ext(e.path)
|| (e.path.extension().is_none() && cli_options.ext_flag().is_some()))
})
.ignore_git_folder()
.ignore_node_modules()
Expand Down