UNPKG

@nx/detox

Version:

The Nx Plugin for Detox contains executors and generators for allowing your workspace to use the powerful Detox integration testing capabilities.

42 lines (41 loc) 1.86 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLinting = addLinting; const eslint_1 = require("@nx/eslint"); const devkit_1 = require("@nx/devkit"); const react_1 = require("@nx/react"); 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 === 'none') { return () => { }; } const tasks = []; const lintTask = await (0, eslint_1.lintProjectGenerator)(host, { linter: options.linter, project: options.e2eProjectName, tsConfigPaths: [ (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'tsconfig.app.json'), ], skipFormat: true, 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.e2eProjectRoot, 'flat/react'); // Add an empty rules object to users know how to add/override rules (0, eslint_file_1.addOverrideToLintConfig)(host, options.e2eProjectRoot, { files: ['*.ts', '*.tsx', '*.js', '*.jsx'], rules: {}, }); } else { const addExtendsTask = (0, eslint_file_1.addExtendsToLintConfig)(host, options.e2eProjectRoot, { name: 'plugin:@nx/react', needCompatFixup: true }); tasks.push(addExtendsTask); } } const installTask = (0, devkit_1.addDependenciesToPackageJson)(host, react_1.extraEslintDependencies.dependencies, react_1.extraEslintDependencies.devDependencies); tasks.push(installTask); return (0, devkit_1.runTasksInSerial)(...tasks); }