@nx/react-native
Version:
52 lines (51 loc) • 2.17 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.addLinting = addLinting;
const eslint_1 = require("@nx/eslint");
const devkit_1 = require("@nx/devkit");
const lint_1 = require("@nx/react/src/utils/lint");
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
const flat_config_1 = require("@nx/eslint/src/utils/flat-config");
async function addLinting(host, options) {
if (options.linter === eslint_1.Linter.None) {
return () => { };
}
const tasks = [];
const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
linter: options.linter,
project: options.projectName,
tsConfigPaths: options.tsConfigPaths,
skipFormat: true,
skipPackageJson: options.skipPackageJson,
setParserOptionsProject: options.setParserOptionsProject,
addPlugin: options.addPlugin,
});
tasks.push(lintTask);
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
if ((0, flat_config_1.useFlatConfig)(host)) {
(0, eslint_file_1.addPredefinedConfigToFlatLintConfig)(host, options.projectRoot, 'flat/react');
// Add an empty rules object to users know how to add/override rules
(0, eslint_file_1.addOverrideToLintConfig)(host, options.projectRoot, {
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
rules: {},
});
}
else {
const addExtendsTask = (0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, {
name: 'plugin:@nx/react',
needCompatFixup: true,
});
tasks.push(addExtendsTask);
}
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
'public',
'.cache',
'node_modules',
]);
}
if (!options.skipPackageJson) {
const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
tasks.push(installTask);
}
return (0, devkit_1.runTasksInSerial)(...tasks);
}
;