in packages/just-scripts/src/tasks/eslintTask.ts [27:70]
export function eslintTask(options: EsLintTaskOptions = {}): TaskFunction {
return function eslint() {
const {
files,
configPath,
ignorePath,
fix,
extensions,
noEslintRc,
maxWarnings,
resolvePluginsPath,
cache,
cacheLocation,
timing,
} = options;
const eslintCmd = resolve('eslint/bin/eslint.js');
// Try all possible extensions in the order listed here: https://eslint.org/docs/user-guide/configuring#configuration-file-formats
const eslintConfigPath = configPath || resolveCwd('.eslintrc', { extensions: ['.js', '.cjs', '.yaml', '.yml', '.json'] });
if (eslintCmd && eslintConfigPath && fs.existsSync(eslintConfigPath)) {
const eslintIgnorePath = ignorePath || resolveCwd('.eslintignore');
const eslintArgs = [
eslintCmd,
...(files ? files : ['.']),
...['--ext', extensions ? extensions : '.js,.jsx,.ts,.tsx'],
...(noEslintRc ? '--no-eslintrc' : []),
...(eslintConfigPath ? ['--config', eslintConfigPath] : []),
...(eslintIgnorePath ? ['--ignore-path', eslintIgnorePath] : []),
...(resolvePluginsPath ? ['--resolve-plugins-relative-to', resolvePluginsPath] : []),
...(fix ? ['--fix'] : []),
...(maxWarnings !== undefined ? ['--max-warnings', `${maxWarnings}`] : []),
...(cache ? ['--cache'] : []),
...(cacheLocation ? ['--cache-location', cacheLocation] : []),
'--color',
];
logger.info(encodeArgs(eslintArgs).join(' '));
return spawn(process.execPath, eslintArgs, { stdio: 'inherit', ...(timing && { env: { TIMING: '1' } }) });
} else {
return Promise.resolve();
}
};
}