vscode-lintlens icon indicating copy to clipboard operation
vscode-lintlens copied to clipboard

Feature Request: Support custom globs / other files not named ".eslintrc"

Open AlansCodeLog opened this issue 4 years ago • 1 comments

Recently I created a package for my eslint config and split it up into smaller configs. To be able to extend from that commit using an easy name like CONFIG_NAME or @SCOPE/eslint-config/CONFIG_NAME, the file must be in the root of the package and named CONFIG_NAME.js (see Shareable Configs).

This means the extension stops working when working in those files. I thought maybe it might detect a name like config-name.eslintrc.js, then I could at least rename the the file temporarily, but I see that the file starting with .eslintrc is hard coded.

Any chance you could add an option to specify custom globs? I miss the extension so much!

I also see now reading the docs that rules in overrides (which I moved to using) are also not supported, but at least those can be worked around a bit by separating the rules into their own file.

AlansCodeLog avatar Nov 29 '20 03:11 AlansCodeLog

Hi @AlansCodeLog,

Thanks for creating this issue. I don't have that much time to spare these days. I have thought about the need for this feature as well (I would like this for work, but also for eslint shared config maintainers). If I can find the time, I will work on this, but don't hold your breath.

I always welcome PRs if you're interested in helping out. I respond to those much more quickly.

ghmcadams avatar Jun 19 '21 23:06 ghmcadams

This feature has been added in the latest release (6.1.4) in the marketplace. You should be able to use this with any file located anywhere in your workspace(s). Overrides should work as well.

ghmcadams avatar Jan 06 '23 01:01 ghmcadams

@ghmcadams it could well be because what I'm doing is an edge case, but I'm working on an eslint config package and my pre-transpiled config file is src/.eslintrc.ts. Obviously eslint itself doesn't support this extension, but I transpile it to dist/.eslintrc.js and have a .eslintrc.js in the project root that re-exports the config from dist/.eslintrc.js.

This works as far as making sure my src/.eslintrc.ts file gets linted in vscode, but lintlens is not kicking in, despite the activation events matching: image

I thought, well, okay, maybe I can make a symlink of src/.eslintrc.js that points to my .eslintrc.ts, but due to the type info, LintLens doesn't seem to be kicking in there, either. If I open dist/.eslintrc.js, it works, but that's not particularly useful.

I know this is nonstandard, but a non-UI config setting to enable lintlens on unexpected filenames would be nice. Alternatively, perhaps you could detect the types? That is:

import type { Linter } from 'eslint';
// OR:
// import { Linter } from '@typescript-eslint/utils/dist/ts-eslint/Linter';

const reactRuleOverrides: Linter.RulesRecord = {
    'jsx-quotes': ['error', 'prefer-single'],
};

const config: Linter.Config = {
   // ...
};

kinland avatar Sep 29 '23 03:09 kinland

@kinland LintLens does not yet support ts files (based on the assumption that parsing TS files would be challenging). Sorry.

ghmcadams avatar Apr 25 '24 00:04 ghmcadams