eslint-cdk-plugin 0.4.0 → 1.0.1

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 (42) hide show
  1. package/README.md +52 -7
  2. package/dist/index.d.mts +31 -0
  3. package/dist/index.mjs +8 -1
  4. package/dist/index.mjs.map +1 -0
  5. package/dist/no-class-in-interface-props.d.mts +2 -0
  6. package/dist/no-class-in-interface-props.mjs +10 -18
  7. package/dist/no-class-in-interface-props.mjs.map +1 -0
  8. package/dist/no-construct-stack-suffix.d.mts +2 -0
  9. package/dist/no-construct-stack-suffix.mjs +13 -22
  10. package/dist/no-construct-stack-suffix.mjs.map +1 -0
  11. package/dist/no-import-private.d.mts +2 -0
  12. package/dist/no-import-private.mjs +17 -29
  13. package/dist/no-import-private.mjs.map +1 -0
  14. package/dist/no-mutable-props-interface.d.mts +2 -0
  15. package/dist/no-mutable-props-interface.mjs +11 -23
  16. package/dist/no-mutable-props-interface.mjs.map +1 -0
  17. package/dist/no-mutable-public-fields.d.mts +2 -0
  18. package/dist/no-mutable-public-fields.mjs +20 -33
  19. package/dist/no-mutable-public-fields.mjs.map +1 -0
  20. package/dist/no-parent-name-construct-id-match.d.mts +2 -0
  21. package/dist/no-parent-name-construct-id-match.mjs +82 -129
  22. package/dist/no-parent-name-construct-id-match.mjs.map +1 -0
  23. package/dist/no-public-class-fields.d.mts +2 -0
  24. package/dist/no-public-class-fields.mjs +30 -57
  25. package/dist/no-public-class-fields.mjs.map +1 -0
  26. package/dist/no-variable-construct-id.d.mts +2 -0
  27. package/dist/no-variable-construct-id.mjs +63 -0
  28. package/dist/no-variable-construct-id.mjs.map +1 -0
  29. package/dist/pascal-case-construct-id.d.mts +2 -0
  30. package/dist/pascal-case-construct-id.mjs +17 -44
  31. package/dist/pascal-case-construct-id.mjs.map +1 -0
  32. package/dist/require-passing-this.d.mts +2 -0
  33. package/dist/require-passing-this.mjs +39 -0
  34. package/dist/require-passing-this.mjs.map +1 -0
  35. package/dist/utils/convertString.d.mts +1 -0
  36. package/dist/utils/convertString.mjs +4 -9
  37. package/dist/utils/convertString.mjs.map +1 -0
  38. package/dist/utils/typeCheck.d.mts +3 -0
  39. package/dist/utils/typeCheck.mjs +16 -0
  40. package/dist/utils/typeCheck.mjs.map +1 -0
  41. package/package.json +2 -2
  42. package/dist/utils/isConstructOrStackType.mjs +0 -19
package/README.md CHANGED
@@ -1,12 +1,24 @@
1
- # eslint-cdk-plugin
1
+ <p align="center">
2
+ <img width="160px" height="160px" src="https://raw.githubusercontent.com/ren-yamanashi/eslint-cdk-plugin/main/assets/logo.png" alt="ESLint plugin for AWS CDK logo">
3
+ </p>
2
4
 
3
- ESLint plugin for [AWS CDK](https://github.com/aws/aws-cdk).
5
+ <h1 align="center">eslint-cdk-plugin</h1>
6
+ <p align="center">ESLint plugin for AWS CDK</p>
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/eslint-cdk-plugin">
9
+ <img src="https://img.shields.io/npm/v/eslint-cdk-plugin.svg" alt="NPM">
10
+ </a>
11
+ </p>
4
12
 
5
- ## Installation
13
+ ## 📔 Documentation
14
+
15
+ Please refer to the [website](https://eslint-cdk-plugin.dev/).
16
+
17
+ ## 📦 Installation
6
18
 
7
19
  ```bash
8
20
  # npm
9
- npm install --save-dev eslint-cdk-plugin
21
+ npm install -D eslint-cdk-plugin
10
22
 
11
23
  # yarn
12
24
  yarn add -D eslint-cdk-plugin
@@ -15,9 +27,9 @@ yarn add -D eslint-cdk-plugin
15
27
  pnpm install -D eslint-cdk-plugin
16
28
  ```
17
29
 
18
- ## Usage
30
+ ## 🚀 Usage
19
31
 
20
- ### Use recommended config
32
+ #### Use recommended config
21
33
 
22
34
  ```js
23
35
  // eslint.config.mjs
@@ -34,4 +46,37 @@ export default [
34
46
  ];
35
47
  ```
36
48
 
37
- ### For more detailed documentation, see [docs for eslint-cdk-plugin](https://eslint-cdk-plugin.dev/)
49
+ #### Use custom config
50
+
51
+ ```js
52
+ // eslint.config.mjs
53
+ import eslintCdkPlugin from "eslint-cdk-plugin";
54
+ export default [
55
+ {
56
+ plugins: {
57
+ cdk: eslintCdkPlugin,
58
+ },
59
+ rules: {
60
+ "cdk/no-class-in-interface": "error",
61
+ "cdk/no-construct-stack-suffix": "error",
62
+ "cdk/no-parent-name-construct-id-match": "error",
63
+ },
64
+ },
65
+ ];
66
+ ```
67
+
68
+ ## ❗ Issue
69
+
70
+ If you have any questions or suggestions, please open an [issue](https://github.com/ren-yamanashi/eslint-cdk-plugin/issues).
71
+
72
+ ## 💪 Contribution
73
+
74
+ Contributions are welcome! Please see [Contribution Guide](https://github.com/ren-yamanashi/eslint-cdk-plugin/blob/main/CONTRIBUTING.md) for more details.
75
+
76
+ ## ⚓ Versioning Policy
77
+
78
+ Please see [Versioning Policy](https://github.com/ren-yamanashi/eslint-cdk-plugin/blob/main/VERSIONING_POLICY.md).
79
+
80
+ ## ©️ License
81
+
82
+ [MIT](http://opensource.org/licenses/MIT)
@@ -0,0 +1,31 @@
1
+ declare const plugin: {
2
+ rules: {
3
+ "no-class-in-interface": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noClassInInterfaceProps", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
4
+ "no-construct-stack-suffix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noConstructStackSuffix", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
5
+ "no-import-private": import("eslint").Rule.RuleModule;
6
+ "no-parent-name-construct-id-match": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noParentNameConstructIdMatch", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
7
+ "no-public-class-fields": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noPublicClassFields", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
8
+ "pascal-case-construct-id": import("@typescript-eslint/utils/ts-eslint").RuleModule<"pascalCaseConstructId", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
9
+ "no-mutable-public-fields": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noMutablePublicFields", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
10
+ "no-mutable-props-interface": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noMutablePropsInterface", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
11
+ "require-passing-this": import("@typescript-eslint/utils/ts-eslint").RuleModule<"requirePassingThis", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
12
+ "no-variable-construct-id": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noVariableConstructId", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
13
+ };
14
+ configs: {
15
+ recommended: {
16
+ plugins: string[];
17
+ rules: {
18
+ "cdk/no-class-in-interface": string;
19
+ "cdk/no-construct-stack-suffix": string;
20
+ "cdk/no-parent-name-construct-id-match": string;
21
+ "cdk/no-public-class-fields": string;
22
+ "cdk/pascal-case-construct-id": string;
23
+ "cdk/require-passing-this": string;
24
+ "cdk/no-variable-construct-id": string;
25
+ "cdk/no-mutable-public-fields": string;
26
+ "cdk/no-mutable-props-interface": string;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ export default plugin;
package/dist/index.mjs CHANGED
@@ -5,8 +5,10 @@ import { noMutablePropsInterface } from "./no-mutable-props-interface.mjs";
5
5
  import { noMutablePublicFields } from "./no-mutable-public-fields.mjs";
6
6
  import { noParentNameConstructIdMatch } from "./no-parent-name-construct-id-match.mjs";
7
7
  import { noPublicClassFields } from "./no-public-class-fields.mjs";
8
+ import { noVariableConstructId } from "./no-variable-construct-id.mjs";
8
9
  import { pascalCaseConstructId } from "./pascal-case-construct-id.mjs";
9
- var plugin = {
10
+ import { requirePassingThis } from "./require-passing-this.mjs";
11
+ const plugin = {
10
12
  rules: {
11
13
  "no-class-in-interface": noClassInInterfaceProps,
12
14
  "no-construct-stack-suffix": noConstructStackSuffix,
@@ -16,6 +18,8 @@ var plugin = {
16
18
  "pascal-case-construct-id": pascalCaseConstructId,
17
19
  "no-mutable-public-fields": noMutablePublicFields,
18
20
  "no-mutable-props-interface": noMutablePropsInterface,
21
+ "require-passing-this": requirePassingThis,
22
+ "no-variable-construct-id": noVariableConstructId,
19
23
  },
20
24
  configs: {
21
25
  recommended: {
@@ -26,6 +30,8 @@ var plugin = {
26
30
  "cdk/no-parent-name-construct-id-match": "error",
27
31
  "cdk/no-public-class-fields": "error",
28
32
  "cdk/pascal-case-construct-id": "error",
33
+ "cdk/require-passing-this": "error",
34
+ "cdk/no-variable-construct-id": "error",
29
35
  "cdk/no-mutable-public-fields": "warn",
30
36
  "cdk/no-mutable-props-interface": "warn",
31
37
  },
@@ -33,3 +39,4 @@ var plugin = {
33
39
  },
34
40
  };
35
41
  export default plugin;
42
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,MAAM,GAAG;IACb,KAAK,EAAE;QACL,uBAAuB,EAAE,uBAAuB;QAChD,2BAA2B,EAAE,sBAAsB;QACnD,mBAAmB,EAAE,eAAe;QACpC,mCAAmC,EAAE,4BAA4B;QACjE,wBAAwB,EAAE,mBAAmB;QAC7C,0BAA0B,EAAE,qBAAqB;QACjD,0BAA0B,EAAE,qBAAqB;QACjD,4BAA4B,EAAE,uBAAuB;QACrD,sBAAsB,EAAE,kBAAkB;QAC1C,0BAA0B,EAAE,qBAAqB;KAClD;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,KAAK,CAAC;YAChB,KAAK,EAAE;gBACL,2BAA2B,EAAE,OAAO;gBACpC,+BAA+B,EAAE,OAAO;gBACxC,uCAAuC,EAAE,OAAO;gBAChD,4BAA4B,EAAE,OAAO;gBACrC,8BAA8B,EAAE,OAAO;gBACvC,0BAA0B,EAAE,OAAO;gBACnC,8BAA8B,EAAE,OAAO;gBACvC,8BAA8B,EAAE,MAAM;gBACtC,gCAAgC,EAAE,MAAM;aACzC;SACF;KACF;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noClassInInterfaceProps: ESLintUtils.RuleModule<"noClassInInterfaceProps", [], unknown, ESLintUtils.RuleListener>;
@@ -1,12 +1,6 @@
1
1
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
2
2
  import { SymbolFlags } from "typescript";
3
- /**
4
- * Enforces the use of interface types instead of class in interface properties
5
- * @param context - The rule context provided by ESLint
6
- * @returns An object containing the AST visitor functions
7
- * @see {@link https://eslint-cdk-plugin.dev/rules/no-class-in-interface} - Documentation
8
- */
9
- export var noClassInInterfaceProps = ESLintUtils.RuleCreator.withoutDocs({
3
+ export const noClassInInterfaceProps = ESLintUtils.RuleCreator.withoutDocs({
10
4
  meta: {
11
5
  type: "problem",
12
6
  docs: {
@@ -18,24 +12,21 @@ export var noClassInInterfaceProps = ESLintUtils.RuleCreator.withoutDocs({
18
12
  schema: [],
19
13
  },
20
14
  defaultOptions: [],
21
- create: function (context) {
22
- var parserServices = ESLintUtils.getParserServices(context);
23
- var checker = parserServices.program.getTypeChecker();
15
+ create(context) {
16
+ const parserServices = ESLintUtils.getParserServices(context);
17
+ const typeChecker = parserServices.program.getTypeChecker();
24
18
  return {
25
- TSInterfaceDeclaration: function (node) {
26
- for (var _i = 0, _a = node.body.body; _i < _a.length; _i++) {
27
- var property = _a[_i];
28
- // NOTE: check property signature
19
+ TSInterfaceDeclaration(node) {
20
+ for (const property of node.body.body) {
29
21
  if (property.type !== AST_NODE_TYPES.TSPropertySignature ||
30
22
  property.key.type !== AST_NODE_TYPES.Identifier) {
31
23
  continue;
32
24
  }
33
- var tsNode = parserServices.esTreeNodeToTSNodeMap.get(property);
34
- var type = checker.getTypeAtLocation(tsNode);
25
+ const tsNode = parserServices.esTreeNodeToTSNodeMap.get(property);
26
+ const type = typeChecker.getTypeAtLocation(tsNode);
35
27
  if (!type.symbol)
36
28
  continue;
37
- // NOTE: check class type
38
- var isClass = type.symbol.flags === SymbolFlags.Class;
29
+ const isClass = type.symbol.flags === SymbolFlags.Class;
39
30
  if (!isClass)
40
31
  continue;
41
32
  context.report({
@@ -51,3 +42,4 @@ export var noClassInInterfaceProps = ESLintUtils.RuleCreator.withoutDocs({
51
42
  };
52
43
  },
53
44
  });
45
+ //# sourceMappingURL=no-class-in-interface-props.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-class-in-interface-props.mjs","sourceRoot":"","sources":["../src/no-class-in-interface-props.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAQzC,MAAM,CAAC,MAAM,uBAAuB,GAAG,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IACzE,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,8CAA8C;SAC5D;QACD,QAAQ,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ils.RuleModule<"noConstructStackSuffix", [], unknown, ESLintUtils.RuleListener>;
@@ -1,13 +1,7 @@
1
1
  import { AST_NODE_TYPES, ESLintUtils, } from "@typescript-eslint/utils";
2
2
  import { toPascalCase } from "./utils/convertString.mjs";
3
- import { isConstructOrStackType } from "./utils/isConstructOrStackType.mjs";
4
- /**
5
- * Enforces that Construct IDs do not end with 'Construct' or 'Stack' suffix
6
- * @param context - The rule context provided by ESLint
7
- * @returns An object containing the AST visitor functions
8
- * @see {@link https://eslint-cdk-plugin.dev/rules/no-construct-stack-suffix} - Documentation
9
- */
10
- export var noConstructStackSuffix = ESLintUtils.RuleCreator.withoutDocs({
3
+ import { isConstructOrStackType } from "./utils/typeCheck.mjs";
4
+ export const noConstructStackSuffix = ESLintUtils.RuleCreator.withoutDocs({
11
5
  meta: {
12
6
  type: "problem",
13
7
  docs: {
@@ -19,12 +13,12 @@ export var noConstructStackSuffix = ESLintUtils.RuleCreator.withoutDocs({
19
13
  schema: [],
20
14
  },
21
15
  defaultOptions: [],
22
- create: function (context) {
23
- var parserServices = ESLintUtils.getParserServices(context);
24
- var checker = parserServices.program.getTypeChecker();
16
+ create(context) {
17
+ const parserServices = ESLintUtils.getParserServices(context);
18
+ const typeChecker = parserServices.program.getTypeChecker();
25
19
  return {
26
- NewExpression: function (node) {
27
- var type = checker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node));
20
+ NewExpression(node) {
21
+ const type = typeChecker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node));
28
22
  if (!isConstructOrStackType(type)) {
29
23
  return;
30
24
  }
@@ -35,22 +29,18 @@ export var noConstructStackSuffix = ESLintUtils.RuleCreator.withoutDocs({
35
29
  };
36
30
  },
37
31
  });
38
- /**
39
- * Validate that construct ID does not end with "Construct" or "Stack"
40
- */
41
- var validateConstructId = function (node, context, expression) {
32
+ const validateConstructId = (node, context, expression) => {
42
33
  if (expression.arguments.length < 2)
43
34
  return;
44
- // NOTE: Treat the second argument as ID
45
- var secondArg = expression.arguments[1];
35
+ const secondArg = expression.arguments[1];
46
36
  if (secondArg.type !== AST_NODE_TYPES.Literal ||
47
37
  typeof secondArg.value !== "string") {
48
38
  return;
49
39
  }
50
- var formattedConstructId = toPascalCase(secondArg.value);
40
+ const formattedConstructId = toPascalCase(secondArg.value);
51
41
  if (formattedConstructId.endsWith("Construct")) {
52
42
  context.report({
53
- node: node,
43
+ node,
54
44
  messageId: "noConstructStackSuffix",
55
45
  data: {
56
46
  classType: "Construct",
@@ -61,7 +51,7 @@ var validateConstructId = function (node, context, expression) {
61
51
  }
62
52
  else if (formattedConstructId.endsWith("Stack")) {
63
53
  context.report({
64
- node: node,
54
+ node,
65
55
  messageId: "noConstructStackSuffix",
66
56
  data: {
67
57
  classType: "Stack",
@@ -71,3 +61,4 @@ var validateConstructId = function (node, context, expression) {
71
61
  });
72
62
  }
73
63
  };
64
+ //# sourceMappingURL=no-construct-stack-suffix.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-construct-stack-suffix.mjs","sourceRoot":"","sources":["../src/no-construct-stack-suffix.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,GAGZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAU/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IACxE,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,uEAAuE;SAC1E;QACD,QAAQ,EAAE;YACR,sBAAsB,EACpB,uEAAuE;SAC1E;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,MAAM,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9D,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OAAO,CAAC,MAAM,CAAC;YACb,IAAI;YACJ,SAAS,EAAE,wBAAwB;YACnC,IAAI,EAAE;gBACJ,SAAS,EAAE,OAAO;gBAClB,EAAE,EAAE,SAAS,CAAC,KAAK;gBACnB,MAAM,EAAE,OAAO;aAChB;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Rule } from "eslint";
2
+ export declare const noImportPrivate: Rule.RuleModule;
@@ -1,11 +1,5 @@
1
1
  import * as path from "path";
2
- /**
3
- * Disallow importing modules from private directories at different levels of the hierarchy.
4
- * @param context - The rule context provided by ESLint
5
- * @returns An object containing the AST visitor functions
6
- * @see {@link https://eslint-cdk-plugin.dev/rules/no-import-private} - Documentation
7
- */
8
- export var noImportPrivate = {
2
+ export const noImportPrivate = {
9
3
  meta: {
10
4
  type: "problem",
11
5
  docs: {
@@ -16,34 +10,28 @@ export var noImportPrivate = {
16
10
  },
17
11
  schema: [],
18
12
  },
19
- create: function (context) {
13
+ create(context) {
20
14
  return {
21
- ImportDeclaration: function (node) {
22
- var _a, _b;
23
- var importPath = (_b = (_a = node.source.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "";
24
- var currentFilePath = context.filename;
25
- var currentDirPath = path.dirname(currentFilePath);
15
+ ImportDeclaration(node) {
16
+ const importPath = node.source.value?.toString() ?? "";
17
+ const currentFilePath = context.filename;
18
+ const currentDirPath = path.dirname(currentFilePath);
26
19
  if (importPath.includes("/private")) {
27
- var absoluteCurrentDirPath = path.resolve(currentDirPath);
28
- var absoluteImportPath = path.resolve(currentDirPath, importPath);
29
- // NOTE: Get the directory from the import path up to the private directory
30
- var importDirBeforePrivate = absoluteImportPath.split("/private")[0];
31
- var currentDirSegments = getDirSegments(absoluteCurrentDirPath);
32
- var importDirSegments_1 = getDirSegments(importDirBeforePrivate);
33
- if (currentDirSegments.length !== importDirSegments_1.length ||
34
- currentDirSegments.some(function (segment, index) { return segment !== importDirSegments_1[index]; })) {
35
- context.report({ node: node, messageId: "noImportPrivate" });
20
+ const absoluteCurrentDirPath = path.resolve(currentDirPath);
21
+ const absoluteImportPath = path.resolve(currentDirPath, importPath);
22
+ const importDirBeforePrivate = absoluteImportPath.split("/private")[0];
23
+ const currentDirSegments = getDirSegments(absoluteCurrentDirPath);
24
+ const importDirSegments = getDirSegments(importDirBeforePrivate);
25
+ if (currentDirSegments.length !== importDirSegments.length ||
26
+ currentDirSegments.some((segment, index) => segment !== importDirSegments[index])) {
27
+ context.report({ node, messageId: "noImportPrivate" });
36
28
  }
37
29
  }
38
30
  },
39
31
  };
40
32
  },
41
33
  };
42
- /**
43
- * Split the directory path into segments (split at `/`)
44
- * @param dirPath - The directory path to split
45
- * @returns The segments of the directory path
46
- */
47
- var getDirSegments = function (dirPath) {
48
- return dirPath.split(path.sep).filter(function (segment) { return segment !== ""; });
34
+ const getDirSegments = (dirPath) => {
35
+ return dirPath.split(path.sep).filter((segment) => segment !== "");
49
36
  };
37
+ //# sourceMappingURL=no-import-private.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-import-private.mjs","sourceRoot":"","sources":["../src/no-import-private.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAU7B,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EACT,8EAA8E;SACjF;QACD,QAAQ,EAAE;YACR,eAAe,EACb,8EAA8E;SACjF;QACD,MAAM,EAAE,EAAE;KACX;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,iBAAiB,CAAC,IAAI;gBACpB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACvD,MAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;gBACzC,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;gBAErD,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;oBACpC,MAAM,sBAAsB,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;oBAC5D,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;oBAGpE,MAAM,sBAAsB,GAC1B,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;oBAE1C,MAAM,kBAAkB,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;oBAClE,MAAM,iBAAiB,GAAG,cAAc,CAAC,sBAAsB,CAAC,CAAC;oBACjE,IACE,kBAAkB,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM;wBACtD,kBAAkB,CAAC,IAAI,CACrB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,iBAAiB,CAAC,KAAK,CAAC,CACzD,EACD,CAAC;wBACD,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC,CAAC;oBACzD,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAOF,MAAM,cAAc,GAAG,CAAC,OAAe,EAAY,EAAE;IACnD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;AACrE,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noMutablePropsInterface: ESLintUtils.RuleModule<"noMutablePropsInterface", [], unknown, ESLintUtils.RuleListener>;
@@ -1,11 +1,5 @@
1
1
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
2
- /**
3
- * Disallow mutable properties in Props interfaces
4
- * @param context - The rule context provided by ESLint
5
- * @returns An object containing the AST visitor functions
6
- * @see {@link https://eslint-cdk-plugin.dev/rules/no-mutable-props-interface} - Documentation
7
- */
8
- export var noMutablePropsInterface = ESLintUtils.RuleCreator.withoutDocs({
2
+ export const noMutablePropsInterface = ESLintUtils.RuleCreator.withoutDocs({
9
3
  meta: {
10
4
  type: "problem",
11
5
  docs: {
@@ -18,39 +12,33 @@ export var noMutablePropsInterface = ESLintUtils.RuleCreator.withoutDocs({
18
12
  schema: [],
19
13
  },
20
14
  defaultOptions: [],
21
- create: function (context) {
22
- var sourceCode = context.sourceCode;
15
+ create(context) {
16
+ const sourceCode = context.sourceCode;
23
17
  return {
24
- TSInterfaceDeclaration: function (node) {
25
- // NOTE: Interface name check for "Props"
18
+ TSInterfaceDeclaration(node) {
26
19
  if (!node.id.name.endsWith("Props"))
27
20
  return;
28
- var _loop_1 = function (property) {
29
- // NOTE: check property signature
21
+ for (const property of node.body.body) {
30
22
  if (property.type !== AST_NODE_TYPES.TSPropertySignature ||
31
23
  property.key.type !== AST_NODE_TYPES.Identifier) {
32
- return "continue";
24
+ continue;
33
25
  }
34
- // NOTE: Skip if already readonly
35
26
  if (property.readonly)
36
- return "continue";
27
+ continue;
37
28
  context.report({
38
29
  node: property,
39
30
  messageId: "noMutablePropsInterface",
40
31
  data: {
41
32
  propertyName: property.key.name,
42
33
  },
43
- fix: function (fixer) {
44
- var propertyText = sourceCode.getText(property);
45
- return fixer.replaceText(property, "readonly ".concat(propertyText));
34
+ fix: (fixer) => {
35
+ const propertyText = sourceCode.getText(property);
36
+ return fixer.replaceText(property, `readonly ${propertyText}`);
46
37
  },
47
38
  });
48
- };
49
- for (var _i = 0, _a = node.body.body; _i < _a.length; _i++) {
50
- var property = _a[_i];
51
- _loop_1(property);
52
39
  }
53
40
  },
54
41
  };
55
42
  },
56
43
  });
44
+ //# sourceMappingURL=no-mutable-props-interface.mjs.map
@@ -0,0 +1 @@
1
+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QAAQ,EAAE,YAAY,YAAY,EAAE,CAAC,CAAC;wBACjE,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noMutablePublicFields: ESLintUtils.RuleModule<"noMutablePublicFields", [], unknown, ESLintUtils.RuleListener>;
@@ -1,12 +1,6 @@
1
1
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
2
- import { isConstructOrStackType } from "./utils/isConstructOrStackType.mjs";
3
- /**
4
- * Disallow mutable public class fields
5
- * @param context - The rule context provided by ESLint
6
- * @returns An object containing the AST visitor functions
7
- * @see {@link https://eslint-cdk-plugin.dev/rules/no-mutable-public-fields} - Documentation
8
- */
9
- export var noMutablePublicFields = ESLintUtils.RuleCreator.withoutDocs({
2
+ import { isConstructOrStackType } from "./utils/typeCheck.mjs";
3
+ export const noMutablePublicFields = ESLintUtils.RuleCreator.withoutDocs({
10
4
  meta: {
11
5
  type: "problem",
12
6
  docs: {
@@ -19,52 +13,45 @@ export var noMutablePublicFields = ESLintUtils.RuleCreator.withoutDocs({
19
13
  schema: [],
20
14
  },
21
15
  defaultOptions: [],
22
- create: function (context) {
23
- var parserServices = ESLintUtils.getParserServices(context);
24
- var checker = parserServices.program.getTypeChecker();
25
- var sourceCode = context.sourceCode;
16
+ create(context) {
17
+ const parserServices = ESLintUtils.getParserServices(context);
18
+ const typeChecker = parserServices.program.getTypeChecker();
19
+ const sourceCode = context.sourceCode;
26
20
  return {
27
- ClassDeclaration: function (node) {
28
- var _a;
29
- var type = checker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node));
21
+ ClassDeclaration(node) {
22
+ const type = typeChecker.getTypeAtLocation(parserServices.esTreeNodeToTSNodeMap.get(node));
30
23
  if (!isConstructOrStackType(type)) {
31
24
  return;
32
25
  }
33
- var _loop_1 = function (member) {
34
- // NOTE: check property definition
26
+ for (const member of node.body.body) {
35
27
  if (member.type !== AST_NODE_TYPES.PropertyDefinition ||
36
28
  member.key.type !== AST_NODE_TYPES.Identifier) {
37
- return "continue";
29
+ continue;
38
30
  }
39
- // NOTE: Skip private and protected fields
40
- if (["private", "protected"].includes((_a = member.accessibility) !== null && _a !== void 0 ? _a : "")) {
41
- return "continue";
31
+ if (["private", "protected"].includes(member.accessibility ?? "")) {
32
+ continue;
42
33
  }
43
- // NOTE: Skip if readonly is present
44
34
  if (member.readonly)
45
- return "continue";
35
+ continue;
46
36
  context.report({
47
37
  node: member,
48
38
  messageId: "noMutablePublicFields",
49
39
  data: {
50
40
  propertyName: member.key.name,
51
41
  },
52
- fix: function (fixer) {
53
- var accessibility = member.accessibility ? "public " : "";
54
- var paramText = sourceCode.getText(member);
55
- var _a = paramText.split(":"), key = _a[0], value = _a[1];
56
- var replacedKey = key.startsWith("public ")
42
+ fix: (fixer) => {
43
+ const accessibility = member.accessibility ? "public " : "";
44
+ const paramText = sourceCode.getText(member);
45
+ const [key, value] = paramText.split(":");
46
+ const replacedKey = key.startsWith("public ")
57
47
  ? key.replace("public ", "")
58
48
  : key;
59
- return fixer.replaceText(member, "".concat(accessibility, "readonly ").concat(replacedKey, ":").concat(value));
49
+ return fixer.replaceText(member, `${accessibility}readonly ${replacedKey}:${value}`);
60
50
  },
61
51
  });
62
- };
63
- for (var _i = 0, _b = node.body.body; _i < _b.length; _i++) {
64
- var member = _b[_i];
65
- _loop_1(member);
66
52
  }
67
53
  },
68
54
  };
69
55
  },
70
56
  });
57
+ //# sourceMappingURL=no-mutable-public-fields.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-mutable-public-fields.mjs","sourceRoot":"","sources":["../src/no-mutable-public-fields.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;A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wBAClC,IAAI,EAAE;4BACJ,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI;yBAC9B;wBACD,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;4BACb,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;4BAC5D,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;4BAC7C,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BAC1C,MAAM,WAAW,GAAG,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC;gCAC3C,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;gCAC5B,CAAC,CAAC,GAAG,CAAC;4BAER,OAAO,KAAK,CAAC,WAAW,CACtB,MAAM,EACN,GAAG,aAAa,YAAY,WAAW,IAAI,KAAK,EAAE,CACnD,CAAC;wBACJ,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { ESLintUtils } from "@typescript-eslint/utils";
2
+ export declare const noParentNameConstructIdMatch: ESLintUtils.RuleModule<"noParentNameConstructIdMatch", [], unknown, ESLintUtils.RuleListener>;