diff --git a/packages/angular/cli/commands/deploy-impl.ts b/packages/angular/cli/commands/deploy-impl.ts index a373a5dede25..4572f27d8995 100644 --- a/packages/angular/cli/commands/deploy-impl.ts +++ b/packages/angular/cli/commands/deploy-impl.ts @@ -5,12 +5,11 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command'; +import { ArchitectCommand } from '../models/architect-command'; import { Arguments } from '../models/interface'; import { Schema as DeployCommandSchema } from './deploy'; const BuilderMissing = ` - Cannot find "deploy" target for the specified project. You should add a package that implements deployment capabilities for your diff --git a/packages/angular/cli/commands/lint-impl.ts b/packages/angular/cli/commands/lint-impl.ts index 6edd8556f994..af2df1aaab64 100644 --- a/packages/angular/cli/commands/lint-impl.ts +++ b/packages/angular/cli/commands/lint-impl.ts @@ -5,15 +5,27 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import { ArchitectCommand, ArchitectCommandOptions } from '../models/architect-command'; +import { ArchitectCommand } from '../models/architect-command'; import { Arguments } from '../models/interface'; import { Schema as LintCommandSchema } from './lint'; +const MissingBuilder = ` +Cannot find "lint" target for the specified project. + +You should add a package that implements linting capabilities. + +For example: + ng add @angular-eslint/schematics +`; + export class LintCommand extends ArchitectCommand { - public readonly target = 'lint'; - public readonly multiTarget = true; + readonly target = 'lint'; + readonly multiTarget = true; + readonly missingTargetError = MissingBuilder; - public async run(options: ArchitectCommandOptions & Arguments) { - return this.runArchitectTarget(options); + async initialize(options: LintCommandSchema & Arguments): Promise { + if (!options.help) { + return super.initialize(options); + } } } diff --git a/packages/angular/cli/commands/lint-long.md b/packages/angular/cli/commands/lint-long.md index 480b069f1e2c..1588c8438fff 100644 --- a/packages/angular/cli/commands/lint-long.md +++ b/packages/angular/cli/commands/lint-long.md @@ -1,7 +1,20 @@ -Takes the name of the project, as specified in the `projects` section of the `angular.json` workspace configuration file. -When a project name is not supplied, it will execute for all projects. +The command takes an optional project name, as specified in the `projects` section of the `angular.json` workspace configuration file. +When a project name is not supplied, executes the `lint` builder for the default project. -The default linting tool is [TSLint](https://palantir.github.io/tslint/), and the default configuration is specified in the project's `tslint.json` file. +To use the `ng lint` command, use `ng add` to add a package that implements linting capabilities. Adding the package automatically updates your workspace configuration, adding a lint [CLI builder](guide/cli-builder). +For example: -**Note**: TSLint has been discontinued and support has been deprecated in the Angular CLI. The options shown below are for the deprecated TSLint builder. -To opt-in using the community driven ESLint builder, see [angular-eslint](https://github.com/angular-eslint/angular-eslint#migrating-an-angular-cli-project-from-codelyzer-and-tslint) README. +```json +"projects": { + "my-project": { + ... + "architect": { + ... + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": {} + } + } + } +} + ``` \ No newline at end of file diff --git a/packages/angular/cli/commands/lint.json b/packages/angular/cli/commands/lint.json index eed1cda035c6..c3b283251b6f 100644 --- a/packages/angular/cli/commands/lint.json +++ b/packages/angular/cli/commands/lint.json @@ -4,7 +4,7 @@ "description": "Runs linting tools on Angular app code in a given project folder.", "$longDescription": "./lint-long.md", - "$aliases": [ "l" ], + "$aliases": ["l"], "$scope": "in", "$type": "architect", "$impl": "./lint-impl#LintCommand", @@ -22,15 +22,14 @@ } }, "configuration": { - "description": "The linting configuration to use.", + "description": "One or more named builder configurations as a comma-separated list as specified in the \"configurations\" section of angular.json.\nThe builder uses the named configurations to run the given target.\nFor more information, see https://angular.io/guide/workspace-config#alternate-build-configurations.", "type": "string", "aliases": [ "c" ] } }, - "required": [ - ] + "required": [] }, { "$ref": "./definitions.json#/definitions/base" diff --git a/packages/schematics/angular/application/files/tslint.json.template b/packages/schematics/angular/application/files/tslint.json.template deleted file mode 100644 index b9ce956376d6..000000000000 --- a/packages/schematics/angular/application/files/tslint.json.template +++ /dev/null @@ -1,18 +0,0 @@ -{<% if (!isRootApp) { %> - "extends": "<%= relativePathToWorkspaceRoot %>/tslint.json",<% - } %> - "rules": { - "directive-selector": [ - true, - "attribute", - "<%= utils.camelize(prefix) %>", - "camelCase" - ], - "component-selector": [ - true, - "element", - "<%= utils.dasherize(prefix) %>", - "kebab-case" - ] - } -} diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index 952dc63ae01e..97cc8b66cae4 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -31,7 +31,6 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks'; import { Schema as ComponentOptions } from '../component/schema'; import { Schema as E2eOptions } from '../e2e/schema'; import { NodeDependencyType, addPackageJsonDependency } from '../utility/dependencies'; -import { JSONFile } from '../utility/json-file'; import { latestVersions } from '../utility/latest-versions'; import { applyLintFix } from '../utility/lint-fix'; import { relativePathToWorkspaceRoot } from '../utility/paths'; @@ -68,28 +67,6 @@ function addDependenciesToPackageJson(options: ApplicationOptions) { }; } -/** - * Merges the application tslint.json with the workspace tslint.json - * when the application being created is a root application - * - * @param {Tree} parentHost The root host of the schematic - */ -function mergeWithRootTsLint(parentHost: Tree) { - return (host: Tree) => { - const tsLintPath = '/tslint.json'; - const rulesPath = ['rules']; - if (!host.exists(tsLintPath)) { - return; - } - - const rootTsLintFile = new JSONFile(parentHost, tsLintPath); - const rootRules = rootTsLintFile.get(rulesPath) as {}; - const appRules = new JSONFile(host, tsLintPath).get(rulesPath) as {}; - rootTsLintFile.modify(rulesPath, { ...rootRules, ...appRules }); - host.overwrite(tsLintPath, rootTsLintFile.content); - }; -} - function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rule { let projectRoot = appDir; if (projectRoot) { @@ -245,18 +222,6 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul scripts: [], }, }, - lint: options.minimal ? undefined : { - builder: Builders.TsLint, - options: { - tsConfig: [ - `${projectRoot}tsconfig.app.json`, - `${projectRoot}tsconfig.spec.json`, - ], - exclude: [ - '**/node_modules/**', - ], - }, - }, }, }; @@ -272,7 +237,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul }); } function minimalPathFilter(path: string): boolean { - const toRemoveList = /(test.ts|tsconfig.spec.json|karma.conf.js|tslint.json).template$/; + const toRemoveList = /(test.ts|tsconfig.spec.json|karma.conf.js).template$/; return !toRemoveList.test(path); } @@ -327,7 +292,6 @@ export default function (options: ApplicationOptions): Rule { appName: options.name, isRootApp, }), - isRootApp ? mergeWithRootTsLint(host) : noop(), move(appDir), ]), MergeStrategy.Overwrite), schematic('module', { diff --git a/packages/schematics/angular/application/index_spec.ts b/packages/schematics/angular/application/index_spec.ts index c4da27dba88a..c32467e0f8aa 100644 --- a/packages/schematics/angular/application/index_spec.ts +++ b/packages/schematics/angular/application/index_spec.ts @@ -51,7 +51,6 @@ describe('Application Schematic', () => { '/projects/foo/karma.conf.js', '/projects/foo/tsconfig.app.json', '/projects/foo/tsconfig.spec.json', - '/projects/foo/tslint.json', '/projects/foo/src/environments/environment.ts', '/projects/foo/src/environments/environment.prod.ts', '/projects/foo/src/favicon.ico', @@ -153,26 +152,6 @@ describe('Application Schematic', () => { expect(_extends).toBe('../../tsconfig.json'); }); - it('should set the right path and prefix in the tslint file', async () => { - const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree) - .toPromise(); - const path = '/projects/foo/tslint.json'; - const content = JSON.parse(tree.readContent(path)); - expect(content.extends).toMatch('../../tslint.json'); - expect(content.rules['directive-selector'][2]).toMatch('app'); - expect(content.rules['component-selector'][2]).toMatch('app'); - }); - - it('should set the right prefix in the tslint file when provided is kebabed', async () => { - const options: ApplicationOptions = { ...defaultOptions, prefix: 'foo-bar' }; - const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) - .toPromise(); - const path = '/projects/foo/tslint.json'; - const content = JSON.parse(tree.readContent(path)); - expect(content.rules['directive-selector'][2]).toMatch('fooBar'); - expect(content.rules['component-selector'][2]).toMatch('foo-bar'); - }); - it('should set the right coverage folder in the karma.json file', async () => { const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree) .toPromise(); @@ -180,7 +159,7 @@ describe('Application Schematic', () => { expect(karmaConf).toContain(`dir: require('path').join(__dirname, '../../coverage/foo')`); }); - it('minimal=true should not create e2e, lint and test targets', async () => { + it('minimal=true should not create e2e and test targets', async () => { const options = { ...defaultOptions, minimal: true }; const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) .toPromise(); @@ -188,7 +167,6 @@ describe('Application Schematic', () => { const architect = config.projects.foo.architect; expect(architect.test).not.toBeDefined(); expect(architect.e2e).not.toBeDefined(); - expect(architect.e2e).not.toBeDefined(); }); it('minimal=true should configure the schematics options for components', async () => { @@ -235,7 +213,6 @@ describe('Application Schematic', () => { const files = tree.files; [ '/projects/foo/tsconfig.spec.json', - '/projects/foo/tslint.json', '/projects/foo/karma.conf.js', '/projects/foo/src/test.ts', '/projects/foo/src/app/app.component.css', @@ -264,7 +241,6 @@ describe('Application Schematic', () => { const files = tree.files; [ '/projects/foo/tsconfig.spec.json', - '/projects/foo/tslint.json', '/projects/foo/karma.conf.js', '/projects/foo/src/test.ts', '/projects/foo/src/app/app.component.html', @@ -293,7 +269,6 @@ describe('Application Schematic', () => { const files = tree.files; [ '/projects/foo/tsconfig.spec.json', - '/projects/foo/tslint.json', '/projects/foo/karma.conf.js', '/projects/foo/src/test.ts', '/projects/foo/src/app/app.component.css', @@ -355,18 +330,6 @@ describe('Application Schematic', () => { const packageJson = JSON.parse(tree.readContent('package.json')); expect(packageJson.devDependencies['@angular-devkit/build-angular']).toBeUndefined(); }); - - it('should set the lint tsConfig option', async () => { - const tree = await schematicRunner.runSchematicAsync('application', defaultOptions, workspaceTree) - .toPromise(); - const workspace = JSON.parse(tree.readContent('/angular.json')); - const lintOptions = workspace.projects.foo.architect.lint.options; - expect(lintOptions.tsConfig).toEqual([ - 'projects/foo/tsconfig.app.json', - 'projects/foo/tsconfig.spec.json', - 'projects/foo/e2e/tsconfig.json', - ]); - }); }); describe('custom projectRoot', () => { @@ -380,7 +343,6 @@ describe('Application Schematic', () => { '/karma.conf.js', '/tsconfig.app.json', '/tsconfig.spec.json', - '/tslint.json', '/src/environments/environment.ts', '/src/environments/environment.prod.ts', '/src/favicon.ico', @@ -448,31 +410,6 @@ describe('Application Schematic', () => { expect(specTsConfig.files).toEqual(['src/test.ts', 'src/polyfills.ts']); }); - it('should set the relative path and prefix in the tslint file', async () => { - const options = { ...defaultOptions, projectRoot: '' }; - - const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) - .toPromise(); - const content = JSON.parse(tree.readContent('/tslint.json')); - expect(content.extends).toMatch('tslint:recommended'); - expect(content.rules['directive-selector'][2]).toMatch('app'); - expect(content.rules['component-selector'][2]).toMatch('app'); - }); - - it('should merge tslint file', async () => { - const options = { ...defaultOptions, projectRoot: '' }; - - const tree = await schematicRunner.runSchematicAsync('application', options, workspaceTree) - .toPromise(); - const content = JSON.parse(tree.readContent('/tslint.json')); - expect(content.extends).toMatch('tslint:recommended'); - expect(content.rules['component-selector'][2]).toMatch('app'); - expect(content.rules['no-console']).toBeDefined(); - // codelyzer rules should be after base tslint rules - expect(Object.keys(content.rules).indexOf('component-selector')) - .toBeGreaterThan(Object.keys(content.rules).indexOf('no-console')); - }); - it(`should create correct paths when 'newProjectRoot' is blank`, async () => { const workspaceTree = await schematicRunner.runSchematicAsync('workspace', { ...workspaceOptions, newProjectRoot: '' }).toPromise(); const options = { ...defaultOptions, projectRoot: undefined }; diff --git a/packages/schematics/angular/e2e/index.ts b/packages/schematics/angular/e2e/index.ts index fc7aaf2092c7..292c918a9119 100644 --- a/packages/schematics/angular/e2e/index.ts +++ b/packages/schematics/angular/e2e/index.ts @@ -62,13 +62,6 @@ export default function (options: E2eOptions): Rule { }, }); - const e2eTsConfig = `${root}/tsconfig.json`; - const lintTarget = project.targets.get('lint'); - if (lintTarget && lintTarget.options && Array.isArray(lintTarget.options.tsConfig)) { - lintTarget.options.tsConfig = - lintTarget.options.tsConfig.concat(e2eTsConfig); - } - return chain([ updateWorkspace(workspace), mergeWith( diff --git a/packages/schematics/angular/library/files/tslint.json.template b/packages/schematics/angular/library/files/tslint.json.template deleted file mode 100644 index 33ecd2e67fbf..000000000000 --- a/packages/schematics/angular/library/files/tslint.json.template +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "<%= relativePathToWorkspaceRoot %>/tslint.json", - "rules": { - "directive-selector": [ - true, - "attribute", - "<%= camelize(prefix) %>", - "camelCase" - ], - "component-selector": [ - true, - "element", - "<%= dasherize(prefix) %>", - "kebab-case" - ] - } -} diff --git a/packages/schematics/angular/library/index.ts b/packages/schematics/angular/library/index.ts index 318de1f1de21..84d7e7329df3 100644 --- a/packages/schematics/angular/library/index.ts +++ b/packages/schematics/angular/library/index.ts @@ -116,18 +116,6 @@ function addLibToWorkspaceFile( karmaConfig: `${projectRoot}/karma.conf.js`, }, }, - lint: { - builder: Builders.TsLint, - options: { - tsConfig: [ - `${projectRoot}/tsconfig.lib.json`, - `${projectRoot}/tsconfig.spec.json`, - ], - exclude: [ - '**/node_modules/**', - ], - }, - }, }, }); }); diff --git a/packages/schematics/angular/library/index_spec.ts b/packages/schematics/angular/library/index_spec.ts index 016a2291b78d..cec4bfc3cff5 100644 --- a/packages/schematics/angular/library/index_spec.ts +++ b/packages/schematics/angular/library/index_spec.ts @@ -50,7 +50,6 @@ describe('Library Schematic', () => { '/projects/foo/ng-package.json', '/projects/foo/package.json', '/projects/foo/README.md', - '/projects/foo/tslint.json', '/projects/foo/tsconfig.lib.json', '/projects/foo/tsconfig.lib.prod.json', '/projects/foo/src/test.ts', @@ -126,15 +125,6 @@ describe('Library Schematic', () => { expect(workspace.projects.foo.prefix).toEqual('pre'); }); - it('should set the right prefix in the tslint file when provided is kebabed', async () => { - const options: GenerateLibrarySchema = { ...defaultOptions, prefix: 'foo-bar' }; - const tree = await schematicRunner.runSchematicAsync('library', options, workspaceTree).toPromise(); - const path = '/projects/foo/tslint.json'; - const content = JSON.parse(tree.readContent(path)); - expect(content.rules['directive-selector'][2]).toMatch('fooBar'); - expect(content.rules['component-selector'][2]).toMatch('foo-bar'); - }); - it('should handle a pascalCasedName', async () => { const options = { ...defaultOptions, name: 'pascalCasedName' }; const tree = await schematicRunner.runSchematicAsync('library', options, workspaceTree).toPromise(); @@ -152,15 +142,6 @@ describe('Library Schematic', () => { expect(fileContent).toContain('exports: [FooComponent]'); }); - it('should set the right path and prefix in the tslint file', async () => { - const tree = await schematicRunner.runSchematicAsync('library', defaultOptions, workspaceTree).toPromise(); - const path = '/projects/foo/tslint.json'; - const content = JSON.parse(tree.readContent(path)); - expect(content.extends).toMatch('../../tslint.json'); - expect(content.rules['directive-selector'][2]).toMatch('lib'); - expect(content.rules['component-selector'][2]).toMatch('lib'); - }); - describe(`update package.json`, () => { it(`should add ng-packagr to devDependencies`, async () => { const tree = await schematicRunner.runSchematicAsync('library', defaultOptions, workspaceTree).toPromise(); diff --git a/packages/schematics/angular/universal/index.ts b/packages/schematics/angular/universal/index.ts index 7e66da5e0485..d912875184e5 100644 --- a/packages/schematics/angular/universal/index.ts +++ b/packages/schematics/angular/universal/index.ts @@ -91,11 +91,6 @@ function updateConfigFile(options: UniversalOptions, tsConfigDirectory: Path): R }, configurations, }); - - const lintTarget = clientProject.targets.get('lint'); - if (lintTarget && lintTarget.options && Array.isArray(lintTarget.options.tsConfig)) { - lintTarget.options.tsConfig = lintTarget.options.tsConfig.concat(serverTsConfig); - } } }); } diff --git a/packages/schematics/angular/utility/workspace-models.ts b/packages/schematics/angular/utility/workspace-models.ts index 28cecea39e5f..248d4ab7a40f 100644 --- a/packages/schematics/angular/utility/workspace-models.ts +++ b/packages/schematics/angular/utility/workspace-models.ts @@ -98,11 +98,6 @@ export interface TestBuilderOptions extends Partial { karmaConfig: string; } -export interface LintBuilderOptions { - tsConfig: string[] | string; - exclude?: string[]; -} - export interface ExtractI18nOptions { browserTarget: string; } @@ -125,7 +120,6 @@ export type LibraryBuilderTarget = BuilderTarget; export type ServerBuilderTarget = BuilderTarget; export type AppShellBuilderTarget = BuilderTarget; -export type LintBuilderTarget = BuilderTarget; export type TestBuilderTarget = BuilderTarget; export type ServeBuilderTarget = BuilderTarget; export type ExtractI18nBuilderTarget = BuilderTarget; @@ -165,7 +159,6 @@ export interface WorkspaceProject { build?: TProjectType extends ProjectType.Library ? LibraryBuilderTarget : BrowserBuilderTarget; server?: ServerBuilderTarget; - lint?: LintBuilderTarget; test?: TestBuilderTarget; serve?: ServeBuilderTarget; e2e?: E2EBuilderTarget; diff --git a/packages/schematics/angular/web-worker/index.ts b/packages/schematics/angular/web-worker/index.ts index 1ebf4942355b..9608395edbee 100644 --- a/packages/schematics/angular/web-worker/index.ts +++ b/packages/schematics/angular/web-worker/index.ts @@ -20,7 +20,7 @@ import { JSONFile } from '../utility/json-file'; import { parseName } from '../utility/parse-name'; import { relativePathToWorkspaceRoot } from '../utility/paths'; import { buildDefaultPath, getWorkspace, updateWorkspace } from '../utility/workspace'; -import { BrowserBuilderOptions, LintBuilderOptions } from '../utility/workspace-models'; +import { BrowserBuilderOptions } from '../utility/workspace-models'; import { Schema as WebWorkerOptions } from './schema'; @@ -135,13 +135,6 @@ export default function (options: WebWorkerOptions): Rule { if (needWebWorkerConfig) { const workerConfigPath = join(normalize(root), 'tsconfig.worker.json'); projectTargetOptions.webWorkerTsConfig = workerConfigPath; - - // add worker tsconfig to lint architect target - const lintTarget = project.targets.get('lint'); - if (lintTarget) { - const lintOptions = (lintTarget.options || {}) as unknown as LintBuilderOptions; - lintOptions.tsConfig = (lintOptions.tsConfig || []).concat(workerConfigPath); - } } const templateSource = apply(url('./files/worker'), [ diff --git a/packages/schematics/angular/web-worker/index_spec.ts b/packages/schematics/angular/web-worker/index_spec.ts index b8d169a12eab..12a4106d1ed1 100644 --- a/packages/schematics/angular/web-worker/index_spec.ts +++ b/packages/schematics/angular/web-worker/index_spec.ts @@ -99,19 +99,6 @@ describe('Web Worker Schematic', () => { expect(appComponent).toContain('console.log(`page got message: ${data}`)'); }); - it('should add worker tsconfig to lint options', async () => { - const tree = await schematicRunner.runSchematicAsync('web-worker', defaultOptions, appTree) - .toPromise(); - const workspace = JSON.parse(tree.readContent('/angular.json')); - const lintOptions = workspace.projects.bar.architect.lint.options; - expect(lintOptions.tsConfig).toEqual([ - 'projects/bar/tsconfig.app.json', - 'projects/bar/tsconfig.spec.json', - 'projects/bar/e2e/tsconfig.json', - 'projects/bar/tsconfig.worker.json', - ]); - }); - it(`should add 'tsconfig.worker.json' outside of 'src' directory in root app`, async () => { const rootAppOptions = { ...appOptions, projectRoot: '', name: 'foo' }; const workerOptions = { ...defaultOptions, project: 'foo' }; diff --git a/packages/schematics/angular/workspace/files/package.json.template b/packages/schematics/angular/workspace/files/package.json.template index f6e7556f5dd6..41f4df11c875 100644 --- a/packages/schematics/angular/workspace/files/package.json.template +++ b/packages/schematics/angular/workspace/files/package.json.template @@ -28,7 +28,6 @@ "@angular/compiler-cli": "<%= latestVersions.Angular %>",<% if (!minimal) { %> "@types/jasmine": "~3.6.0",<% } %> "@types/node": "^12.11.1",<% if (!minimal) { %> - "codelyzer": "^6.0.0", "jasmine-core": "~3.6.0", "jasmine-spec-reporter": "~6.0.0", "karma": "~6.2.0", @@ -37,8 +36,7 @@ "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", - "ts-node": "~9.1.1", - "tslint": "~6.1.0",<% } %> + "ts-node": "~9.1.1",<% } %> "typescript": "<%= latestVersions.TypeScript %>" } } diff --git a/tests/legacy-cli/e2e/tests/generate/lint-fix.ts b/tests/legacy-cli/e2e/tests/generate/lint-fix.ts deleted file mode 100644 index 10394ca45561..000000000000 --- a/tests/legacy-cli/e2e/tests/generate/lint-fix.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; -import { expectToFail } from '../../utils/utils'; - -export default function () { - const nestedConfigContent = ` - { - "rules": { - "quotemark": [ - true, - "double", - "avoid-escape" - ] - } - }`; - - return Promise.resolve() - - // setup a double-quote tslint config - .then(() => writeFile('src/app/tslint.json', nestedConfigContent)) - - // Generate a fixed new component but don't fix rest of app - .then(() => ng('generate', 'component', 'test-component1', '--lint-fix')) - .then(() => expectToFail(() => ng('lint'))) - - // Fix rest of app and generate new component - .then(() => ng('lint', '--fix')) - .then(() => ng('generate', 'component', 'test-component2', '--lint-fix')) - .then(() => ng('lint')) - - // Enable default option and generate all other module related blueprints - .then(() => ng('config', 'schematics.@schematics/angular.directive.lintFix', 'true')) - .then(() => ng('config', 'schematics.@schematics/angular.service.lintFix', 'true')) - .then(() => ng('config', 'schematics.@schematics/angular.pipe.lintFix', 'true')) - .then(() => ng('config', 'schematics.@schematics/angular.guard.lintFix', 'true')) - .then(() => ng('generate', 'directive', 'test-directive')) - .then(() => ng('generate', 'service', 'test-service')) - .then(() => ng('generate', 'pipe', 'test-pipe')) - .then(() => ng('generate', 'guard', 'test-guard')) - .then(() => ng('lint')); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-no-config-section.ts b/tests/legacy-cli/e2e/tests/lint/lint-no-config-section.ts deleted file mode 100644 index 473a6fbb10f9..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-no-config-section.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ng } from '../../utils/process'; -import { oneLine } from 'common-tags'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - return Promise.resolve() - .then(() => ng('config', 'lint', '[]')) - .then(() => ng('lint', 'app')) - .then(({ stdout }) => { - if (!stdout.match(/No lint configuration\(s\) found\./)) { - throw new Error(oneLine` - Expected to match "No lint configuration(s) found." - in ${stdout}. - `); - } - - return stdout; - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts b/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts deleted file mode 100644 index 6253087a997c..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; -import { expectToFail } from '../../utils/utils'; -import { oneLine } from 'common-tags'; -import { updateJsonFile } from '../../utils/project'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - return Promise.resolve() - .then(() => updateJsonFile('angular.json', workspaceJson => { - const appArchitect = workspaceJson.projects['test-project'].architect; - appArchitect.lint.options.tsConfig = undefined; - })) - .then(() => ng('lint', 'app', '--type-check')) - .then(({ stdout }) => { - if (!stdout.match(/A "project" must be specified to enable type checking./)) { - throw new Error(oneLine` - Expected to match "A "project" must be specified to enable type checking." - in ${stdout}. - `); - } - - return stdout; - }) - .then(() => ng('config', 'lint.0.files', '"**/baz.ts"')) - .then(() => writeFile('src/app/foo.ts', 'const foo = "";\n')) - .then(() => writeFile('src/app/baz.ts', 'const baz = \'\';\n')) - .then(() => ng('lint', 'app')) - .then(() => ng('config', 'lint.0.files', '"**/foo.ts"')) - .then(() => expectToFail(() => ng('lint', 'app'))); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-exclude.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-exclude.ts deleted file mode 100644 index 887bd7a06542..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-exclude.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; -import { oneLine } from 'common-tags'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - - return Promise.resolve() - .then(() => ng('config', 'lint.0.exclude', '"**/foo.ts"')) - .then(() => writeFile(fileName, 'const foo = "";\n')) - .then(() => ng('lint', 'app')) - .then(({ stdout }) => { - if (!stdout.match(/All files pass linting\./)) { - throw new Error(oneLine` - Expected to match "All files pass linting." - in ${stdout}. - `); - } - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-fix.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-fix.ts deleted file mode 100644 index 41bbdd6762dc..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-fix.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ng } from '../../utils/process'; -import { readFile, writeFile } from '../../utils/fs'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - - return Promise.resolve() - .then(() => writeFile(fileName, 'const foo = "";\n')) - .then(() => ng('lint', 'app', '--fix', '--force')) - .then(() => readFile(fileName)) - .then(content => { - if (!content.match(/const foo = '';/)) { - throw new Error(`Expected to match "const foo = '';" in ${content}.`); - } - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-force.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-force.ts deleted file mode 100644 index 147941721a52..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-force.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; -import { oneLine } from 'common-tags'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - - return Promise.resolve() - .then(() => writeFile(fileName, 'const foo = "";\n')) - .then(() => ng('lint', 'app', '--force')) - .then(({ stdout }) => { - if (!stdout.match(/" should be '/)) { - throw new Error(`Expected to match "" should be '" in ${stdout}.`); - } - - return stdout; - }) - .then((output) => { - if (!output.match(/Lint errors found in the listed files\./)) { - throw new Error(oneLine` - Expected to match "Lint errors found in the listed files." - in ${output}. - `); - } - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-format-by-aliases.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-format-by-aliases.ts deleted file mode 100644 index 8c1d983e9c18..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-format-by-aliases.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; -import { oneLine } from 'common-tags'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - - return Promise.resolve() - .then(() => writeFile(fileName, 'const foo = "";\n')) - .then(() => ng('lint', 'app', '-t=stylish', '--force')) - .then(({ stdout }) => { - if (!stdout.match(/1:13 quotemark " should be '/)) { - throw new Error(oneLine` - Expected to match "1:13 quotemark " should be '" - in ${stdout}. - `); - } - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-format.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-format.ts deleted file mode 100644 index 5376986eb08c..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-format.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; -import { oneLine } from 'common-tags'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - - return Promise.resolve() - .then(() => writeFile(fileName, 'const foo = "";\n')) - .then(() => ng('lint', 'app', '--format=stylish', '--force')) - .then(({ stdout }) => { - if (!stdout.match(/1:13 quotemark " should be '/)) { - throw new Error(oneLine` - Expected to match "1:13 quotemark " should be '" - in ${stdout}. - `); - } - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-nested-configs.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-nested-configs.ts deleted file mode 100644 index 5ba81188b981..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-nested-configs.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { createDir, writeFile } from '../../utils/fs'; -import { ng } from '../../utils/process'; -import { expectToFail } from '../../utils/utils'; - - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo/foo.ts'; - const nestedConfigContent = ` - { - "rules": { - "quotemark": [ - true, - "double", - "avoid-escape" - ] - } - }`; - - return Promise.resolve() - .then(() => createDir('src/app/foo')) - .then(() => writeFile(fileName, 'const foo = \'\';\n')) - .then(() => writeFile('src/app/foo/tslint.json', nestedConfigContent)) - .then(() => expectToFail(() => ng('lint', 'app'))); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-non-project.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-non-project.ts deleted file mode 100644 index ebe4c207181a..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-non-project.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ng } from '../../utils/process'; -import { expectToFail } from '../../utils/utils'; - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - return Promise.resolve() - .then(() => ng('config', 'lint.0.files', '"src/app/**/*.ts"')) - .then(() => expectToFail(() => ng('lint', 'app'))); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-type-check-fail.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-type-check-fail.ts deleted file mode 100644 index 448c79822a3f..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-type-check-fail.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { ng } from '../../utils/process'; -import { expectToFail } from '../../utils/utils'; -import { writeFile } from '../../utils/fs'; - - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - const fileContents = ` -const ANIMATION_CSS_VALUE_REGEX = 'asda'; -const a = ["asda", 'asda', 'asdasd', "ASDASDAS"]; -const b = "asdasd"; -const c = { - a: "sadas", - b: { - v: "asdasda", - s: ["asda", "asdas", 10, true, "asda"], - } -}; - -function check(val: any, fxState: any) { - if (typeof val === "string" && val.indexOf(" ") < 0) { - var r = val.match(ANIMATION_CSS_VALUE_REGEX); - var num = parseFloat(r[1]); - - if (!isNaN(num)) { - fxState.num = num + ""; - } - fxState.unit = (r[0] !== r[2] ? r[2] : ""); - - } else if (typeof val === "number") { - fxState.num = val + ""; - } -} - - `; - - return Promise.resolve() - .then(() => writeFile(fileName, fileContents)) - .then(() => expectToFail(() => ng('lint', 'app', '--fix', '--type-check'))); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint-with-type-check.ts b/tests/legacy-cli/e2e/tests/lint/lint-with-type-check.ts deleted file mode 100644 index 1c41f38e6a1d..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint-with-type-check.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { ng } from '../../utils/process'; -import { writeFile } from '../../utils/fs'; - - -export default function () { - // TODO(architect): Figure out how this test should look like post devkit/build-angular. - return; - - const fileName = 'src/app/foo.ts'; - const fileContents = ` -const ANIMATION_CSS_VALUE_REGEX = 'asda'; -const a = ["asda", 'asda', 'asdasd', "ASDASDAS"]; -const b = "asdasd"; -const c = { - a: "sadas", - b: { - v: "asdasda", - s: ["asda", "asdas", 10, true, "asda"], - } -}; - -function check(val: any, fxState: any) { - if (typeof val === "string" && val.indexOf(" ") < 0) { - let r = val.match(ANIMATION_CSS_VALUE_REGEX); - let num = parseFloat(r[1]); - - if (!isNaN(num)) { - fxState.num = num + ""; - } - fxState.unit = (r[0] !== r[2] ? r[2] : ""); - - } else if (typeof val === "number") { - fxState.num = val + ""; - } -} - - `; - - return Promise.resolve() - .then(() => writeFile(fileName, fileContents)) - .then(() => ng('lint', 'app', '--fix')) - .then(() => ng('lint', 'app')) - .then(({ stdout }) => { - if (!stdout.match(/All files pass linting./)) { - throw new Error('All files pass linting.'); - } - }); -} diff --git a/tests/legacy-cli/e2e/tests/lint/lint.ts b/tests/legacy-cli/e2e/tests/lint/lint.ts deleted file mode 100644 index 49bd7aadae4b..000000000000 --- a/tests/legacy-cli/e2e/tests/lint/lint.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ng } from '../../utils/process'; -import { oneLine } from 'common-tags'; - -export default function () { - // TODO(architect): Delete this test. It is now in devkit/build-angular. - - return ng('lint', 'test-project') - .then(({ stdout }) => { - if (!stdout.match(/All files pass linting\./)) { - throw new Error(oneLine` - Expected to match "All files pass linting." - in ${stdout}. - `); - } - }); -}