@amazon-devices/eslint-plugin-kepler 0.1.8 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -11
- package/dist/formatters/default.js +8 -189
- package/dist/formatters/default.js.LICENSE.txt +1 -0
- package/dist/index.js +1 -107
- package/package.json +1 -1
- package/dist/formatters/KeplerReport.js +0 -40
- package/dist/metrics/Metrics.js +0 -69
- package/dist/metrics/TelemetryService.js +0 -48
- package/dist/rules/apiPrivileges/ApiPrivilegeStateCheck.js +0 -102
- package/dist/rules/apiPrivileges/ApiPrivilegesCheck.js +0 -67
- package/dist/rules/apiPrivileges/apiPermissionsNeeded.js +0 -58
- package/dist/rules/apiPrivileges/manifestHelper.js +0 -44
- package/dist/rules/backwardCompatibility/BackwardCompatibility.js +0 -119
- package/dist/rules/backwardCompatibility/BackwardCompatibilityCopyOnPack.js +0 -101
- package/dist/rules/backwardCompatibility/BackwardCompatibilitySysconfCheck.js +0 -73
- package/dist/rules/performance/Animated.js +0 -64
- package/dist/rules/performance/CheckSubscription.js +0 -150
- package/dist/rules/performance/DetectSplashScreen.js +0 -62
- package/dist/rules/performance/DetectUseReportFullyDrawn.js +0 -50
- package/dist/rules/performance/FlatList.js +0 -39
- package/dist/rules/systemDistributedLibs/SDLPackageVersionCheck.js +0 -136
- package/dist/rules/systemDistributedLibs/SDLPackageVersionCheckImports.js +0 -58
- package/dist/rules/systemDistributedLibs/sdlHelpers.js +0 -232
- package/dist/rules/systemDistributedLibs/sdlRuleMessages.js +0 -25
- package/dist/state/KeplerESLintPluginStateManager.js +0 -94
- package/dist/utils/Constants.js +0 -40
- package/dist/utils/PackageUtils.js +0 -50
- package/dist/utils/RuleUtils.js +0 -128
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DetectUseReportFullyDrawn = void 0;
|
|
7
|
-
var _KeplerESLintPluginStateManager = require("../../state/KeplerESLintPluginStateManager");
|
|
8
|
-
var _RuleUtils = require("../../utils/RuleUtils");
|
|
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
|
-
|
|
18
|
-
const USE_REPORT_FULLY_DRAWN_FUNCTION_NAME = 'useReportFullyDrawn';
|
|
19
|
-
const DetectUseReportFullyDrawn = exports.DetectUseReportFullyDrawn = {
|
|
20
|
-
meta: {
|
|
21
|
-
type: 'suggestion',
|
|
22
|
-
docs: {
|
|
23
|
-
description: 'useReportFullyDrawn() callback should be used to measure Time to Fully Drawn',
|
|
24
|
-
recommended: true,
|
|
25
|
-
category: 'Performance'
|
|
26
|
-
},
|
|
27
|
-
fixable: 'code',
|
|
28
|
-
schema: []
|
|
29
|
-
},
|
|
30
|
-
create(context) {
|
|
31
|
-
const useReportFullyDrawnAliases = new Set();
|
|
32
|
-
return {
|
|
33
|
-
VariableDeclarator(node) {
|
|
34
|
-
if ((0, _RuleUtils.isFunctionAssignedToVariable)(node, USE_REPORT_FULLY_DRAWN_FUNCTION_NAME)) {
|
|
35
|
-
useReportFullyDrawnAliases.add(node.id['name']);
|
|
36
|
-
}
|
|
37
|
-
if ((0, _RuleUtils.isModuleFunctionAssignedToVariable)(node, USE_REPORT_FULLY_DRAWN_FUNCTION_NAME)) {
|
|
38
|
-
useReportFullyDrawnAliases.add(node.id['name']);
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
CallExpression(node) {
|
|
42
|
-
if ((0, _RuleUtils.isDirectCall)(node, USE_REPORT_FULLY_DRAWN_FUNCTION_NAME) || (0, _RuleUtils.isAliasCall)(node, USE_REPORT_FULLY_DRAWN_FUNCTION_NAME, useReportFullyDrawnAliases) || (0, _RuleUtils.isNamespacedCall)(node, USE_REPORT_FULLY_DRAWN_FUNCTION_NAME)) {
|
|
43
|
-
const keplerESLintState = _KeplerESLintPluginStateManager.KeplerESLintPluginStateManager.getInstance().getKeplerESLintState();
|
|
44
|
-
keplerESLintState.fullyDrawn.useReportFullyDrawnFound = true;
|
|
45
|
-
_KeplerESLintPluginStateManager.KeplerESLintPluginStateManager.getInstance().setKeplerESLintState(keplerESLintState);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.FlatList = void 0;
|
|
7
|
-
var _Constants = require("../../utils/Constants");
|
|
8
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
9
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
10
|
-
|
|
11
|
-
const FLATLIST_PERF_REQD_PROPS = ['initialNumToRender', 'windowSize', 'removeClippedSubviews', 'maxToRenderPerBatch', 'updateCellsBatchingPeriod'];
|
|
12
|
-
const FlatList = exports.FlatList = {
|
|
13
|
-
meta: {
|
|
14
|
-
type: 'suggestion',
|
|
15
|
-
docs: {
|
|
16
|
-
description: 'FlatList causes performance overhead and should be used carefully',
|
|
17
|
-
recommended: true,
|
|
18
|
-
category: 'Performance'
|
|
19
|
-
},
|
|
20
|
-
fixable: 'code',
|
|
21
|
-
schema: []
|
|
22
|
-
},
|
|
23
|
-
create(context) {
|
|
24
|
-
return {
|
|
25
|
-
JSXOpeningElement(node) {
|
|
26
|
-
if (node.name.name === 'FlatList') {
|
|
27
|
-
const currentFlatListPropNames = node.attributes.map(attr => attr.name.name);
|
|
28
|
-
const missingProps = FLATLIST_PERF_REQD_PROPS.filter(prop => !currentFlatListPropNames.includes(prop));
|
|
29
|
-
if (missingProps.length > 0) {
|
|
30
|
-
context.report({
|
|
31
|
-
node,
|
|
32
|
-
message: `FlatList missing props: '${missingProps}'. FlatList performance is not fully unlocked without these props. ` + `See ${_Constants.VEGA_BEST_PRACTICE_URL}#flatlist for more.`
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SDLPackageVersionCheck = void 0;
|
|
7
|
-
var _sdlHelpers = require("./sdlHelpers");
|
|
8
|
-
var _sdlRuleMessages = require("./sdlRuleMessages");
|
|
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
|
-
|
|
18
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */ // ESLint Rule API uses complex inferred types
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */ // AST node types are complex, using any for simplicity
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* ESLint rule to validate SDL package versions in package.json
|
|
23
|
-
*/
|
|
24
|
-
const SDLPackageVersionCheck = exports.SDLPackageVersionCheck = {
|
|
25
|
-
meta: {
|
|
26
|
-
type: 'problem',
|
|
27
|
-
docs: {
|
|
28
|
-
description: 'Validates that SDL dependencies use proper semantic versioning with ~ or < prefixes',
|
|
29
|
-
recommended: true,
|
|
30
|
-
category: 'System Distributed Libraries'
|
|
31
|
-
},
|
|
32
|
-
schema: [{
|
|
33
|
-
type: 'object',
|
|
34
|
-
properties: {
|
|
35
|
-
semverGuidance: {
|
|
36
|
-
oneOf: [{
|
|
37
|
-
type: 'string',
|
|
38
|
-
enum: ['minor', 'patch', 'auto']
|
|
39
|
-
}]
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
additionalProperties: false
|
|
43
|
-
}]
|
|
44
|
-
},
|
|
45
|
-
create(context) {
|
|
46
|
-
const options = context.options[0] || {};
|
|
47
|
-
const isMinorUpgradeMode = (0, _sdlHelpers.determineMinorUpdateMode)(options.semverGuidance);
|
|
48
|
-
return {
|
|
49
|
-
JSONProperty(node) {
|
|
50
|
-
// Only check properties in dependencies and peerDependencies
|
|
51
|
-
const parent = node.parent;
|
|
52
|
-
if (parent?.type === 'JSONObjectExpression' && parent.parent?.type === 'JSONProperty') {
|
|
53
|
-
const grandParent = parent.parent;
|
|
54
|
-
if (grandParent.key?.type === 'JSONLiteral') {
|
|
55
|
-
const sectionName = grandParent.key.value;
|
|
56
|
-
if (['dependencies', 'peerDependencies'].includes(sectionName)) {
|
|
57
|
-
// Check if this property is an SDL package
|
|
58
|
-
if (node.key?.type === 'JSONLiteral' && node.value?.type === 'JSONLiteral') {
|
|
59
|
-
const packageName = node.key.value;
|
|
60
|
-
const version = node.value.value;
|
|
61
|
-
const isSDLPackage = (0, _sdlHelpers.isSystemDistributedLibrary)(packageName);
|
|
62
|
-
if (isSDLPackage && typeof version === 'string') {
|
|
63
|
-
// Check for greater-than operators (error in both modes)
|
|
64
|
-
if ((0, _sdlHelpers.hasGreaterThanOperators)(version)) {
|
|
65
|
-
context.report({
|
|
66
|
-
node: node.value,
|
|
67
|
-
message: _sdlRuleMessages.GREATER_THAN_VERSION_ERROR
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Check for wildcards - but allow patch-only wildcards like "2.0.x"
|
|
73
|
-
if ((0, _sdlHelpers.hasWildcards)(version)) {
|
|
74
|
-
// If it's a patch-only wildcard, it's allowed in conservative mode
|
|
75
|
-
if (!(0, _sdlHelpers.allowsPatchUpgrades)(version)) {
|
|
76
|
-
if (isMinorUpgradeMode) {
|
|
77
|
-
context.report({
|
|
78
|
-
node: node.value,
|
|
79
|
-
message: _sdlRuleMessages.MINOR_UPGRADE_MODE_WILDCARD_WARNING
|
|
80
|
-
});
|
|
81
|
-
} else {
|
|
82
|
-
context.report({
|
|
83
|
-
node: node.value,
|
|
84
|
-
message: _sdlRuleMessages.WILDCARD_VERSION_ERROR
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Check for locked versions or partial ranges (flagged in both modes)
|
|
92
|
-
if ((0, _sdlHelpers.isLockedOrPartialRange)(version)) {
|
|
93
|
-
if (isMinorUpgradeMode) {
|
|
94
|
-
context.report({
|
|
95
|
-
node: node.value,
|
|
96
|
-
message: _sdlRuleMessages.MINOR_UPGRADE_MODE_LOCKED_VERSION_WARNING
|
|
97
|
-
});
|
|
98
|
-
} else {
|
|
99
|
-
context.report({
|
|
100
|
-
node: node.value,
|
|
101
|
-
message: _sdlRuleMessages.LOCKED_VERSION_WARNING
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (isMinorUpgradeMode) {
|
|
107
|
-
// Pre-release mode: flag major upgrades or prohibiting minor upgrades
|
|
108
|
-
if ((0, _sdlHelpers.allowsMajorUpgrades)(version)) {
|
|
109
|
-
context.report({
|
|
110
|
-
node: node.value,
|
|
111
|
-
message: _sdlRuleMessages.MAJOR_UPGRADE_WARNING
|
|
112
|
-
});
|
|
113
|
-
} else if ((0, _sdlHelpers.prohibitsMinorUpgrades)(version)) {
|
|
114
|
-
context.report({
|
|
115
|
-
node: node.value,
|
|
116
|
-
message: _sdlRuleMessages.PROHIBITS_MINOR_WARNING
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
// Conservative mode: flag minor or major upgrades
|
|
121
|
-
if ((0, _sdlHelpers.allowsMinorUpgrades)(version) || (0, _sdlHelpers.allowsMajorUpgrades)(version)) {
|
|
122
|
-
context.report({
|
|
123
|
-
node: node.value,
|
|
124
|
-
message: _sdlRuleMessages.MINOR_OR_MAJOR_UPGRADE_WARNING
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SDLPackageVersionCheckImports = void 0;
|
|
7
|
-
var _sdlHelpers = require("./sdlHelpers");
|
|
8
|
-
var _sdlRuleMessages = require("./sdlRuleMessages");
|
|
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
|
-
|
|
18
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */ // ESLint Rule API uses complex inferred types
|
|
19
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */ // AST node types are complex, using any for simplicity
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* ESLint rule to flag imports of system distributed libraries
|
|
23
|
-
*/
|
|
24
|
-
const SDLPackageVersionCheckImports = exports.SDLPackageVersionCheckImports = {
|
|
25
|
-
meta: {
|
|
26
|
-
type: 'suggestion',
|
|
27
|
-
docs: {
|
|
28
|
-
description: 'Flags imports of system distributed libraries with informational messages',
|
|
29
|
-
recommended: true,
|
|
30
|
-
category: 'System Distributed Libraries'
|
|
31
|
-
},
|
|
32
|
-
schema: [{
|
|
33
|
-
type: 'object',
|
|
34
|
-
properties: {
|
|
35
|
-
semverGuidance: {
|
|
36
|
-
oneOf: [{
|
|
37
|
-
type: 'string',
|
|
38
|
-
enum: ['minor', 'patch', 'auto']
|
|
39
|
-
}]
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
additionalProperties: false
|
|
43
|
-
}]
|
|
44
|
-
},
|
|
45
|
-
create(context) {
|
|
46
|
-
return {
|
|
47
|
-
ImportDeclaration(node) {
|
|
48
|
-
const importSource = node.source.value;
|
|
49
|
-
if ((0, _sdlHelpers.isSystemDistributedLibrary)(importSource)) {
|
|
50
|
-
context.report({
|
|
51
|
-
node: node.source,
|
|
52
|
-
message: `${importSource} ${_sdlRuleMessages.SBL_IMPORT_MESSAGE}`
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -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;
|