-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
add-linting.ts
40 lines (35 loc) · 1.15 KB
/
add-linting.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-serial';
import { Linter, lintProjectGenerator } from '@nrwl/linter';
import {
addDependenciesToPackageJson,
joinPathFragments,
Tree,
updateJson,
} from '@nrwl/devkit';
import { extendReactEslintJson, extraEslintDependencies } from '@nrwl/react';
import { NormalizedSchema } from './normalize-options';
export async function addLinting(host: Tree, options: NormalizedSchema) {
if (options.linter === Linter.None) {
return () => {};
}
const lintTask = await lintProjectGenerator(host, {
linter: options.linter,
project: options.e2eProjectName,
tsConfigPaths: [
joinPathFragments(options.e2eProjectRoot, 'tsconfig.app.json'),
],
eslintFilePatterns: [`${options.e2eProjectRoot}/**/*.{ts,tsx,js,jsx}`],
skipFormat: true,
});
updateJson(
host,
joinPathFragments(options.e2eProjectRoot, '.eslintrc.json'),
extendReactEslintJson
);
const installTask = addDependenciesToPackageJson(
host,
extraEslintDependencies.dependencies,
extraEslintDependencies.devDependencies
);
return runTasksInSerial(lintTask, installTask);
}