UNPKG

@nx-plugins/linter

Version:

The Nx Plugin for Linter that contains executors, generators, and utilities to use powerful Eslint capabilities.

35 lines 1.57 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.eslintCommonProject = exports.eslintCommonProjectGenerator = void 0; const tslib_1 = require("tslib"); const devkit_1 = require("@nrwl/devkit"); const linter_1 = require("@nrwl/linter"); const add_linter_1 = require("./lib/add-linter"); const schemaDefaults = { skipFormat: false, linter: linter_1.Linter.EsLint, setParserOptionsProject: false, unitTestRunner: 'vitest', }; function normalizeOptions(tree, options) { const project = (0, devkit_1.getProjects)(tree).get(options.project); if (!project) { devkit_1.logger.error(`Cannot find the ${options.project} project. Please double check the project name.`); throw new Error(); } return Object.assign(Object.assign(Object.assign({}, schemaDefaults), options), { projectRoot: project.root, projectType: project.projectType }); } function eslintCommonProjectGenerator(tree, schema) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const options = normalizeOptions(tree, schema); const addLint = yield (0, add_linter_1.addLinter)(tree, options); if (!schema.skipFormat) { yield (0, devkit_1.formatFiles)(tree); } return addLint; }); } exports.eslintCommonProjectGenerator = eslintCommonProjectGenerator; exports.default = eslintCommonProjectGenerator; exports.eslintCommonProject = (0, devkit_1.convertNxGenerator)(eslintCommonProjectGenerator); //# sourceMappingURL=generator.js.map