UNPKG

@nx/gatsby

Version:

Gatsby Plugin for Nx

41 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addLinting = void 0; const tslib_1 = require("tslib"); const devkit_1 = require("@nx/devkit"); const linter_1 = require("@nx/linter"); const react_1 = require("@nx/react"); const run_tasks_in_serial_1 = require("@nx/workspace/src/utilities/run-tasks-in-serial"); function addLinting(host, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const lintTask = yield (0, linter_1.lintProjectGenerator)(host, { linter: linter_1.Linter.EsLint, project: options.projectName, tsConfigPaths: [ (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'), ], eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`], skipFormat: true, }); const reactEslintJson = (0, react_1.createReactEslintJson)(options.projectRoot, options.setParserOptionsProject); (0, devkit_1.updateJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, '.eslintrc.json'), (json) => { json = reactEslintJson; json.ignorePatterns = ['!**/*', 'public', '.cache']; for (const override of json.overrides) { if (!override.files || override.files.length !== 2) { continue; } if (!(override.files.includes('*.ts') && override.files.includes('*.tsx'))) { continue; } override.rules = override.rules || {}; override.rules['@typescript-eslint/camelcase'] = 'off'; } return json; }); const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, react_1.extraEslintDependencies.dependencies, react_1.extraEslintDependencies.devDependencies); return (0, run_tasks_in_serial_1.runTasksInSerial)(lintTask, installTask); }); } exports.addLinting = addLinting; //# sourceMappingURL=add-linting.js.map