UNPKG

@nativescript/nx

Version:

NativeScript Plugin for Nx

43 lines 2.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLinting = addLinting; const tslib_1 = require("tslib"); const devkit_1 = require("@nx/devkit"); const flat_config_1 = require("@nx/eslint/src/utils/flat-config"); const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file"); function addLinting(host, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { if (options.linter !== 'eslint') { return () => { /* empty */ }; } const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', devkit_1.NX_VERSION); const lintTask = yield lintProjectGenerator(host, { linter: options.linter, project: options.name, tsConfigPaths: [(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json')], eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,spec.ts}`], skipFormat: true, }); const eslintFile = (0, eslint_file_1.findEslintFile)(host, options.projectRoot); const eslintFilePath = (0, devkit_1.joinPathFragments)(options.projectRoot, eslintFile); if ((0, flat_config_1.useFlatConfig)(host)) { /** * TODO: augment flat config once the plugins are ready with the flat */ } else { (0, devkit_1.updateJson)(host, eslintFilePath, (json) => { var _a, _b; const ignorePatterns = [...((_a = json.ignorePatterns) !== null && _a !== void 0 ? _a : ['!**/*']), 'references.d.ts', 'node_modules/**/*', 'hooks/**/*', 'platforms/**/*']; const extendsVal = [...((_b = json.extends) !== null && _b !== void 0 ? _b : [])]; delete json.ignorePatterns; delete json.extends; return Object.assign({ extends: extendsVal, ignorePatterns }, json); }); } return (0, devkit_1.runTasksInSerial)(lintTask); }); } //# sourceMappingURL=add-linting.js.map