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

docs: specifying files with arbitrary or no extension #18539

Merged
merged 5 commits into from
Jun 4, 2024
Merged

Conversation

fasttime
Copy link
Member

@fasttime fasttime commented Jun 2, 2024

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[X] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

Fixes #18475

What changes did you make? (Give an overview)

Added two sections to the configuration files docs explaining how to lint files with a given extension or without extension.
Clarified other parts of the documentation about files and ignores.

Is there anything you'd like reviewers to focus on?

@eslint-github-bot eslint-github-bot bot added the documentation Relates to ESLint's documentation label Jun 2, 2024
Copy link

netlify bot commented Jun 2, 2024

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 319c7af
🔍 Latest deploy log https://app.netlify.com/sites/docs-eslint/deploys/665ecc80c5f3a40008718c82
😎 Deploy Preview https://deploy-preview-18539--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.


#### Specifying files without extension

No simple glob pattern can be used to target only files without extension.
Copy link
Member

Choose a reason for hiding this comment

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

A pattern like **/!(*.*) would match only files without extension I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you're right, that seems to do the job 👍🏻

@aladdin-add
Copy link
Member

ci failing has been fixed in the main branch, can you please rebase it, thanks!

@fasttime
Copy link
Member Author

fasttime commented Jun 3, 2024

@aladdin-add I rebased to main but the browser test is still failing: https://github.com/eslint/eslint/actions/runs/9352097110/job/25739399981?pr=18539. Any clues?

@aladdin-add
Copy link
Member

yes, It's not 100% reproducible, I filed a new issue: #18548

@fasttime fasttime marked this pull request as ready for review June 3, 2024 17:11
@fasttime fasttime requested a review from a team as a code owner June 3, 2024 17:11
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Thanks for getting this started. I have some suggestions for clarifying things further.

@@ -79,7 +79,7 @@ Each configuration object contains all of the information ESLint needs to execut
Patterns specified in `files` and `ignores` use [`minimatch`](https://www.npmjs.com/package/minimatch) syntax and are evaluated relative to the location of the `eslint.config.js` file. If using an alternate config file via the `--config` command line option, then all patterns are evaluated relative to the current working directory.
:::

You can use a combination of `files` and `ignores` to determine which files should apply the configuration object and which should not. By default, ESLint matches `**/*.js`, `**/*.cjs`, and `**/*.mjs`. Because config objects that don't specify `files` or `ignores` apply to all files that have been matched by any other configuration object, those config objects apply to any JavaScript files passed to ESLint by default. For example:
You can use a combination of `files` and `ignores` to determine which files should apply the configuration object and which should not. By default, ESLint matches `**/*.js`, `**/*.cjs`, and `**/*.mjs`. Because config objects that don't specify `files` or `ignores` apply to all files that have been matched by any other configuration object, only JavaScript files are linted by default. For example:
Copy link
Member

Choose a reason for hiding this comment

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

That last sentence doesn't seem correct to me. JavaScript linted by default isn't a result of config objects without files or ignores. Maybe this?

Suggested change
You can use a combination of `files` and `ignores` to determine which files should apply the configuration object and which should not. By default, ESLint matches `**/*.js`, `**/*.cjs`, and `**/*.mjs`. Because config objects that don't specify `files` or `ignores` apply to all files that have been matched by any other configuration object, only JavaScript files are linted by default. For example:
You can use a combination of `files` and `ignores` to determine which files should apply the configuration object and which should not. By default, ESLint matches `**/*.js`, `**/*.cjs`, and `**/*.mjs`. so those are always matched unless you explicitly exclude them using `ignores`. Because config objects that don't specify `files` or `ignores` apply to all files that have been matched by any other configuration object, they will apply to all JavaScript files. For example:

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, actually it's a result of the default patterns being what they are and also the fact that config objects without files or ignores apply to all linted files. I will elaborate.

docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
fasttime and others added 2 commits June 4, 2024 09:32
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
Co-authored-by: Nicholas C. Zakas <nicholas@humanwhocodes.com>
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
docs/src/use/configure/configuration-files.md Outdated Show resolved Hide resolved
@fasttime
Copy link
Member Author

fasttime commented Jun 4, 2024

Thanks for the suggestions @nzakas. I did a few changes, please check if it's okay now.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Relates to ESLint's documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Docs: Unexpected file matching behavior when using ignores without files
4 participants