@meadowlark-software/angular-config 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # @meadowlark-software/angular-config changelog
2
+
3
+ Each entry starts with **Added**, **Changed**, **Fixed**, **Removed** or **Upgrading**; an **Upgrading** entry says
4
+ what a consumer changes to take the version. Changes waiting for a release are under **Unreleased**.
5
+
6
+ ## Unreleased
7
+
8
+ - **Changed** `@typescript-eslint/strict-boolean-expressions` rejects strings and numbers as conditions, since `''` and
9
+ `0` would pass for missing.
10
+ - **Changed** Prettier wraps at 160 columns instead of 120.
11
+ - **Upgrading** Compare strings and numbers explicitly in conditions, such as `name !== ''` or `count > 0`, and run
12
+ Prettier to rewrap.
13
+
14
+ ## 0.1.0
15
+
16
+ The changes up to this version are in the repository's commit history.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Meadowlark Software
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # @meadowlark-software/angular-config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The compiler, lint and format settings every Meadowlark Angular client builds with, so they are the same in every
4
+ repository and change in one place.
5
+
6
+ Install it, pinned, with the tools it configures:
7
+
8
+ ```bash
9
+ npm install --save-dev --save-exact @meadowlark-software/angular-config
10
+ ```
11
+
12
+ Its peer dependencies (`eslint`, `@eslint/js`, `typescript-eslint`, `angular-eslint`, `eslint-config-prettier`,
13
+ `prettier` and `@inlang/paraglide-js`) are the client's own, at the versions it pins.
14
+
15
+ - **`tsconfig.json`**: strict TypeScript and strict Angular templates.
16
+
17
+ ```json
18
+ { "extends": "@meadowlark-software/angular-config/tsconfig.json", "compilerOptions": { "outDir": "./dist/out-tsc" } }
19
+ ```
20
+
21
+ - **`eslint.config.js`**:
22
+
23
+ ```js
24
+ module.exports = require('@meadowlark-software/angular-config')({ tsconfigRootDir: __dirname });
25
+ ```
26
+
27
+ Options: `prefix`, the selector prefix (`app` unless set), and `ignores`, more files to leave unlinted. Generated
28
+ code in `src/paraglide/` and `src/app/api/` is already left out.
29
+
30
+ - **`.prettierrc.json`**:
31
+
32
+ ```json
33
+ "@meadowlark-software/angular-config/prettier"
34
+ ```
35
+
36
+ Beyond the recommended rules, the lint settings ban browser APIs newer than Angular's target browsers, reading the time
37
+ anywhere but `Clock` from `@meadowlark-software/angular`, `Math.random`, a `default` arm on a switch over a union, a file over 300 lines, a
38
+ message looked up by a computed key, and a string or number as a condition: write `name !== ''` or `count !== 0`, since
39
+ `''` and `0` are rarely meant as missing. Prettier wraps at 160 columns.
package/eslint.js ADDED
@@ -0,0 +1,112 @@
1
+ // @ts-check
2
+ const eslint = require('@eslint/js');
3
+ const { defineConfig } = require('eslint/config');
4
+ const tseslint = require('typescript-eslint');
5
+ const angular = require('angular-eslint');
6
+ const prettier = require('eslint-config-prettier/flat');
7
+ // an ES module; require loads it in the Node versions the client builds with
8
+ const paraglide = require('@inlang/paraglide-js/eslint').default;
9
+
10
+ /*
11
+ * tsconfig's lib is ESNext, so TypeScript knows methods newer than the browsers the build targets. Angular targets
12
+ * Baseline "widely available" and does not polyfill library methods, so these would type-check, build and then fail in
13
+ * an older browser. Take one off this list once the target includes it. Iterator helpers cannot be caught here.
14
+ */
15
+ const NOT_YET_IN_TARGET = 'is newer than the browsers the build targets (Baseline widely available)';
16
+ const notYetInTarget = [
17
+ ...[
18
+ ['Object', 'groupBy'],
19
+ ['Map', 'groupBy'],
20
+ ['Promise', 'withResolvers'],
21
+ ['Array', 'fromAsync'],
22
+ ].map(([object, property]) => ({ object, property, message: `${object}.${property} ${NOT_YET_IN_TARGET}` })),
23
+ ...['union', 'intersection', 'difference', 'symmetricDifference', 'isSubsetOf', 'isSupersetOf', 'isDisjointFrom'].map((property) => ({
24
+ property,
25
+ message: `Set.prototype.${property} ${NOT_YET_IN_TARGET}`,
26
+ })),
27
+ ];
28
+
29
+ // Only the clock's own implementation reads the time, with a suppression saying so.
30
+ const USE_CLOCK = 'Read the time from Clock in @meadowlark-software/angular; tests use provideFakeClock';
31
+ const ambient = [
32
+ { object: 'Date', property: 'now', message: USE_CLOCK },
33
+ { object: 'performance', property: 'now', message: USE_CLOCK },
34
+ { object: 'Math', property: 'random', message: 'Take randomness as a dependency' },
35
+ ];
36
+ const ambientSyntax = [
37
+ { selector: "NewExpression[callee.name='Date'][arguments.length=0]", message: USE_CLOCK },
38
+ { selector: "CallExpression[callee.name='Date']", message: USE_CLOCK },
39
+ ];
40
+
41
+ /**
42
+ * The lint settings every Angular client builds with, from its `eslint.config.js`:
43
+ *
44
+ * module.exports = require('@meadowlark-software/angular-config')({ tsconfigRootDir: __dirname });
45
+ *
46
+ * @param {object} options
47
+ * @param {string} options.tsconfigRootDir The client's folder, where its `tsconfig.json` is.
48
+ * @param {string} [options.prefix] The prefix of the client's selectors; `app` unless it is a library.
49
+ * @param {string[]} [options.ignores] More files to leave unlinted, such as other generated code.
50
+ */
51
+ function angularConfig({ tsconfigRootDir, prefix = 'app', ignores = [] }) {
52
+ return defineConfig([
53
+ {
54
+ // src/paraglide is compiled from messages/, and src/app/api is generated from the OpenAPI document
55
+ ignores: ['.angular/**', 'dist/**', 'coverage/**', 'node_modules/**', 'src/paraglide/**', 'src/app/api/**', ...ignores],
56
+ },
57
+ {
58
+ files: ['**/*.ts'],
59
+ extends: [eslint.configs.recommended, tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked, angular.configs.tsRecommended],
60
+ processor: angular.processInlineTemplates,
61
+ plugins: { paraglide },
62
+ languageOptions: {
63
+ parserOptions: {
64
+ projectService: true,
65
+ tsconfigRootDir,
66
+ },
67
+ },
68
+ rules: {
69
+ '@angular-eslint/directive-selector': ['error', { type: 'attribute', prefix, style: 'camelCase' }],
70
+ '@angular-eslint/component-selector': ['error', { type: 'element', prefix, style: 'kebab-case' }],
71
+ '@angular-eslint/prefer-inject': 'error',
72
+ '@angular-eslint/prefer-signals': 'error',
73
+ '@angular-eslint/prefer-on-push-component-change-detection': 'error',
74
+ '@typescript-eslint/consistent-type-imports': ['error', { fixStyle: 'separate-type-imports' }],
75
+ '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
76
+ '@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
77
+ '@typescript-eslint/no-floating-promises': 'error',
78
+ '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
79
+ // a string or number as a condition treats '' and 0 as missing, which is rarely what was meant
80
+ '@typescript-eslint/strict-boolean-expressions': ['error', { allowString: false, allowNumber: false }],
81
+ // a default arm would hide a new case of a union
82
+ '@typescript-eslint/switch-exhaustiveness-check': [
83
+ 'error',
84
+ { allowDefaultCaseForExhaustiveSwitch: false, considerDefaultExhaustiveForUnions: false },
85
+ ],
86
+ 'max-lines': ['error', { max: 300 }],
87
+ 'no-restricted-properties': ['error', ...notYetInTarget, ...ambient],
88
+ 'no-restricted-syntax': ['error', ...ambientSyntax],
89
+ // m[key]() keeps every message in the bundle and loses the typing
90
+ 'paraglide/no-dynamic-message-access': 'error',
91
+ },
92
+ },
93
+ {
94
+ // test doubles use mocks and loosely typed fixtures
95
+ files: ['**/*.spec.ts'],
96
+ rules: {
97
+ '@typescript-eslint/no-unsafe-assignment': 'off',
98
+ '@typescript-eslint/no-unsafe-member-access': 'off',
99
+ '@typescript-eslint/no-unsafe-call': 'off',
100
+ '@typescript-eslint/unbound-method': 'off',
101
+ '@typescript-eslint/no-non-null-assertion': 'off',
102
+ },
103
+ },
104
+ {
105
+ files: ['**/*.html'],
106
+ extends: [angular.configs.templateRecommended, angular.configs.templateAccessibility],
107
+ },
108
+ prettier,
109
+ ]);
110
+ }
111
+
112
+ module.exports = angularConfig;
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@meadowlark-software/angular-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "The compiler, lint and format settings every Meadowlark Angular client builds with.",
5
+ "license": "MIT",
6
+ "author": "Meadowlark Software",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Meadowlark-Software/foundation.git",
10
+ "directory": "angular/projects/angular-config"
11
+ },
12
+ "keywords": [
13
+ "angular",
14
+ "eslint",
15
+ "prettier",
16
+ "tsconfig"
17
+ ],
18
+ "main": "eslint.js",
19
+ "exports": {
20
+ ".": "./eslint.js",
21
+ "./eslint": "./eslint.js",
22
+ "./tsconfig.json": "./tsconfig.json",
23
+ "./prettier": "./prettier.json",
24
+ "./prettier.json": "./prettier.json"
25
+ },
26
+ "files": [
27
+ "eslint.js",
28
+ "tsconfig.json",
29
+ "prettier.json",
30
+ "README.md",
31
+ "CHANGELOG.md",
32
+ "LICENSE"
33
+ ],
34
+ "peerDependencies": {
35
+ "@eslint/js": "^10.0.1",
36
+ "@inlang/paraglide-js": "^3.2.2",
37
+ "angular-eslint": "^22.8.0",
38
+ "eslint": "^10.16.0",
39
+ "eslint-config-prettier": "^10.1.9",
40
+ "prettier": "^3.10.1",
41
+ "typescript-eslint": "^8.74.0"
42
+ },
43
+ "scripts": {
44
+ "prepack": "node -e \"require('node:fs').copyFileSync('../../../LICENSE', 'LICENSE')\""
45
+ }
46
+ }
package/prettier.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "printWidth": 160,
3
+ "singleQuote": true,
4
+ "tabWidth": 4,
5
+ "overrides": [
6
+ { "files": "*.json", "options": { "tabWidth": 2 } },
7
+ { "files": "*.html", "options": { "parser": "angular" } }
8
+ ]
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "compilerOptions": {
3
+ "strict": true,
4
+ "noUncheckedIndexedAccess": true,
5
+ "exactOptionalPropertyTypes": true,
6
+ "noPropertyAccessFromIndexSignature": true,
7
+ "noImplicitOverride": true,
8
+ "noImplicitReturns": true,
9
+ "noFallthroughCasesInSwitch": true,
10
+ "noUnusedLocals": true,
11
+ "noUnusedParameters": true,
12
+ "verbatimModuleSyntax": true,
13
+ "isolatedModules": true,
14
+ "skipLibCheck": true,
15
+ "esModuleInterop": true,
16
+ "experimentalDecorators": true,
17
+ "moduleResolution": "bundler",
18
+ "importHelpers": true,
19
+ "target": "ES2022",
20
+ "module": "preserve",
21
+ "lib": ["ESNext", "DOM"]
22
+ },
23
+ "angularCompilerOptions": {
24
+ "enableI18nLegacyMessageIdFormat": false,
25
+ "strictInjectionParameters": true,
26
+ "strictInputAccessModifiers": true,
27
+ "strictTemplates": true,
28
+ "extendedDiagnostics": {
29
+ "defaultCategory": "error"
30
+ }
31
+ }
32
+ }