diff --git a/.eslintrc.json b/.eslintrc.json index 25be7e43..49524997 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,8 @@ // 👇 Added `coverage/**/*` to be able to run 'eslint .' successfully // When upgrading to v9, can include .gitignore here. In v8, you need to add a CLI flag // Given 'eslint .' is not something ran often, it's good enough as ienough as is - "ignorePatterns": ["projects/**/*", "coverage/**/*"], + // Removing `projects/**/*` to allow using `eslint .` to lint everything. + "ignorePatterns": ["coverage/**/*", "!.*.json"], "parserOptions": { "ecmaVersion": 9 // for jest.config.js files on IntelliJ }, @@ -47,6 +48,17 @@ { "files": ["*.cy.ts"], "extends": ["plugin:cypress/recommended"] + }, + { + //👇 `*.json` is needed so that when `lint-staged` sends any kind of JSON file, + // ESLint doesn't complain about them. However, just `package.json` files are linted. + "files": ["*.json"], + "plugins": ["json-files"], + "rules": { + "json-files/require-unique-dependency-names": "error", + "json-files/ensure-repository-directory": "error", + "json-files/restrict-ranges": ["error", { "versionHint": "pin" }] + } } ] } diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 342cfa76..fe202695 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,5 +1,5 @@ { - "!(*.ts)": ["pnpm run format"], - "*.ts": ["pnpm run lint:code:raw --fix", "pnpm run format"], + "!(*.{json,ts})": ["pnpm run format"], + "*.{json,ts}": ["pnpm run lint:code:raw --fix", "pnpm run format"], ".github/**/*.{yml,yaml}": ["pnpm run lint:gh-actions"] } diff --git a/angular.json b/angular.json index b7964595..bdafe155 100644 --- a/angular.json +++ b/angular.json @@ -37,8 +37,7 @@ "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": [ - "projects/ngx-meta/src/**/*.ts", - "projects/ngx-meta/src/**/*.html", + "projects/ngx-meta/src/**/*.{ts,html}", "projects/ngx-meta/e2e/**/*.ts", "projects/ngx-meta/example-apps/**/*.ts", "projects/ngx-meta/schematics/**/*.ts" diff --git a/package.json b/package.json index 2580b203..76b4a391 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "eslint-plugin-cypress": "3.6.0", "eslint-plugin-jasmine": "4.2.2", "eslint-plugin-jest": "28.8.3", + "eslint-plugin-json-files": "4.4.1", "husky": "9.1.6", "jasmine-core": "5.4.0", "jest": "29.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d2442934..813213c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -132,6 +132,9 @@ importers: eslint-plugin-jest: specifier: 28.8.3 version: 28.8.3(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(typescript@5.4.5))(eslint@8.57.1)(jest@29.7.0(@types/node@22.8.7))(typescript@5.4.5) + eslint-plugin-json-files: + specifier: 4.4.1 + version: 4.4.1(eslint@8.57.1) husky: specifier: 9.1.6 version: 9.1.6 @@ -1402,6 +1405,10 @@ packages: resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} + '@humanwhocodes/momoa@2.0.4': + resolution: {integrity: sha512-RE815I4arJFtt+FVeU1Tgp9/Xvecacji8w/V6XtXsWWH/wz/eNkNbhb+ny/+PlVZjV0rxQpRSQKNKE3lcktHEA==} + engines: {node: '>=10.10.0'} + '@humanwhocodes/object-schema@2.0.3': resolution: {integrity: sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==} deprecated: Use @eslint/object-schema instead @@ -2180,6 +2187,9 @@ packages: '@types/express@4.17.21': resolution: {integrity: sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==} + '@types/glob@7.2.0': + resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} + '@types/graceful-fs@4.1.9': resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} @@ -2213,6 +2223,9 @@ packages: '@types/mime@3.0.4': resolution: {integrity: sha512-iJt33IQnVRkqeqC7PzBHPTC6fDlRNRW8vjrgqtScAhrmMwe8c4Eo7+fUGTa+XdWrpEgpyKWMYmi2dIwMAYRzPw==} + '@types/minimatch@5.1.2': + resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} + '@types/mute-stream@0.0.4': resolution: {integrity: sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==} @@ -2636,6 +2649,12 @@ packages: before-after-hook@3.0.2: resolution: {integrity: sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==} + better-ajv-errors@1.2.0: + resolution: {integrity: sha512-UW+IsFycygIo7bclP9h5ugkNH8EjCSgqyFB/yQ4Hqqa1OEYDtb0uFIkYE0b6+CjkgJYVM5UKI/pJPxjYe9EZlA==} + engines: {node: '>= 12.13.0'} + peerDependencies: + ajv: 4.11.8 - 8 + big.js@5.2.2: resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} @@ -3147,6 +3166,10 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + detect-indent@6.1.0: + resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} + engines: {node: '>=8'} + detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -3375,6 +3398,12 @@ packages: jest: optional: true + eslint-plugin-json-files@4.4.1: + resolution: {integrity: sha512-R91vfR2rxvvkEG9KJZu3SmbZrcqEljxsjUgq/wenKTkZ1uRJtCzk51NbU7aCocENH59bskUUiy1NOl2dSOjkXQ==} + engines: {node: '>=18.12'} + peerDependencies: + eslint: '>=5' + eslint-scope@5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'} @@ -3686,6 +3715,9 @@ packages: resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} engines: {node: '>=18'} + git-hooks-list@1.0.3: + resolution: {integrity: sha512-Y7wLWcrLUXwk2noSka166byGCvhMtDRpgHdzCno1UQv/n/Hegp++a2xBWJL1lJarnKD3SWaljD+0z1ztqxuKyQ==} + git-log-parser@1.2.0: resolution: {integrity: sha512-rnCVNfkTL8tdNryFuaY0fYiBWEBcgF748O6ZI61rslBvr2o7U65c2/6npCRqH40vuAhtgtDiqLTJjBVdrejCzA==} @@ -3726,6 +3758,10 @@ packages: resolution: {integrity: sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==} engines: {node: '>=8'} + globby@10.0.0: + resolution: {integrity: sha512-3LifW9M4joGZasyYPz2A1U74zbC/45fvpXUvO/9KbSa+VV0aGZarWkfdgKyR9sExNP0t0x0ss/UMJpNpcaTspw==} + engines: {node: '>=8'} + globby@11.1.0: resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} engines: {node: '>=10'} @@ -4057,6 +4093,10 @@ packages: resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} engines: {node: '>=8'} + is-plain-obj@2.1.0: + resolution: {integrity: sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==} + engines: {node: '>=8'} + is-plain-obj@3.0.0: resolution: {integrity: sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==} engines: {node: '>=10'} @@ -4388,6 +4428,10 @@ packages: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} + jsonpointer@5.0.1: + resolution: {integrity: sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==} + engines: {node: '>=0.10.0'} + karma-chrome-launcher@3.2.0: resolution: {integrity: sha512-rE9RkUPI7I9mAxByQWkGJFXfFD6lE4gC5nPuZdobf/QdTEJI6EU4yIay/cfU/xV4ZxlM5JiTv7zWYgA64NpS5Q==} @@ -5534,6 +5578,10 @@ packages: require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} + requireindex@1.2.0: + resolution: {integrity: sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==} + engines: {node: '>=0.10.5'} + requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} @@ -5826,6 +5874,13 @@ packages: peerDependencies: tslib: '2' + sort-object-keys@1.1.3: + resolution: {integrity: sha512-855pvK+VkU7PaKYPc+Jjnmt4EzejQHyhhF33q31qG8x7maDzkeFhAAThdCYay11CISO+qAMwjOBP+fPZe0IPyg==} + + sort-package-json@1.57.0: + resolution: {integrity: sha512-FYsjYn2dHTRb41wqnv+uEqCUvBpK3jZcTp9rbz2qDTmel7Pmdtf+i2rLaaPMRZeSVM60V3Se31GyWFpmKs4Q5Q==} + hasBin: true + source-map-js@1.2.0: resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} engines: {node: '>=0.10.0'} @@ -7983,6 +8038,8 @@ snapshots: '@humanwhocodes/module-importer@1.0.1': {} + '@humanwhocodes/momoa@2.0.4': {} + '@humanwhocodes/object-schema@2.0.3': {} '@inquirer/checkbox@2.4.7': @@ -8970,6 +9027,11 @@ snapshots: '@types/qs': 6.9.10 '@types/serve-static': 1.15.5 + '@types/glob@7.2.0': + dependencies: + '@types/minimatch': 5.1.2 + '@types/node': 22.8.7 + '@types/graceful-fs@4.1.9': dependencies: '@types/node': 22.8.7 @@ -9002,6 +9064,8 @@ snapshots: '@types/mime@3.0.4': {} + '@types/minimatch@5.1.2': {} + '@types/mute-stream@0.0.4': dependencies: '@types/node': 22.8.7 @@ -9495,6 +9559,15 @@ snapshots: before-after-hook@3.0.2: {} + better-ajv-errors@1.2.0(ajv@8.17.1): + dependencies: + '@babel/code-frame': 7.24.7 + '@humanwhocodes/momoa': 2.0.4 + ajv: 8.17.1 + chalk: 4.1.2 + jsonpointer: 5.0.1 + leven: 3.1.0 + big.js@5.2.2: {} binary-extensions@2.2.0: {} @@ -10015,6 +10088,8 @@ snapshots: destroy@1.2.0: {} + detect-indent@6.1.0: {} + detect-libc@2.0.3: {} detect-newline@3.1.0: {} @@ -10255,6 +10330,16 @@ snapshots: - supports-color - typescript + eslint-plugin-json-files@4.4.1(eslint@8.57.1): + dependencies: + ajv: 8.17.1 + better-ajv-errors: 1.2.0(ajv@8.17.1) + eslint: 8.57.1 + fast-glob: 3.3.2 + requireindex: 1.2.0 + semver: 7.6.3 + sort-package-json: 1.57.0 + eslint-scope@5.1.1: dependencies: esrecurse: 4.3.0 @@ -10661,6 +10746,8 @@ snapshots: '@sec-ant/readable-stream': 0.4.1 is-stream: 4.0.1 + git-hooks-list@1.0.3: {} + git-log-parser@1.2.0: dependencies: argv-formatter: 1.0.0 @@ -10713,6 +10800,17 @@ snapshots: dependencies: type-fest: 0.20.2 + globby@10.0.0: + dependencies: + '@types/glob': 7.2.0 + array-union: 2.1.0 + dir-glob: 3.0.1 + fast-glob: 3.3.2 + glob: 7.2.3 + ignore: 5.3.2 + merge2: 1.4.1 + slash: 3.0.0 + globby@11.1.0: dependencies: array-union: 2.1.0 @@ -11015,6 +11113,8 @@ snapshots: is-path-inside@3.0.3: {} + is-plain-obj@2.1.0: {} + is-plain-obj@3.0.0: {} is-plain-obj@4.1.0: {} @@ -11508,6 +11608,8 @@ snapshots: jsonparse@1.3.1: {} + jsonpointer@5.0.1: {} + karma-chrome-launcher@3.2.0: dependencies: which: 1.3.1 @@ -12673,6 +12775,8 @@ snapshots: require-main-filename@2.0.0: {} + requireindex@1.2.0: {} + requires-port@1.0.0: {} resolve-cwd@3.0.0: @@ -13058,6 +13162,17 @@ snapshots: tree-dump: 1.0.1(tslib@2.7.0) tslib: 2.7.0 + sort-object-keys@1.1.3: {} + + sort-package-json@1.57.0: + dependencies: + detect-indent: 6.1.0 + detect-newline: 3.1.0 + git-hooks-list: 1.0.3 + globby: 10.0.0 + is-plain-obj: 2.1.0 + sort-object-keys: 1.1.3 + source-map-js@1.2.0: {} source-map-js@1.2.1: {} diff --git a/projects/ngx-meta/.eslintrc.json b/projects/ngx-meta/.eslintrc.json new file mode 100644 index 00000000..ba93ef6b --- /dev/null +++ b/projects/ngx-meta/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "../../.eslintrc.json", + "ignorePatterns": ["dist/**/*", "out/**/*"] +} diff --git a/projects/ngx-meta/docs/.eslintrc.json b/projects/ngx-meta/docs/.eslintrc.json new file mode 100644 index 00000000..b392e5d3 --- /dev/null +++ b/projects/ngx-meta/docs/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../.eslintrc.json", + "ignorePatterns": ["content/fonts/**/*"] +} diff --git a/projects/ngx-meta/src/.eslintrc.json b/projects/ngx-meta/src/.eslintrc.json index a33164c9..5bda0f1c 100644 --- a/projects/ngx-meta/src/.eslintrc.json +++ b/projects/ngx-meta/src/.eslintrc.json @@ -31,6 +31,14 @@ "files": ["*.spec.ts"], "extends": ["plugin:jasmine/recommended"], "plugins": ["jasmine"] + }, + { + "files": ["package.json"], + "plugins": ["json-files"], + "rules": { + "json-files/require-license": "error", + "json-files/restrict-ranges": ["error", { "versionHint": "caret" }] + } } ] }