@amazon-devices/eslint-plugin-kepler 0.1.8 → 0.1.13

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 (28) hide show
  1. package/README.md +139 -16
  2. package/dist/formatters/default.js +8 -189
  3. package/dist/formatters/default.js.LICENSE.txt +1 -0
  4. package/dist/index.js +1 -107
  5. package/package.json +1 -1
  6. package/dist/formatters/KeplerReport.js +0 -40
  7. package/dist/metrics/Metrics.js +0 -69
  8. package/dist/metrics/TelemetryService.js +0 -48
  9. package/dist/rules/apiPrivileges/ApiPrivilegeStateCheck.js +0 -102
  10. package/dist/rules/apiPrivileges/ApiPrivilegesCheck.js +0 -67
  11. package/dist/rules/apiPrivileges/apiPermissionsNeeded.js +0 -58
  12. package/dist/rules/apiPrivileges/manifestHelper.js +0 -44
  13. package/dist/rules/backwardCompatibility/BackwardCompatibility.js +0 -119
  14. package/dist/rules/backwardCompatibility/BackwardCompatibilityCopyOnPack.js +0 -101
  15. package/dist/rules/backwardCompatibility/BackwardCompatibilitySysconfCheck.js +0 -73
  16. package/dist/rules/performance/Animated.js +0 -64
  17. package/dist/rules/performance/CheckSubscription.js +0 -150
  18. package/dist/rules/performance/DetectSplashScreen.js +0 -62
  19. package/dist/rules/performance/DetectUseReportFullyDrawn.js +0 -50
  20. package/dist/rules/performance/FlatList.js +0 -39
  21. package/dist/rules/systemDistributedLibs/SDLPackageVersionCheck.js +0 -136
  22. package/dist/rules/systemDistributedLibs/SDLPackageVersionCheckImports.js +0 -58
  23. package/dist/rules/systemDistributedLibs/sdlHelpers.js +0 -232
  24. package/dist/rules/systemDistributedLibs/sdlRuleMessages.js +0 -25
  25. package/dist/state/KeplerESLintPluginStateManager.js +0 -94
  26. package/dist/utils/Constants.js +0 -40
  27. package/dist/utils/PackageUtils.js +0 -50
  28. package/dist/utils/RuleUtils.js +0 -128
@@ -1,232 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowsMajorUpgrades = allowsMajorUpgrades;
7
- exports.allowsMinorUpgrades = allowsMinorUpgrades;
8
- exports.allowsPatchUpgrades = allowsPatchUpgrades;
9
- exports.determineMinorUpdateMode = determineMinorUpdateMode;
10
- exports.hasGreaterThanOperators = hasGreaterThanOperators;
11
- exports.hasWildcards = hasWildcards;
12
- exports.isLockedOrPartialRange = isLockedOrPartialRange;
13
- exports.isLockedVersion = isLockedVersion;
14
- exports.isSystemDistributedLibrary = isSystemDistributedLibrary;
15
- exports.prohibitsMinorUpgrades = prohibitsMinorUpgrades;
16
- var fs = _interopRequireWildcard(require("fs"));
17
- var path = _interopRequireWildcard(require("path"));
18
- var semver = _interopRequireWildcard(require("semver"));
19
- var _RuleUtils = require("../../utils/RuleUtils");
20
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
21
- // Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
22
- // AMAZON PROPRIETARY/CONFIDENTIAL
23
- // You may not use this file except in compliance with the terms and conditions
24
- // set forth in the accompanying LICENSE.TXT file.
25
- // THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
26
- // DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
27
- // IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
28
- // FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
29
-
30
- /**
31
- * Determines if a given dependency is a System Distributed Library (SDL)
32
- *
33
- * @param dependencyName - The name of the dependency to check (e.g., '@amazon-devices/react-native-kepler')
34
- * @param projectRoot - The root directory of the project (defaults to current working directory)
35
- * @returns true if the dependency is an SDL, false otherwise
36
- */
37
- function isSystemDistributedLibrary(dependencyName, projectRoot = process.cwd()) {
38
- // Check if package has the required namespace
39
- if (!dependencyName.startsWith('@amazon-devices/') && !dependencyName.startsWith('@amazon-devices/')) {
40
- return false;
41
- }
42
-
43
- // Construct path to the package in node_modules
44
- const packagePath = path.join(projectRoot, 'node_modules', dependencyName);
45
-
46
- // Check if the package directory exists
47
- if (!fs.existsSync(packagePath)) {
48
- return false;
49
- }
50
-
51
- // Check if SystemModules folder exists in the package
52
- const systemModulesPath = path.join(packagePath, 'SystemModules');
53
- try {
54
- return fs.existsSync(systemModulesPath) && fs.statSync(systemModulesPath).isDirectory();
55
- } catch {
56
- return false;
57
- }
58
- }
59
-
60
- /**
61
- * Checks if a version string contains wildcards
62
- */
63
- function hasWildcards(version) {
64
- return version.includes('*') || version.includes('x') || version.includes('X');
65
- }
66
-
67
- /**
68
- * Checks if a version string uses greater-than operators
69
- */
70
- function hasGreaterThanOperators(version) {
71
- return version.startsWith('>') || version.startsWith('>=');
72
- }
73
-
74
- /**
75
- * Checks if a version string is completely locked (no prefix)
76
- */
77
- function isLockedVersion(version) {
78
- return !version.startsWith('^') && !version.startsWith('~') && !version.startsWith('<') && !version.startsWith('>') && !version.startsWith('>=') && !hasWildcards(version);
79
- }
80
-
81
- /**
82
- * Checks if a version range allows patch upgrades only using semver
83
- * Examples: ~5.0.0, <5.1.0, 5.0.x
84
- */
85
- function allowsPatchUpgrades(versionRange) {
86
- try {
87
- // Handle x/X wildcards for patch-only (e.g., "5.0.x")
88
- if (/^\d+\.\d+\.[xX]$/.test(versionRange)) {
89
- return true;
90
- }
91
-
92
- // Handle tilde ranges (patch-only)
93
- if (versionRange.startsWith('~')) {
94
- const cleanRange = versionRange.substring(1);
95
- const parsed = semver.parse(cleanRange);
96
- return parsed !== null;
97
- }
98
-
99
- // Handle < operator - check if it constrains to patch-only
100
- if (versionRange.startsWith('<')) {
101
- const targetVersion = versionRange.substring(1);
102
- const parsed = semver.parse(targetVersion);
103
- if (parsed) {
104
- // If target is X.Y.Z where Z > 0, it allows patches within X.Y
105
- return parsed.patch > 0;
106
- }
107
- }
108
- return false;
109
- } catch {
110
- return false;
111
- }
112
- }
113
-
114
- /**
115
- * Checks if a version range allows minor upgrades using semver
116
- * Examples: ^5.0.0, <6.0.0, 5.x.x
117
- */
118
- function allowsMinorUpgrades(versionRange) {
119
- try {
120
- // Handle x/X wildcards for minor (e.g., "5.x.x", "5.x")
121
- if (/^\d+\.[xX](\.[xX])?$/.test(versionRange)) {
122
- return true;
123
- }
124
-
125
- // Handle caret ranges (minor + patch)
126
- if (versionRange.startsWith('^')) {
127
- const cleanRange = versionRange.substring(1);
128
- const parsed = semver.parse(cleanRange);
129
- return parsed !== null;
130
- }
131
-
132
- // Handle < operator - check if it allows minor within major
133
- if (versionRange.startsWith('<')) {
134
- const targetVersion = versionRange.substring(1);
135
- const parsed = semver.parse(targetVersion);
136
- if (parsed) {
137
- // If target is X.0.0 where X > 1, it allows minor upgrades within previous major
138
- return parsed.minor === 0 && parsed.patch === 0 && parsed.major > 1;
139
- }
140
- }
141
- return false;
142
- } catch {
143
- return false;
144
- }
145
- }
146
-
147
- /**
148
- * Checks if a version range allows major upgrades using semver
149
- * Examples: *, >5.0.0, >=5.0.0
150
- */
151
- function allowsMajorUpgrades(versionRange) {
152
- try {
153
- // Wildcard allows everything
154
- if (versionRange === '*') {
155
- return true;
156
- }
157
-
158
- // Major wildcards (e.g., "1.*")
159
- if (/^\d+\.\*$/.test(versionRange)) {
160
- return true;
161
- }
162
-
163
- // Greater than operators allow major upgrades
164
- if (versionRange.startsWith('>')) {
165
- return true;
166
- }
167
- return false;
168
- } catch {
169
- return false;
170
- }
171
- }
172
-
173
- /**
174
- * Checks if a version range prohibits minor upgrades (only allows patches)
175
- * Used for minor upgrade mode validation
176
- */
177
- function prohibitsMinorUpgrades(versionRange) {
178
- return allowsPatchUpgrades(versionRange) && !allowsMinorUpgrades(versionRange);
179
- }
180
-
181
- /**
182
- * Checks if a version is locked (exact version) or uses partial ranges using semver
183
- * Examples: 2.0.0, 2.0.0-2.0.5
184
- */
185
- function isLockedOrPartialRange(versionRange) {
186
- try {
187
- // Check for hyphen ranges (e.g., "2.0.0-2.0.5")
188
- if (versionRange.includes('-') && !versionRange.startsWith('-')) {
189
- const parts = versionRange.split('-');
190
- if (parts.length === 2) {
191
- const start = parts[0].trim();
192
- const end = parts[1].trim();
193
- const startValid = semver.valid(start) !== null && !start.includes('-');
194
- const endValid = semver.valid(end) !== null && !end.includes('-');
195
- return startValid && endValid;
196
- }
197
- }
198
-
199
- // Check for exact version (no operators or wildcards)
200
- if (isLockedVersion(versionRange)) {
201
- const parsed = semver.parse(versionRange);
202
- return parsed !== null && !parsed.prerelease.length;
203
- }
204
- return false;
205
- } catch {
206
- return false;
207
- }
208
- }
209
-
210
- /**
211
- * Determines the minor upgrade mode based on configuration parameter
212
- *
213
- * @param semverMode - Configuration value: "patch", "minor", "auto"
214
- * @param projectRoot - The root directory of the project (defaults to current working directory)
215
- * @returns true if minor version mode should be enabled, false otherwise
216
- */
217
- function determineMinorUpdateMode(semverMode = 'auto', projectRoot = process.cwd()) {
218
- switch (semverMode) {
219
- case 'minor':
220
- return true;
221
- case 'patch':
222
- return false;
223
- case 'auto':
224
- try {
225
- return (0, _RuleUtils.isBrazilRepo)();
226
- } catch {
227
- return false;
228
- }
229
- default:
230
- return false;
231
- }
232
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.WILDCARD_VERSION_ERROR = exports.SBL_IMPORT_MESSAGE = exports.PROHIBITS_MINOR_WARNING = exports.MINOR_UPGRADE_MODE_WILDCARD_WARNING = exports.MINOR_UPGRADE_MODE_LOCKED_VERSION_WARNING = exports.MINOR_OR_MAJOR_UPGRADE_WARNING = exports.MAJOR_UPGRADE_WARNING = exports.LOCKED_VERSION_WARNING = exports.GREATER_THAN_VERSION_ERROR = void 0;
7
- var _Constants = require("../../utils/Constants");
8
- // Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
9
- // AMAZON PROPRIETARY/CONFIDENTIAL
10
- // You may not use this file except in compliance with the terms and conditions
11
- // set forth in the accompanying LICENSE.TXT file.
12
- // THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
13
- // DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
14
- // IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
16
-
17
- const MINOR_OR_MAJOR_UPGRADE_WARNING = exports.MINOR_OR_MAJOR_UPGRADE_WARNING = 'Allowing minor or major version upgrades for system distributed libraries may result in unpredictable behavior or incompatibility with Vega devices in the field that have not upgraded. It is strongly recommended to specify patch versions only using "~" or "<" in the semantic version.';
18
- const MAJOR_UPGRADE_WARNING = exports.MAJOR_UPGRADE_WARNING = 'Allowing major version upgrades for system distributed libraries may cause breaking changes. For pre-release development, it is strongly recommended to allow minor upgrades only using "^" in the semantic version.';
19
- const PROHIBITS_MINOR_WARNING = exports.PROHIBITS_MINOR_WARNING = 'Prohibiting minor upgrades for system distributed libraries may result in this app becoming unusable after an OS upgrade. It is strongly recommended you allow for minor and patch versions by using "^" in the semantic version.';
20
- const GREATER_THAN_VERSION_ERROR = exports.GREATER_THAN_VERSION_ERROR = 'Using ">" or ">=" operators for system distributed libraries may cause backwards compatibility issues. Use "~" to allow patch updates (recommended) or "^" to allow minor version updates (for pre-release development) instead.';
21
- const WILDCARD_VERSION_ERROR = exports.WILDCARD_VERSION_ERROR = 'Wildcard versions for system distributed libraries is strongly discouraged as this can result in app instability or failure to launch. Use "~" for patch updates or "<" for specific version ranges instead.';
22
- const MINOR_UPGRADE_MODE_WILDCARD_WARNING = exports.MINOR_UPGRADE_MODE_WILDCARD_WARNING = 'Use "^" for minor updates instead of wildcards for system distributed libraries to prevent app instability or failure to launch.';
23
- const LOCKED_VERSION_WARNING = exports.LOCKED_VERSION_WARNING = 'Locking semantic versions of system distributed packages may result in this app becoming unusable after an OS upgrade. It is strongly recommended you allow for patch versions by using ~ or < in the semantic version.';
24
- const MINOR_UPGRADE_MODE_LOCKED_VERSION_WARNING = exports.MINOR_UPGRADE_MODE_LOCKED_VERSION_WARNING = 'Locking semantic versions of system distributed packages will result in this app becoming unusable after an OS upgrade. For pre-release development, it is strongly recommended you allow for minor and patch versions by using ^ in the semantic version.';
25
- const SBL_IMPORT_MESSAGE = exports.SBL_IMPORT_MESSAGE = `is a system distributed library. This is not an error. However, please see the React Native for Vega documentation for important information on system distributed libraries (${_Constants.VEGA_DOC_BASE_URL}/vega-rn-arch.html). Please see the documentation for this plugin for how to turn this warning off once you understand the implications of system distributed libraries.`;
@@ -1,94 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.KeplerESLintPluginStateManager = void 0;
7
- var fs = _interopRequireWildcard(require("fs"));
8
- var path = _interopRequireWildcard(require("path"));
9
- var _Constants = require("../utils/Constants");
10
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
- // Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
12
- // AMAZON PROPRIETARY/CONFIDENTIAL
13
- // You may not use this file except in compliance with the terms and conditions
14
- // set forth in the accompanying LICENSE.TXT file.
15
- // THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
16
- // DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
17
- // IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
18
- // FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
19
-
20
- const KEPLER_ESLINT_STATE_FILE_PATH = path.join(_Constants.KEPLER_ESLINT_OUTPUT_DIR_PATH, 'keplerESLintState.json');
21
- /**
22
- * Singleton class to maintain global state for ESLint Plugin and persist it to file.
23
- */
24
- class KeplerESLintPluginStateManager {
25
- constructor() {
26
- this.keplerESLintState = {
27
- fullyDrawn: {
28
- useReportFullyDrawnFound: false
29
- },
30
- splashScreen: {
31
- usePreventHideSplashScreenFound: false,
32
- useHideSplashScreenCallbackFound: false
33
- }
34
- };
35
- }
36
- static getInstance() {
37
- if (!KeplerESLintPluginStateManager.instance) {
38
- KeplerESLintPluginStateManager.instance = new KeplerESLintPluginStateManager();
39
- }
40
- return KeplerESLintPluginStateManager.instance;
41
- }
42
-
43
- /**
44
- * Initialize the state management, such as persistent storages.
45
- *
46
- * This method must be invoked on the starting ESLint process.
47
- */
48
- initialize() {
49
- if (!fs.existsSync(_Constants.KEPLER_ESLINT_OUTPUT_DIR_PATH)) {
50
- fs.mkdirSync(_Constants.KEPLER_ESLINT_OUTPUT_DIR_PATH, {
51
- recursive: true
52
- });
53
- }
54
- this.persistKeplerAnalyzerState();
55
- }
56
- setKeplerESLintState(newState) {
57
- this.keplerESLintState = newState;
58
- this.persistKeplerAnalyzerState();
59
- }
60
- getKeplerESLintState() {
61
- return this.keplerESLintState;
62
- }
63
- persistKeplerAnalyzerState() {
64
- fs.writeFileSync(KEPLER_ESLINT_STATE_FILE_PATH, JSON.stringify(this.keplerESLintState), 'utf8');
65
- }
66
-
67
- /**
68
- * Reads Kepler ESLint state from file.
69
- * @returns
70
- */
71
- static readKeplerESLintState() {
72
- let keplerESLintState = undefined;
73
- try {
74
- keplerESLintState = JSON.parse(fs.readFileSync(KEPLER_ESLINT_STATE_FILE_PATH, 'utf8'));
75
- } catch (err) {
76
- console.error(err);
77
- }
78
- return keplerESLintState;
79
- }
80
-
81
- /**
82
- * Deletes Kepler ESLint state file.
83
- * @returns
84
- */
85
- static cleanUpKeplerESLintState() {
86
- try {
87
- fs.rmSync(_Constants.KEPLER_ESLINT_OUTPUT_DIR_PATH);
88
- } catch (err) {
89
- console.error(`Error deleting ${_Constants.KEPLER_ESLINT_OUTPUT_DIR_PATH}`);
90
- console.error(err);
91
- }
92
- }
93
- }
94
- exports.KeplerESLintPluginStateManager = KeplerESLintPluginStateManager;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.VEGA_DOC_BASE_URL = exports.VEGA_BEST_PRACTICE_URL = exports.UNKNOWN = exports.REACT_DOC_BASE_URL = exports.PROJECT_DIR_PATH = exports.KeplerESLintRuleIds = exports.KEPLER_ESLINT_RULE_PREFIX = exports.KEPLER_ESLINT_OUTPUT_DIR_PATH = exports.ICON_WARN = exports.ICON_ERROR = exports.ESLintRuleSeverity = exports.DOC_BASE_URL = void 0;
7
- var path = _interopRequireWildcard(require("path"));
8
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
9
- // Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
10
- // AMAZON PROPRIETARY/CONFIDENTIAL
11
- // You may not use this file except in compliance with the terms and conditions
12
- // set forth in the accompanying LICENSE.TXT file.
13
- // THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
14
- // DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
15
- // IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
16
- // FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17
- let KeplerESLintRuleIds = exports.KeplerESLintRuleIds = /*#__PURE__*/function (KeplerESLintRuleIds) {
18
- KeplerESLintRuleIds["FlatList"] = "@amazon-devices/kepler/flat-list";
19
- KeplerESLintRuleIds["Animated"] = "@amazon-devices/kepler/animated";
20
- KeplerESLintRuleIds["NoComplexScrollView"] = "@amazon-devices/kepler/no-complex-scroll-view";
21
- KeplerESLintRuleIds["DetectReportFullyDrawn"] = "@amazon-devices/kepler/detect-report-fully-drawn";
22
- KeplerESLintRuleIds["DetectSplashScreen"] = "@amazon-devices/kepler/detect-splash-screen";
23
- return KeplerESLintRuleIds;
24
- }({});
25
- let ESLintRuleSeverity = exports.ESLintRuleSeverity = /*#__PURE__*/function (ESLintRuleSeverity) {
26
- ESLintRuleSeverity[ESLintRuleSeverity["OFF"] = 0] = "OFF";
27
- ESLintRuleSeverity[ESLintRuleSeverity["WARNING"] = 1] = "WARNING";
28
- ESLintRuleSeverity[ESLintRuleSeverity["ERROR"] = 2] = "ERROR";
29
- return ESLintRuleSeverity;
30
- }({});
31
- const PROJECT_DIR_PATH = exports.PROJECT_DIR_PATH = process.cwd();
32
- const KEPLER_ESLINT_OUTPUT_DIR_PATH = exports.KEPLER_ESLINT_OUTPUT_DIR_PATH = path.join(PROJECT_DIR_PATH, 'generated', 'eslint-plugin-kepler');
33
- const ICON_WARN = exports.ICON_WARN = '⚠️';
34
- const ICON_ERROR = exports.ICON_ERROR = '❌';
35
- const KEPLER_ESLINT_RULE_PREFIX = exports.KEPLER_ESLINT_RULE_PREFIX = '@amazon-devices/kepler';
36
- const UNKNOWN = exports.UNKNOWN = 'UNKNOWN';
37
- const DOC_BASE_URL = exports.DOC_BASE_URL = 'https://developer.amazon.com/docs';
38
- const REACT_DOC_BASE_URL = exports.REACT_DOC_BASE_URL = `${DOC_BASE_URL}/react-native-vega/0.72`;
39
- const VEGA_DOC_BASE_URL = exports.VEGA_DOC_BASE_URL = `${DOC_BASE_URL}/vega/0.21`;
40
- const VEGA_BEST_PRACTICE_URL = exports.VEGA_BEST_PRACTICE_URL = `${VEGA_DOC_BASE_URL}/best_practices.html`;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAppManifest = getAppManifest;
7
- exports.getKeplerESLintPackageJson = getKeplerESLintPackageJson;
8
- var fs = _interopRequireWildcard(require("fs"));
9
- var path = _interopRequireWildcard(require("path"));
10
- var toml = _interopRequireWildcard(require("toml"));
11
- var package_json = _interopRequireWildcard(require("../../package.json"));
12
- var _Constants = require("./Constants");
13
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
- /* eslint-disable @typescript-eslint/no-explicit-any */
15
- // Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
16
- // AMAZON PROPRIETARY/CONFIDENTIAL
17
- // You may not use this file except in compliance with the terms and conditions
18
- // set forth in the accompanying LICENSE.TXT file.
19
- // THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
20
- // DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
21
- // IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
22
- // FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
23
-
24
- let PROJECT_MANIFEST_JSON = undefined;
25
- const MANIFEST_TOML = 'manifest.toml';
26
-
27
- /**
28
- * Returns the manifest.toml of the project on which eslint is executed.
29
- * @returns manifest.toml file as a JSON object
30
- */
31
- function getAppManifest() {
32
- if (PROJECT_MANIFEST_JSON) {
33
- return PROJECT_MANIFEST_JSON;
34
- }
35
- try {
36
- const fileData = fs.readFileSync(path.join(_Constants.PROJECT_DIR_PATH, MANIFEST_TOML), 'utf8');
37
- PROJECT_MANIFEST_JSON = toml.parse(fileData);
38
- } catch (err) {
39
- return undefined;
40
- }
41
- return PROJECT_MANIFEST_JSON;
42
- }
43
-
44
- /**
45
- * Returns the package.json of eslint-plugin-kepler.
46
- * @returns package.json file as a JSON object
47
- */
48
- function getKeplerESLintPackageJson() {
49
- return package_json;
50
- }
@@ -1,128 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isAliasCall = isAliasCall;
7
- exports.isBrazilRepo = void 0;
8
- exports.isDirectCall = isDirectCall;
9
- exports.isFunctionAssignedToVariable = isFunctionAssignedToVariable;
10
- exports.isModuleFunctionAssignedToVariable = isModuleFunctionAssignedToVariable;
11
- exports.isNamespacedCall = isNamespacedCall;
12
- exports.isSDLProject = void 0;
13
- var fs = _interopRequireWildcard(require("fs"));
14
- var path = _interopRequireWildcard(require("path"));
15
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
- // Copyright 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
17
- // AMAZON PROPRIETARY/CONFIDENTIAL
18
- // You may not use this file except in compliance with the terms and conditions
19
- // set forth in the accompanying LICENSE.TXT file.
20
- // THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS. AMAZON SPECIFICALLY
21
- // DISCLAIMS, WITH RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS,
22
- // IMPLIED, OR STATUTORY, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY,
23
- // FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
24
-
25
- const NODE_TYPE_IDENTIFIER = 'Identifier';
26
- const NODE_TYPE_MEMBER_EXPRESSION = 'MemberExpression';
27
-
28
- /**
29
- * Returns true if the provided function is assigned to a variable.
30
- * e.g.
31
- * import { useReportFullyDrawn } from '@amazon-devices/kepler-performance-api';
32
- * const reportFullyDrawn = useReportFullyDrawn;
33
- * @param node
34
- * @param functionName
35
- * @returns
36
- */
37
- function isFunctionAssignedToVariable(node, functionName) {
38
- if (node.init?.type === NODE_TYPE_IDENTIFIER && node.init.name === functionName) {
39
- if (node.id.type === NODE_TYPE_IDENTIFIER) {
40
- return true;
41
- }
42
- }
43
- return false;
44
- }
45
-
46
- /**
47
- * Returns true if the provided function accessed through module, is assigned to a variable
48
- * e.g.
49
- * import * as keplerPerfModule from '@amazon-devices/kepler-performance-api';
50
- * const reportFullyDrawn = keplerPerfModule.useReportFullyDrawn;
51
- * @param node
52
- * @param functionName
53
- * @returns
54
- */
55
- function isModuleFunctionAssignedToVariable(node, functionName) {
56
- if (node.init?.type === NODE_TYPE_MEMBER_EXPRESSION && node.init.property.type === NODE_TYPE_IDENTIFIER && node.init.property.name === functionName) {
57
- if (node.id.type === NODE_TYPE_IDENTIFIER) {
58
- return true;
59
- }
60
- }
61
- return false;
62
- }
63
-
64
- /**
65
- * Checks if a function call is a direct call to the function.
66
- * e.g.
67
- * import { useReportFullyDrawn } from '@amazon-devices/kepler-performance-api';
68
- * useReportFullyDrawn();
69
- * @param node
70
- * @param functionName
71
- * @returns
72
- */
73
- function isDirectCall(node, functionName) {
74
- return node.callee.type === NODE_TYPE_IDENTIFIER && node.callee.name === functionName;
75
- }
76
-
77
- /**
78
- * Checks if a function call is an alias call to the function.
79
- * e.g.
80
- * a)
81
- * import { useReportFullyDrawn } from '@amazon-devices/kepler-performance-api';
82
- * const reportFullyDrawn = useReportFullyDrawn;
83
- * reportFullyDrawn();
84
- *
85
- * b)
86
- * import * as keplerPerfModule from '@amazon-devices/kepler-performance-api';
87
- * const reportFullyDrawn = keplerPerfModule.useReportFullyDrawn;
88
- * reportFullyDrawn();
89
- *
90
- * @param node
91
- * @param functionName
92
- * @param aliases
93
- * @returns
94
- */
95
- function isAliasCall(node, functionName, aliases) {
96
- return node.callee.type === NODE_TYPE_IDENTIFIER && aliases.has(node.callee.name);
97
- }
98
-
99
- /**
100
- * Checks if a function call is a namespaced call to the function.
101
- * e.g.
102
- * import * as keplerPerfModule from '@amazon-devices/kepler-performance-api';
103
- * keplerPerfModule.useReportFullyDrawn();
104
- * @param node
105
- * @param functionName
106
- * @returns
107
- */
108
- function isNamespacedCall(node, functionName) {
109
- return node.callee.type === NODE_TYPE_MEMBER_EXPRESSION && node.callee.property.type === NODE_TYPE_IDENTIFIER && node.callee.property.name === functionName;
110
- }
111
- const fileExists = (fileName, projectRoot = process.cwd()) => {
112
- const configPath = path.join(projectRoot, fileName);
113
- return fs.existsSync(configPath);
114
- };
115
-
116
- /**
117
- * Checks if the current repository is a Brazil repository by looking for a Config file in the root folder.
118
- * @returns true if Config file exists in root, false otherwise
119
- */
120
- const isBrazilRepo = () => fileExists('Config');
121
-
122
- /**
123
- * Checks if the current repository is a Vega SDL project by looking for kepler-system-conf.toml file in the root folder.
124
- * @returns true if kepler-system-conf.toml file exists in root, false otherwise
125
- */
126
- exports.isBrazilRepo = isBrazilRepo;
127
- const isSDLProject = () => fileExists('kepler-system-conf.toml');
128
- exports.isSDLProject = isSDLProject;