declapract-typescript-ehmpathy 0.45.2 → 0.45.4

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.
Files changed (78) hide show
  1. package/dist/domain/constants.ts +3 -0
  2. package/dist/practices/cicd-app-react-native-expo/best-practice/.gitignore.declapract.ts +1 -1
  3. package/dist/practices/commands/bad-practices/scripts-dir/src/contract/scripts/<star><star>/<star>.ts.declapract.ts +1 -1
  4. package/dist/practices/config/bad-practices/configs-contain-wrong-account-id/config/dev.json.declapract.ts +1 -1
  5. package/dist/practices/config/bad-practices/configs-contain-wrong-account-id/config/prod.json.declapract.ts +1 -1
  6. package/dist/practices/config/bad-practices/configs-contain-wrong-account-id/config/test.json.declapract.ts +1 -1
  7. package/dist/practices/config/bad-practices/divergent-config-shapes/config/dev.json.declapract.ts +1 -1
  8. package/dist/practices/config/bad-practices/divergent-config-shapes/config/prod.json.declapract.ts +1 -1
  9. package/dist/practices/config/bad-practices/in-util-dir-directly/src/<star><star>/<star>.ts.declapract.ts +1 -1
  10. package/dist/practices/config/bad-practices/promise-config/src/<star><star>/<star>.ts.declapract.ts +1 -1
  11. package/dist/practices/config/best-practice/provision/aws/product/parameter-store.tf.declapract.ts +1 -1
  12. package/dist/practices/config/best-practice/src/utils/config/Config.ts.declapract.ts +8 -8
  13. package/dist/practices/dates-and-times/bad-practices/moment/package.json.declapract.ts +1 -1
  14. package/dist/practices/declastruct/bad-practices/old-module-name/package.json.declapract.ts +1 -1
  15. package/dist/practices/directory-structure-src/bad-practices/model-dir/src/<star><star>/<star>.ts.declapract.ts +1 -1
  16. package/dist/practices/directory-structure-src/bad-practices/model-dir/src/model/<star><star>/<star>.ts.declapract.ts +1 -1
  17. package/dist/practices/directory-structure-src/best-practice/src/domain/constants.ts.declapract.ts +1 -1
  18. package/dist/practices/domain/bad-practices/schematic-joi-model/src/domain/<star><star>/<star>.ts.declapract.ts +1 -1
  19. package/dist/practices/domain/bad-practices/simple-type-guards/package.json.declapract.ts +1 -1
  20. package/dist/practices/domain/best-practice/package.json +0 -1
  21. package/dist/practices/errors/bad-practices/error-fns/src/<star><star>/<star>.ts.declapract.ts +1 -1
  22. package/dist/practices/format/bad-practices/format-script/package.json.declapract.ts +1 -1
  23. package/dist/practices/format/bad-practices/prettier/.prettierignore.declapract.ts +1 -1
  24. package/dist/practices/format/bad-practices/prettier/package.json.declapract.ts +1 -1
  25. package/dist/practices/format/bad-practices/prettier/prettier.config.js.declapract.ts +1 -1
  26. package/dist/practices/format/best-practice/package.json.declapract.ts +4 -1
  27. package/dist/practices/git/best-practice/.gitignore.declapract.ts +1 -1
  28. package/dist/practices/husky/bad-practices/postinstall/package.json.declapract.ts +1 -1
  29. package/dist/practices/lambda-clients/bad-practices/lambda-service-client-package/package.json.declapract.ts +1 -1
  30. package/dist/practices/lint/bad-practices/biome-json-extension/biome.json.declapract.ts +7 -0
  31. package/dist/practices/lint/bad-practices/depcheck-denylisted-ignores/.depcheckrc.yml.declapract.ts +1 -2
  32. package/dist/practices/lint/bad-practices/eslint/.eslintrc.js.declapract.ts +1 -1
  33. package/dist/practices/lint/bad-practices/eslint/package.json.declapract.ts +1 -1
  34. package/dist/practices/lint/bad-practices/tslint/package.json.declapract.ts +1 -1
  35. package/dist/practices/lint/best-practice/.depcheckrc.yml +1 -0
  36. package/dist/practices/lint/best-practice/.depcheckrc.yml.declapract.ts +1 -1
  37. package/dist/practices/logging/bad-practices/leveled-term/package.json.declapract.ts +1 -1
  38. package/dist/practices/node-service/bad-practices/license/package.json.declapract.ts +1 -1
  39. package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/contract/handlers/<star>.integration.test.ts.declapract.ts +1 -1
  40. package/dist/practices/nonpublished-modules/bad-practices/ahbode-standard-lambda-handler/src/contract/handlers/<star>.ts.declapract.ts +1 -1
  41. package/dist/practices/nonpublished-modules/bad-practices/deep-omit/src/data/dao/<star><star>/<star>.integration.test.ts.declapract.ts +2 -2
  42. package/dist/practices/package-json-order/best-practice/package.json.declapract.ts +1 -1
  43. package/dist/practices/persist-with-rds/bad-practices/non-prefixed-manual-init-sqls/provision/schema/sql/init/extensions.sql.declapract.ts +1 -1
  44. package/dist/practices/persist-with-rds/bad-practices/old-integration-test-db-dir/provision/docker/integration_test_db/<star><star>/<star>.declapract.ts +1 -1
  45. package/dist/practices/persist-with-rds/bad-practices/old-integration-test-db-hyphen-dir/provision/docker/integration-test-db/<star><star>/<star>.declapract.ts +1 -1
  46. package/dist/practices/persist-with-rds/bad-practices/old-integration-test-db-paths/package.json.declapract.ts +1 -1
  47. package/dist/practices/persist-with-rds/bad-practices/old-packagejson-script-names/package.json.declapract.ts +1 -1
  48. package/dist/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/entities/<star>.ts.declapract.ts +1 -1
  49. package/dist/practices/persist-with-rds/bad-practices/schema-entities-dir/provision/schema/sql/entities.yml.declapract.ts +1 -1
  50. package/dist/practices/persist-with-rds/best-practice/config/dev.json.declapract.ts +1 -1
  51. package/dist/practices/persist-with-rds/best-practice/config/prod.json.declapract.ts +1 -1
  52. package/dist/practices/persist-with-rds/best-practice/config/test.json.declapract.ts +1 -1
  53. package/dist/practices/persist-with-rds/best-practice/provision/aws/product/parameter-store.tf.declapract.ts +2 -2
  54. package/dist/practices/persist-with-rds/best-practice/provision/schema/sql/init/.extensions.sql.declapract.ts +1 -1
  55. package/dist/practices/persist-with-rds/best-practice/src/utils/config/Config.ts.declapract.ts +1 -1
  56. package/dist/practices/runtime-type-checking/bad-practices/joi-types/package.json.declapract.ts +1 -1
  57. package/dist/practices/runtime-type-checking/bad-practices/old-joi-syntax-valid-input-cant-be-array/src/<star><star>/<star>.ts.declapract.ts +1 -1
  58. package/dist/practices/serverless/bad-practices/old-sls-plugins/package.json.declapract.ts +1 -1
  59. package/dist/practices/serverless/best-practice/serverless.yml.declapract.ts +7 -7
  60. package/dist/practices/terraform-common/bad-practices/terraform-dir/provision/terraform/<star><star>/.gitignore.declapract.ts +1 -1
  61. package/dist/practices/terraform-common/bad-practices/terraform-dir/provision/terraform/<star><star>/<star>.hcl.declapract.ts +1 -1
  62. package/dist/practices/terraform-common/bad-practices/terraform-dir/provision/terraform/<star><star>/<star>.tf.declapract.ts +1 -1
  63. package/dist/practices/tests/bad-practices/deprecated-test-deps/package.json.declapract.ts +1 -1
  64. package/dist/practices/tests/bad-practices/old-acceptance-test-utils/acceptance/lambdas/<star>.ts.declapract.ts +3 -3
  65. package/dist/practices/tests/bad-practices/old-acceptance-test-utils-2/acceptance/lambdas/<star>.ts.declapract.ts +1 -1
  66. package/dist/practices/tests/bad-practices/old-acceptance-test-utils-3/acceptance/lambdas/<star>.ts.declapract.ts +1 -1
  67. package/dist/practices/tests/bad-practices/old-extension-pattern/<star><star>/<star>.test.acceptance.ts.declapract.ts +1 -1
  68. package/dist/practices/tests/bad-practices/old-extension-pattern/<star><star>/<star>.test.integration.ts.declapract.ts +1 -1
  69. package/dist/practices/tests/best-practice/jest.unit.env.ts.declapract.ts +1 -1
  70. package/dist/practices/tests-service/best-practice/acceptance/lambdas/<star>.acceptance.test.ts.declapract.ts +2 -3
  71. package/dist/practices/typescript/bad-practices/relative-imports/src/<star><star>/<star>.ts.declapract.ts +33 -6
  72. package/dist/practices/typescript/best-practice/package.json +1 -1
  73. package/dist/practices/typescript/best-practice/package.json.declapract.ts +1 -1
  74. package/dist/practices/uuid/bad-practices/deps-file/package.json.declapract.ts +1 -1
  75. package/dist/practices/uuid/bad-practices/npm-uuidv4/package.json.declapract.ts +1 -1
  76. package/package.json +33 -42
  77. package/dist/practices/tests/bad-practices/old-acceptance-test-utils-2/acceptance/__test_utils__/environment.ts.declapract.ts +0 -3
  78. /package/dist/practices/lint/best-practice/{biome.json → biome.jsonc} +0 -0
@@ -0,0 +1,3 @@
1
+ /**
2
+ * constants shared across the whole service but not tied to a specific domain object go in this file
3
+ */
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
  import { dedupe } from 'domain-objects';
3
3
  import expect from 'expect';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS; // if we see that files with this path exist, its bad practice
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
 
3
3
  import { getServiceVariables } from '../../../../../getVariables';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
 
3
3
  import { getServiceVariables } from '../../../../../getVariables';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
 
3
3
  import { getServiceVariables } from '../../../../../getVariables';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
  import flatten from 'flat';
3
3
 
4
4
  import { readFile } from '../../../../../utils/readFile';
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
  import flatten from 'flat';
3
3
 
4
4
  import { readFile } from '../../../../../utils/readFile';
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (contents?.includes(`../utils/config'`)) return; // if it includes this string, then its a bad practice
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  import { getProjectVariables } from '../../../../../../getVariables';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
  import { UnexpectedCodePathError } from 'helpful-errors';
3
3
 
4
4
  export const check = FileCheckType.CONTAINS;
@@ -7,10 +7,10 @@ export const fix: FileFixFunction = (contents, { declaredFileContents }) =>
7
7
  !declaredFileContents
8
8
  ? UnexpectedCodePathError.throw('expected declared file contents to exist')
9
9
  : !contents
10
- ? { contents: [declaredFileContents.trim(), '}'].join('\n') }
11
- : {
12
- contents: contents.replace(
13
- 'export interface Config {',
14
- declaredFileContents.trim(), // add the prefix
15
- ),
16
- };
10
+ ? { contents: [declaredFileContents.trim(), '}'].join('\n') }
11
+ : {
12
+ contents: contents.replace(
13
+ 'export interface Config {',
14
+ declaredFileContents.trim(), // add the prefix
15
+ ),
16
+ };
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
  import expect from 'expect';
3
3
 
4
4
  export const check: FileCheckFunction = (contents) => {
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
2
2
  import expect from 'expect';
3
3
 
4
4
  export const check: FileCheckFunction = (contents) => {
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  const defineModelImportFromRelativePathName = ({
4
4
  relativeFilePath,
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS; // if we see that files with this path exist, its bad practice
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (contents?.includes('SchematicJoiModel')) return; // if it includes that, then this file matches a bad practice
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  const packageJSONObject = JSON.parse(contents!);
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "domain-objects": "@declapract{check.minVersion('0.31.7')}",
4
- "joi": "@declapract{check.minVersion('17.4.0')}",
5
4
  "type-fns": "@declapract{check.minVersion('1.21.0')}"
6
5
  }
7
6
  }
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
- import { type FileCheckFunction, type FileFixFunction } from 'declapract';
2
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
3
3
 
4
4
  export const check: FileCheckFunction = (contents) => {
5
5
  if (contents?.includes("from '@ehmpathy/error-fns'")) return; // matches if it includes this
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (!contents) throw new Error('fine, does not match bad practice'); // if not defined, doesn't have the script
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,7 @@
1
- import { FileCheckType, FileContentsFunction } from 'declapract/dist/domain';
1
+ import {
2
+ FileCheckType,
3
+ type FileContentsFunction,
4
+ } from 'declapract/dist/domain';
2
5
  import { isPresent } from 'type-fns';
3
6
 
4
7
  /**
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
  import { dedupe } from 'domain-objects';
3
3
  import expect from 'expect';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (!contents) throw new Error('does not match bad practice');
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -0,0 +1,7 @@
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
+
3
+ export const check = FileCheckType.EXISTS;
4
+
5
+ export const fix: FileFixFunction = () => {
6
+ return { contents: null }; // delete biome.json so biome.jsonc can be used instead
7
+ };
@@ -1,5 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
2
- import expect from 'expect';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
3
2
  import yaml from 'yaml';
4
3
 
5
4
  const denylist = [
@@ -1,3 +1,3 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  const depsBlocklist = [
4
4
  '@typescript-eslint/eslint-plugin',
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  const packageJSONObject = JSON.parse(contents!);
@@ -13,3 +13,4 @@ ignores:
13
13
  - "@swc/jest"
14
14
  - husky
15
15
  - tsx
16
+ - tsc-alias
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
- import { FileCheckType, FileFixFunction } from 'declapract';
2
+ import { FileCheckType, type FileFixFunction } from 'declapract';
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies
4
4
  import yaml from 'yaml';
5
5
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
  import expect from 'expect';
3
3
 
4
4
  export const check: FileCheckFunction = async (contents) => {
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -11,7 +11,7 @@ export const fix: FileFixFunction = (contents) => {
11
11
  `import { omitAutogeneratedValues } from 'domain-objects';`,
12
12
  )
13
13
  .replace(
14
- /deepOmit\(([\w|!|?|\.]+), \[[\w'", ]+\]\)/g,
14
+ /deepOmit\(([\w|!|?|.]+), \[[\w'", ]+\]\)/g,
15
15
  'omitAutogeneratedValues($1)',
16
16
  ),
17
17
  };
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
  import expect from 'expect';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS; // if a file exists with this path pattern, then it's bad practice
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS; // if a file exists with this path pattern, then it's bad practice
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS; // i.e., check that the contents of the file contains what's declared (default is equals)
4
4
 
@@ -7,7 +7,7 @@ export const fix: FileFixFunction = (contents, context) => {
7
7
  return {
8
8
  contents: contents
9
9
  .replace(
10
- /value\s+\= var\.secret_database_\w+_password/g,
10
+ /value\s+= var\.secret_database_\w+_password/g,
11
11
  `value = "__IGNORED__" # "ignored" since we dont want to check in secrets to version control (terraform.lifecycle.ignore_changes -> value isn't overwritten)`,
12
12
  )
13
13
  .replace(
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  const grabCreateExtensionLinesFromContents = (contents: string) =>
4
4
  contents
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
  import { UnexpectedCodePathError } from 'helpful-errors';
3
3
 
4
4
  export const check = FileCheckType.CONTAINS; // practice must contain this
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (contents?.includes('.valid(Object.values(')) return; // matches bad practice if this is found
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { FileCheckType } from 'declapract';
2
- import { FileFixFunction } from 'declapract/dist/domain';
2
+ import type { FileFixFunction } from 'declapract/dist/domain';
3
3
 
4
4
  export const check = FileCheckType.CONTAINS; // i.e., check that the contents of the file contains what's declared (default is equals)
5
5
 
@@ -12,11 +12,11 @@ const listAccountAliasesPolicy = ` # allow inferring access from account alia
12
12
  export const fix: FileFixFunction = (contents) => {
13
13
  if (!contents) return { contents }; // do nothing if file dne; // TODO: update to provision file from declared contents
14
14
  let fixed = contents
15
- .replace(/runtime\: nodejs\d\d.x/, 'runtime: nodejs16.x')
16
- .replace(/ - serverless-offline .*\n/, '') // a plugin we no longer use (never used it, no need to have it)
17
- .replace(/ - serverless-pseudo-parameters .*\n/, '') // a plugin we no longer use (serverless supports variables natively now)
18
- .replace(/\#\{AWS\:\:Region\}/g, '${aws:region}') // use the serverless native variables, instead of the pseudo-parameters format
19
- .replace(/\#\{AWS\:\:AccountId\}/g, '${aws:accountId}') // use the serverless native variables, instead of the pseudo-parameters format
15
+ .replace(/runtime: nodejs\d\d.x/, 'runtime: nodejs16.x')
16
+ .replace(/ {2}- serverless-offline .*\n/, '') // a plugin we no longer use (never used it, no need to have it)
17
+ .replace(/ {2}- serverless-pseudo-parameters .*\n/, '') // a plugin we no longer use (serverless supports variables natively now)
18
+ .replace(/#\{AWS::Region\}/g, '${aws:region}') // use the serverless native variables, instead of the pseudo-parameters format
19
+ .replace(/#\{AWS::AccountId\}/g, '${aws:accountId}') // use the serverless native variables, instead of the pseudo-parameters format
20
20
  .replace('## paramstore access', '# parameter store access')
21
21
  .replace(
22
22
  '## allow invocation of other lambdas',
@@ -31,7 +31,7 @@ export const fix: FileFixFunction = (contents) => {
31
31
  'NODE_ENV: ${self:custom.stageToNodeEnvMapping.${self:provider.stage}}\n AWS_NODEJS_CONNECTION_REUSE_ENABLED: true # https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html\n deploymentBucket',
32
32
  ) // add this env flag
33
33
  .replace(
34
- /service: ([a-zA-Z0-9\-]+)\n\n?provider:/,
34
+ /service: ([a-zA-Z0-9-]+)\n\n?provider:/,
35
35
  'service: $1\n\npackage:\n artifact: .artifact/contents.zip\n\nprovider:',
36
36
  )
37
37
  .replace(
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.CONTAINS;
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  import { getProjectVariables } from '../../../../../../getVariables';
4
4
 
@@ -31,7 +31,7 @@ export const fix: FileFixFunction = async (contents, context) => {
31
31
  )
32
32
  .replace(
33
33
  // replace the inputs
34
- /name\: '(\w+)',/g,
34
+ /name: '(\w+)',/g,
35
35
  [
36
36
  `service: '${projectName}',`,
37
37
  `function: '$1',`,
@@ -39,6 +39,6 @@ export const fix: FileFixFunction = async (contents, context) => {
39
39
  `locally,`,
40
40
  ].join('\n'),
41
41
  )
42
- .replace(/data\: /g, 'event: '),
42
+ .replace(/data: /g, 'event: '),
43
43
  };
44
44
  };
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  if (contents?.includes(`import { locally } from '../_utils/environment';`))
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS; // if files matching this pattern exist, bad practice
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileFixFunction } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check = FileCheckType.EXISTS; // if files matching this pattern exist, bad practice
4
4
 
@@ -1,6 +1,6 @@
1
1
  // eslint-disable-next-line import/no-extraneous-dependencies
2
2
  import { FileCheckType } from 'declapract';
3
- import { FileContentsFunction } from 'declapract/dist/domain';
3
+ import type { FileContentsFunction } from 'declapract/dist/domain';
4
4
 
5
5
  import { readFile } from '../../../utils/readFile';
6
6
 
@@ -1,5 +1,4 @@
1
- import chalk from 'chalk';
2
- import { FileCheckFunction } from 'declapract';
1
+ import type { FileCheckFunction } from 'declapract';
3
2
  import expect from 'expect';
4
3
 
5
4
  import { defineFunctionNameFromTestFileName } from '../../../defineFunctionNameFromTestFileName';
@@ -20,7 +19,7 @@ export const check: FileCheckFunction = (contents, context) => {
20
19
  if (missedImports.length)
21
20
  throw new Error(
22
21
  `
23
- ${chalk.green(`- Expected imports ${['', ...expectedImports].join('\n - ')}`)}
22
+ ${`- Expected imports ${['', ...expectedImports].join('\n - ')}`}
24
23
  `.trim(),
25
24
  );
26
25
 
@@ -1,4 +1,4 @@
1
- import { type FileCheckFunction, type FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  /**
4
4
  * .what = detects relative imports that should use @src alias
@@ -8,6 +8,21 @@ import { type FileCheckFunction, type FileFixFunction } from 'declapract';
8
8
  // matches relative imports that go up directories (../)
9
9
  const RELATIVE_IMPORT_PATTERN = /from\s+['"](\.\.\/)+(.*?)['"]/g;
10
10
 
11
+ const isInPracticesDir = (relativeFilePath: string | undefined): boolean =>
12
+ relativeFilePath?.includes('src/practices/') ?? false;
13
+
14
+ const isDeclapractFile = (relativeFilePath: string | undefined): boolean =>
15
+ relativeFilePath?.endsWith('.declapract.ts') ?? false;
16
+
17
+ /**
18
+ * skip files in src/practices/ because they are templates defining what target
19
+ * codebases should look like - not actual config files to be fixed. however,
20
+ * .declapract.ts files contain check/fix logic (not template content) so they
21
+ * should still be processed normally by other practices.
22
+ */
23
+ const shouldSkip = (relativeFilePath: string | undefined): boolean =>
24
+ isInPracticesDir(relativeFilePath) && !isDeclapractFile(relativeFilePath);
25
+
11
26
  export const check: FileCheckFunction = (contents, { relativeFilePath }) => {
12
27
  if (!contents) throw new Error('does not match bad practice');
13
28
 
@@ -16,6 +31,11 @@ export const check: FileCheckFunction = (contents, { relativeFilePath }) => {
16
31
  throw new Error('does not match bad practice');
17
32
  }
18
33
 
34
+ // skip practice template files
35
+ if (shouldSkip(relativeFilePath)) {
36
+ throw new Error('does not match bad practice');
37
+ }
38
+
19
39
  // check for relative imports that go up directories (../)
20
40
  const matches = contents.match(RELATIVE_IMPORT_PATTERN);
21
41
  if (matches && matches.length > 0) {
@@ -28,23 +48,30 @@ export const check: FileCheckFunction = (contents, { relativeFilePath }) => {
28
48
  export const fix: FileFixFunction = (contents, { relativeFilePath }) => {
29
49
  if (!contents) return {};
30
50
  if (!relativeFilePath?.startsWith('src/')) return {};
51
+ if (shouldSkip(relativeFilePath)) return {};
31
52
 
32
53
  // calculate the path parts of the current file
33
54
  const pathParts = relativeFilePath.split('/');
34
55
  const srcIndex = pathParts.indexOf('src');
35
56
 
36
- // replace relative imports with @src imports
57
+ // get the directories between src/ and the current file
58
+ const currentDirParts = pathParts.slice(srcIndex + 1, -1);
59
+
60
+ // replace relative imports with @src imports (only if they stay within src/)
37
61
  const fixed = contents.replace(
38
62
  /from\s+['"]((\.\.\/)+)(.*?)['"]/g,
39
63
  (match, dots, _, importPath) => {
40
64
  // count how many ../ we have
41
65
  const upCount = (dots.match(/\.\.\//g) || []).length;
42
66
 
43
- // get the directories between src/ and the current file
44
- const currentDirParts = pathParts.slice(srcIndex + 1, -1);
67
+ // if going up more levels than we have directories within src/, it goes OUTSIDE src
68
+ // leave these imports unchanged (e.g., ../../package.json from src/utils/index.ts)
69
+ if (upCount > currentDirParts.length) {
70
+ return match;
71
+ }
45
72
 
46
- // if going up more levels than we have directories, just use @src/importPath
47
- if (upCount >= currentDirParts.length) {
73
+ // if going up exactly as many levels as we have directories, target is at src root
74
+ if (upCount === currentDirParts.length) {
48
75
  return `from '@src/${importPath}'`;
49
76
  }
50
77
 
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build:clean": "rm dist/ -rf",
11
11
  "build:compile": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
12
- "build": "npm run build:clean && npm run build:compile && npm run build:artifact",
12
+ "build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present && npm run build:artifact",
13
13
  "test:types": "tsc -p ./tsconfig.json --noEmit"
14
14
  }
15
15
  }
@@ -1,4 +1,4 @@
1
- import { FileCheckType, FileContentsFunction } from 'declapract';
1
+ import { FileCheckType, type FileContentsFunction } from 'declapract';
2
2
 
3
3
  import { readFile } from '../../../utils/readFile';
4
4
 
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  const packageJSONObject = JSON.parse(contents!);
@@ -1,4 +1,4 @@
1
- import { FileCheckFunction, FileFixFunction } from 'declapract';
1
+ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
 
3
3
  export const check: FileCheckFunction = (contents) => {
4
4
  const packageJSONObject = JSON.parse(contents!);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.45.2",
5
+ "version": "0.45.4",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
@@ -13,26 +13,30 @@
13
13
  ],
14
14
  "scripts": {
15
15
  "commit:with-cli": "npx cz",
16
- "fix:format:prettier": "prettier --write '**/*.ts' --config ./prettier.config.js",
16
+ "biome:nested:readme": "echo 'todo, remove the need for this once https://github.com/biomejs/biome/issues/7942 is fixed'",
17
+ "biome:nested:hide": "mv src/practices/lint/best-practice/biome.jsonc src/practices/lint/best-practice/_biome.jsonc 2>/dev/null || true",
18
+ "biome:nested:restore": "mv src/practices/lint/best-practice/_biome.jsonc src/practices/lint/best-practice/biome.jsonc 2>/dev/null || true",
19
+ "fix:format:biome": "npm run biome:nested:hide && biome check --write; EXIT=$?; npm run biome:nested:restore; exit $EXIT",
17
20
  "fix:format:terraform": "terraform fmt -recursive",
18
- "fix:format": "npm run fix:format:prettier",
19
- "fix:lint": "eslint -c ./.eslintrc.js src/**/*.ts --fix",
21
+ "fix:format": "npm run fix:format:biome",
22
+ "fix:lint": "npm run biome:nested:hide && biome check --write; EXIT=$?; npm run biome:nested:restore; exit $EXIT",
20
23
  "fix": "npm run fix:format && npm run fix:lint",
21
24
  "build:clean": "rm dist/ -rf",
22
25
  "build:compile": "npx declapract compile",
23
26
  "build": "npm run build:clean && npm run build:compile",
24
27
  "test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
25
- "test:types": "tsc -p ./tsconfig.build.json --noEmit",
26
- "test:format:prettier": "prettier --parser typescript --check 'src/**/*.ts' --config ./prettier.config.js",
27
- "test:format": "npm run test:format:prettier",
28
+ "test:types": "tsc -p ./tsconfig.json --noEmit",
29
+ "test:format": "npm run test:format:biome",
28
30
  "test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
29
- "test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
30
- "test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
31
+ "test:validate": "npm run build && npx declapract validate",
32
+ "test:format:biome": "npm run biome:nested:hide && biome format; EXIT=$?; npm run biome:nested:restore; exit $EXIT",
33
+ "test:lint:biome": "npm run biome:nested:hide && biome check --diagnostic-level=error; EXIT=$?; npm run biome:nested:restore; exit $EXIT",
34
+ "test:lint:biome:all": "npm run biome:nested:hide && biome check; EXIT=$?; npm run biome:nested:restore; exit $EXIT",
35
+ "test:lint": "npm run test:lint:biome && npm run test:lint:deps",
31
36
  "test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
32
37
  "test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
33
- "test:validate": "npm run build && npx declapract validate",
34
38
  "test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
35
- "test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally && npm run test:validate",
39
+ "test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally && test:validate",
36
40
  "test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
37
41
  "prepush": "npm run test && npm run build",
38
42
  "prepublish": "npm run build",
@@ -42,55 +46,42 @@
42
46
  "prepare": "[ -e .git ] && npm run prepare:husky || exit 0"
43
47
  },
44
48
  "dependencies": {
45
- "chalk": "4.1.2",
46
- "domain-objects": "0.31.3",
49
+ "domain-objects": "0.31.7",
50
+ "esbuild-register": "3.6.0",
47
51
  "expect": "29.4.2",
48
52
  "flat": "5.0.2",
49
53
  "helpful-errors": "1.5.3",
50
54
  "rhachet": "1.13.1",
51
55
  "rhachet-roles-ehmpathy": "1.13.7",
52
- "simple-log-methods": "0.5.0",
53
- "yaml": "1.10.2"
56
+ "yaml": "2.8.2"
54
57
  },
55
58
  "peerDependencies": {
56
- "declapract": ">=0.12.1"
59
+ "declapract": ">=0.13.1"
57
60
  },
58
61
  "devDependencies": {
59
- "@babel/core": "7.28.5",
60
- "@babel/preset-env": "7.28.5",
61
- "@commitlint/cli": "19.3.0",
62
- "@commitlint/config-conventional": "13.1.0",
63
- "@ehmpathy/as-command": "1.0.1",
64
- "@trivago/prettier-plugin-sort-imports": "4.3.0",
65
- "@tsconfig/node-lts-strictest": "18.12.1",
62
+ "@biomejs/biome": "2.3.8",
63
+ "@commitlint/cli": "19.5.0",
64
+ "@commitlint/config-conventional": "19.5.0",
65
+ "@swc/core": "1.15.3",
66
+ "@swc/jest": "0.2.39",
67
+ "@tsconfig/node20": "20.1.5",
68
+ "@tsconfig/strictest": "2.0.5",
66
69
  "@types/flat": "5.0.2",
67
- "@types/jest": "29.4.0",
70
+ "@types/jest": "30.0.0",
68
71
  "@types/node": "22.15.21",
69
- "@typescript-eslint/eslint-plugin": "7.8.0",
70
- "@typescript-eslint/parser": "7.8.0",
71
- "babel-jest": "30.2.0",
72
- "core-js": "3.26.1",
73
72
  "cz-conventional-changelog": "3.3.0",
74
- "declastruct": "1.4.5",
75
- "declastruct-github": "1.0.5",
73
+ "declastruct": "1.7.0",
74
+ "declastruct-github": "1.0.7",
76
75
  "depcheck": "1.4.3",
77
- "eslint": "8.56.0",
78
- "eslint-config-airbnb-typescript": "18.0.0",
79
- "eslint-config-prettier": "8.5.0",
80
- "eslint-plugin-import": "2.26.0",
81
- "eslint-plugin-prettier": "4.2.1",
82
- "eslint-plugin-unused-imports": "4.1.4",
76
+ "esbuild-register": "3.6.0",
83
77
  "husky": "8.0.3",
84
- "jest": "29.3.1",
85
- "prettier": "2.8.1",
78
+ "jest": "30.2.0",
86
79
  "rhachet": "1.13.1",
87
80
  "rhachet-roles-ehmpathy": "1.13.8",
88
- "test-fns": "1.4.2",
89
- "ts-jest": "29.4.5",
81
+ "tsc-alias": "1.8.10",
90
82
  "tsx": "4.20.6",
91
83
  "type-fns": "0.8.1",
92
- "typescript": "5.4.5",
93
- "visualogic": "1.2.3"
84
+ "typescript": "5.4.5"
94
85
  },
95
86
  "config": {
96
87
  "commitizen": {
@@ -1,3 +0,0 @@
1
- import { FileCheckType } from 'declapract';
2
-
3
- export const check = FileCheckType.EXISTS;