Skip to content

Commit 1d8c3d2

Browse files
authored
Merge pull request #279 from sisisin/feat/support-plugin-option
feat: support --resolve-plugins-relative-to
2 parents 80894b0 + efdbfd0 commit 1d8c3d2

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

README.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,19 @@ $ npx eslint-interactive --help
6666
eslint-interactive [file.js] [dir]
6767

6868
Options:
69-
--help Show help [boolean]
70-
--version Show version number [boolean]
71-
--eslintrc Enable use of configuration from .eslintrc.* [boolean] [default: true]
72-
-c, --config Use this configuration, overriding .eslintrc.* config options if present [string]
73-
--ext Specify JavaScript file extensions [array]
74-
--rulesdir Use additional rules from this directory [array]
75-
--ignore-path Specify path of ignore file [string]
76-
--format Specify the format to be used for the `Display problem messages` action [string] [default: "codeframe"]
77-
--quiet Report errors only [boolean] [default: false]
78-
--cache Only check changed files [boolean] [default: true]
79-
--cache-location Path to the cache file or directory [string] [default: "node_modules/.cache/eslint-interactive/10.5.0/.eslintcache"]
69+
--help Show help [boolean]
70+
--version Show version number [boolean]
71+
--eslintrc Enable use of configuration from .eslintrc.* [boolean] [default: true]
72+
-c, --config Use this configuration, overriding .eslintrc.* config options if present [string]
73+
--resolve-plugins-relative-to A folder where plugins should be resolved from, CWD by default [string]
74+
--ext Specify JavaScript file extensions [array]
75+
--rulesdir Use additional rules from this directory [array]
76+
--ignore-path Specify path of ignore file [string]
77+
--format Specify the format to be used for the `Display problem messages` action [string] [default: "codeframe"]
78+
--quiet Report errors only [boolean] [default: false]
79+
--cache Only check changed files [boolean] [default: true]
80+
--cache-location Path to the cache file or directory
81+
[string] [default: "node_modules/.cache/eslint-interactive/10.6.0/.eslintcache"]
8082

8183
Examples:
8284
eslint-interactive ./src Lint ./src/ directory

src/cli/parse-argv.ts

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export function parseArgv(argv: string[]): Config {
2626
describe: 'Specify JavaScript file extensions',
2727
})
2828
.nargs('ext', 1)
29+
.option('resolve-plugins-relative-to', {
30+
type: 'string',
31+
describe: 'A folder where plugins should be resolved from, CWD by default',
32+
})
2933
.option('rulesdir', {
3034
type: 'array',
3135
describe: 'Use additional rules from this directory',
@@ -73,6 +77,7 @@ export function parseArgv(argv: string[]): Config {
7377
// map '.js,.ts' into ['.js', '.ts']
7478
.flatMap((extension) => extension.split(','));
7579
const formatterName = parsedArgv.format;
80+
const resolvePluginsRelativeTo = parsedArgv['resolve-plugins-relative-to'];
7681
return {
7782
patterns,
7883
useEslintrc: parsedArgv.eslintrc,
@@ -84,5 +89,6 @@ export function parseArgv(argv: string[]): Config {
8489
quiet: parsedArgv.quiet,
8590
cache: parsedArgv.cache,
8691
cacheLocation: parsedArgv['cache-location'],
92+
resolvePluginsRelativeTo,
8793
};
8894
}

src/core.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ describe('Core', () => {
8989
rulePaths: ['rule-path-a', 'rule-path-b'],
9090
extensions: ['.js', '.jsx'],
9191
cwd: '/tmp/cwd',
92+
resolvePluginsRelativeTo: undefined,
9293
});
9394
const core2 = new Core({
9495
patterns: ['pattern-a', 'pattern-b'],
@@ -100,6 +101,7 @@ describe('Core', () => {
100101
rulePaths: undefined,
101102
extensions: undefined,
102103
cwd: undefined,
104+
resolvePluginsRelativeTo: undefined,
103105
});
104106
});
105107
describe('lint', () => {

src/core.ts

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type Config = Pick<
6161
| 'cacheLocation'
6262
| 'overrideConfig'
6363
| 'cwd'
64+
| 'resolvePluginsRelativeTo'
6465
> & {
6566
patterns: string[];
6667
formatterName?: string;
@@ -77,6 +78,7 @@ export const DEFAULT_BASE_CONFIG: Partial<Config> = {
7778
formatterName: 'codeframe',
7879
quiet: false,
7980
rulePaths: undefined,
81+
resolvePluginsRelativeTo: undefined,
8082
};
8183

8284
/**

0 commit comments

Comments
 (0)