eslint / rewrite

Monorepo for the new version of ESLint
Apache License 2.0
65 stars 4 forks source link

Change Request: Utility function to read gitignore files #44

Closed nzakas closed 2 weeks ago

nzakas commented 3 weeks ago

Which packages would you like to change?

What problem do you want to solve?

In v8, people pass --ignore-path .gitignore in order to use .gitignore patterns with ESLint.

In v9, there is no obvious way to use the .gitignore patterns in an eslint.config.js file, leaving people confused.

What do you think is the correct solution?

  1. Copy the conversion function from migrate-config into compat and export it, making it available to end users.
  2. Export an includeIgnoreFile() function that reads in an ignore file and automatically converts into the format that the config file needs, such that we can do this:
export default [
    await includeIgnoreFile(".gitignore", __dirname),

    // other configs here

];

Participation

Additional comments

No response

mdjermanovic commented 3 weeks ago

Makes sense to me, marked as accepted.

await includeIgnoreFile(".gitignore", __dirname),

I'm wondering if this function needs to be async, as that would make the use of it complicated in CommonJS config files.

nzakas commented 3 weeks ago

I suppose we could do it synchronously.

nzakas commented 3 weeks ago

Working on this.

wong2 commented 1 week ago

How about reading multiple .gitignore files? I have a monorepo where each package has its own .gitignore file.