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

Support --resolve-plugins-relative-to option #279

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,19 @@ $ npx eslint-interactive --help
eslint-interactive [file.js] [dir]

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

Examples:
eslint-interactive ./src Lint ./src/ directory
Expand Down
6 changes: 6 additions & 0 deletions src/cli/parse-argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export function parseArgv(argv: string[]): Config {
describe: 'Specify JavaScript file extensions',
})
.nargs('ext', 1)
.option('resolve-plugins-relative-to', {
type: 'string',
describe: 'A folder where plugins should be resolved from, CWD by default',
})
.option('rulesdir', {
type: 'array',
describe: 'Use additional rules from this directory',
Expand Down Expand Up @@ -73,6 +77,7 @@ export function parseArgv(argv: string[]): Config {
// map '.js,.ts' into ['.js', '.ts']
.flatMap((extension) => extension.split(','));
const formatterName = parsedArgv.format;
const resolvePluginsRelativeTo = parsedArgv['resolve-plugins-relative-to'];
return {
patterns,
useEslintrc: parsedArgv.eslintrc,
Expand All @@ -84,5 +89,6 @@ export function parseArgv(argv: string[]): Config {
quiet: parsedArgv.quiet,
cache: parsedArgv.cache,
cacheLocation: parsedArgv['cache-location'],
resolvePluginsRelativeTo,
};
}
2 changes: 2 additions & 0 deletions src/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('Core', () => {
rulePaths: ['rule-path-a', 'rule-path-b'],
extensions: ['.js', '.jsx'],
cwd: '/tmp/cwd',
resolvePluginsRelativeTo: undefined,
});
const core2 = new Core({
patterns: ['pattern-a', 'pattern-b'],
Expand All @@ -100,6 +101,7 @@ describe('Core', () => {
rulePaths: undefined,
extensions: undefined,
cwd: undefined,
resolvePluginsRelativeTo: undefined,
});
});
describe('lint', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type Config = Pick<
| 'cacheLocation'
| 'overrideConfig'
| 'cwd'
| 'resolvePluginsRelativeTo'
> & {
patterns: string[];
formatterName?: string;
Expand All @@ -77,6 +78,7 @@ export const DEFAULT_BASE_CONFIG: Partial<Config> = {
formatterName: 'codeframe',
quiet: false,
rulePaths: undefined,
resolvePluginsRelativeTo: undefined,
};

/**
Expand Down