Skip to content

Commit 84828e9

Browse files
Test with an Angular workspace in the Angular smoke test. (#181)
Resolves #177. Test with an Angular workspace to validate that the style guide configuration works with the workspace configuration, root applications, libraries, language and parser options, ng lint, and the standalone eslint command. This also validates the instructions provided in the README. The original ignore custom attributes test has been integrated into the root application component template. Additionally, there is a root component test with HTML file and library component test with inline template. The workspace has been reduced to the necessities of a test which satisfies the criteria. - Test with an Angular workspace in the Angular smoke test. Testing - Verified that the automated tests pass (npm test) - ng lint - eslint - cd projects/angular-library && eslint . - Manually verified that the application builds and starts
1 parent 9003e00 commit 84828e9

30 files changed

+34741
-3173
lines changed

package-lock.json

Lines changed: 16187 additions & 3038 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/angular/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
/.angular
3+
/dist

tests/angular/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Angular Smoke Test
22

3-
## Overview
3+
This package is a smoke test for using the Angular rules in an Angular workspace. See [CONTRIBUTING.md](../../CONTRIBUTING.md#smoke-tests) for more information on smoke tests.
44

5-
This package is a smoke test for using the Angular rules in a project. See [CONTRIBUTING.md](../../CONTRIBUTING.md#smoke-tests) for more information.
5+
## Testing
6+
7+
- The `npm test` script runs the linter to test that the lint configuration functions correctly with `ng lint` and and also runs `ng test`.

tests/angular/angular.json

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"angular-test": {
7+
"projectType": "application",
8+
"root": "",
9+
"sourceRoot": "src",
10+
"prefix": "app",
11+
"architect": {
12+
"build": {
13+
"builder": "@angular-devkit/build-angular:application",
14+
"options": {
15+
"outputPath": "dist/angular-test",
16+
"index": "src/index.html",
17+
"browser": "src/main.ts",
18+
"polyfills": [
19+
"zone.js",
20+
"@angular/localize/init"
21+
],
22+
"tsConfig": "tsconfig.app.json"
23+
},
24+
"configurations": {
25+
"production": {
26+
"outputHashing": "all"
27+
},
28+
"development": {
29+
"optimization": false,
30+
"extractLicenses": false,
31+
"sourceMap": true
32+
}
33+
},
34+
"defaultConfiguration": "production"
35+
},
36+
"serve": {
37+
"builder": "@angular-devkit/build-angular:dev-server",
38+
"configurations": {
39+
"production": {
40+
"buildTarget": "angular-test:build:production"
41+
},
42+
"development": {
43+
"buildTarget": "angular-test:build:development"
44+
}
45+
},
46+
"defaultConfiguration": "development"
47+
},
48+
"extract-i18n": {
49+
"builder": "@angular-devkit/build-angular:extract-i18n"
50+
},
51+
"test": {
52+
"builder": "@angular-devkit/build-angular:karma",
53+
"options": {
54+
"browsers": "ChromeHeadlessNoSandbox",
55+
"polyfills": [
56+
"zone.js",
57+
"zone.js/testing",
58+
"@angular/localize/init"
59+
],
60+
"tsConfig": "tsconfig.spec.json",
61+
"watch": false
62+
}
63+
},
64+
"lint": {
65+
"builder": "@angular-eslint/builder:lint",
66+
"options": {
67+
"lintFilePatterns": [
68+
"src/**/*.ts",
69+
"src/**/*.js",
70+
"src/**/*.mjs",
71+
"src/**/*.html"
72+
]
73+
}
74+
}
75+
}
76+
},
77+
"angular-library": {
78+
"projectType": "library",
79+
"root": "projects/angular-library",
80+
"sourceRoot": "projects/angular-library/src",
81+
"prefix": "angular-lib",
82+
"architect": {
83+
"build": {
84+
"builder": "@angular-devkit/build-angular:ng-packagr",
85+
"options": {
86+
"project": "projects/angular-library/ng-package.json"
87+
},
88+
"configurations": {
89+
"production": {
90+
"tsConfig": "projects/angular-library/tsconfig.lib.prod.json"
91+
},
92+
"development": {
93+
"tsConfig": "projects/angular-library/tsconfig.lib.json"
94+
}
95+
},
96+
"defaultConfiguration": "production"
97+
},
98+
"test": {
99+
"builder": "@angular-devkit/build-angular:karma",
100+
"options": {
101+
"browsers": "ChromeHeadlessNoSandbox",
102+
"polyfills": [
103+
"zone.js",
104+
"zone.js/testing",
105+
"@angular/localize/init"
106+
],
107+
"tsConfig": "projects/angular-library/tsconfig.spec.json",
108+
"watch": false
109+
}
110+
},
111+
"lint": {
112+
"builder": "@angular-eslint/builder:lint",
113+
"options": {
114+
"lintFilePatterns": [
115+
"projects/angular-library/**/*.ts",
116+
"projects/angular-library/**/*.js",
117+
"projects/angular-library/**/*.mjs",
118+
"projects/angular-library/**/*.html"
119+
],
120+
"eslintConfig": "projects/angular-library/eslint.config.mjs"
121+
}
122+
}
123+
}
124+
}
125+
},
126+
"cli": {
127+
"analytics": false,
128+
"schematicCollections": [
129+
"angular-eslint"
130+
]
131+
}
132+
}

tests/angular/custom-ignore-attributes/index.html

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/angular/custom-ignore-attributes/index.spec.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/angular/custom-ignore-attributes/index.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/angular/eslint.config.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/angular/eslint.config.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import { angularTypescriptConfig, angularTemplateConfig, ignoreAttributes } from '@ni/eslint-config-angular';
3+
import { javascriptConfig, importNodeEsmConfig } from '@ni/eslint-config-javascript';
4+
5+
export default defineConfig([
6+
globalIgnores(['projects']),
7+
{
8+
files: ['**/*.js', '**/*.mjs'],
9+
extends: [javascriptConfig, importNodeEsmConfig]
10+
}, {
11+
files: ['**/*.ts'],
12+
extends: angularTypescriptConfig,
13+
languageOptions: {
14+
parserOptions: {
15+
project: ['tsconfig.app.json', 'tsconfig.spec.json', 'tsconfig.json']
16+
}
17+
},
18+
rules: {
19+
'@angular-eslint/component-selector': [
20+
'error', { prefix: 'app', style: 'kebab-case', type: 'element' }
21+
]
22+
}
23+
}, {
24+
files: ['**/*.spec.ts'],
25+
rules: {
26+
'@typescript-eslint/no-unsafe-call': 'off',
27+
'@typescript-eslint/no-unsafe-member-access': 'off'
28+
}
29+
}, {
30+
files: ['**/*.html'],
31+
extends: angularTemplateConfig,
32+
rules: {
33+
'@angular-eslint/template/i18n': [
34+
'error',
35+
{ checkId: false, ignoreAttributes: [...ignoreAttributes.all, 'custom-field'] }
36+
]
37+
}
38+
}]);

tests/angular/index.spec.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)