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

Add ability to lint file name and path #1140

Open
kellyselden opened this issue Apr 7, 2023 · 1 comment
Open

Add ability to lint file name and path #1140

kellyselden opened this issue Apr 7, 2023 · 1 comment
Labels
Status: Proposal Request for comments

Comments

@kellyselden
Copy link
Contributor

This is a feature I've used in ESLint before, and is something I'm looking to use in textlint. For example in ESLint, here is how it is used:

  valid: [
    {
      code: '{ "repository": { "directory": "foo/bar" } }',
      filename: 'foo/bar/package.json'
    }
  ]

https://github.com/kellyselden/eslint-plugin-json-files/blob/v2.1.0/tests/lib/rules/ensure-repository-directory.js#L11

  create(context) {
    let filename = context.getFilename();
  }

https://github.com/kellyselden/eslint-plugin-json-files/blob/v2.1.0/lib/rules/ensure-repository-directory.js#L15

You can generate failures based on the filename if you want.

It would be nice to have this in textlint. The use case would be to write a rule that verifies files are in a correct spot. For example, I have a rule that verifies a CODEOWNERS file is not malformed, but I also want the rule to verify all the files are in an expected spot in a monorepo.

@azu azu added the Status: Proposal Request for comments label Apr 8, 2023
@azu
Copy link
Member

azu commented Apr 8, 2023

https://github.com/textlint/textlint/tree/master/packages/textlint-tester
inputPath is similar option, but it require actual file path(tester load the file path as actual file).
Presumably you are asking for a pseudo file path to be specified.
Is is not implemented yet.

Probably, we can implement this by passing filePath option to here. This filePath is pseudo.

return kernel.lintText(text, {
ext,
...textlintKernelDescriptor.toKernelOptions()
});
},

// file path
filePath?: string;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Proposal Request for comments
Projects
None yet
Development

No branches or pull requests

2 participants