@amazon-devices/eslint-plugin-kepler 0.1.4 → 0.1.8
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 +198 -23
- package/dist/formatters/KeplerReport.js +40 -0
- package/dist/formatters/default.js +189 -8
- package/dist/index.js +107 -1
- package/dist/metrics/Metrics.js +69 -0
- package/dist/metrics/TelemetryService.js +48 -0
- package/dist/rules/apiPrivileges/ApiPrivilegeStateCheck.js +102 -0
- package/dist/rules/apiPrivileges/ApiPrivilegesCheck.js +67 -0
- package/dist/rules/apiPrivileges/apiPermissionsNeeded.js +58 -0
- package/dist/rules/apiPrivileges/manifestHelper.js +44 -0
- package/dist/rules/backwardCompatibility/BackwardCompatibility.js +119 -0
- package/dist/rules/backwardCompatibility/BackwardCompatibilityCopyOnPack.js +101 -0
- package/dist/rules/backwardCompatibility/BackwardCompatibilitySysconfCheck.js +73 -0
- package/dist/rules/performance/Animated.js +64 -0
- package/dist/rules/performance/CheckSubscription.js +150 -0
- package/dist/rules/performance/DetectSplashScreen.js +62 -0
- package/dist/rules/performance/DetectUseReportFullyDrawn.js +50 -0
- package/dist/rules/performance/FlatList.js +39 -0
- package/dist/rules/systemDistributedLibs/SDLPackageVersionCheck.js +136 -0
- package/dist/rules/systemDistributedLibs/SDLPackageVersionCheckImports.js +58 -0
- package/dist/rules/systemDistributedLibs/sdlHelpers.js +232 -0
- package/dist/rules/systemDistributedLibs/sdlRuleMessages.js +25 -0
- package/dist/state/KeplerESLintPluginStateManager.js +94 -0
- package/dist/utils/Constants.js +40 -0
- package/dist/utils/PackageUtils.js +50 -0
- package/dist/utils/RuleUtils.js +128 -0
- package/package.json +1 -1
- package/dist/formatters/default.js.LICENSE.txt +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@amazon-devices/eslint-plugin-kepler", "version": "0.1.
|
|
1
|
+
{"name": "@amazon-devices/eslint-plugin-kepler", "version": "0.1.8", "description": "An ESLint Plugin to suggest Vega App Development best practices", "main": "dist/index.js", "files": ["dist", "THIRD_PARTY_NOTICES.txt"], "scripts": {"test": "jest --colors", "lint": "eslint src __tests__ --ext .js,.ts,.tsx", "lint:fix": "eslint src __tests__ --ext .js,.ts,.tsx --fix", "typeCheck": "tsc --noEmit", "bundle": "webpack", "clean": "rm -rf node_modules && rm package-lock.json && rm -rf dist", "compile": "babel src -d dist --extensions '.ts,.tsx'", "build": "npm-run-all lint typeCheck test compile", "rebuild": "rm -rf ./dist && npm run compile", "watch": "node scripts/watch.js", "format": "prettier --config .prettierrc 'src/**/*.ts' '__tests__/**/*.ts' --write", "checkLicenses": "license-checker --production --exclude MIT,Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,0BSD,Python-2.0", "genAttribution": "generate-attribution -o ./.attr && mv .attr/attribution.txt ./dist/LICENSE-THIRD-PARTY && rm -rf .attr"}, "devDependencies": {"@babel/cli": "^7.26.4", "@babel/core": "^7.26.9", "@babel/preset-env": "^7.26.9", "@babel/preset-typescript": "^7.26.0", "@eslint/js": "^8.12.0", "@trivago/prettier-plugin-sort-imports": "^5.2.1", "@types/eslint": "^8.4.1", "@types/jest": "^29.5.14", "@types/node": "^22.10.2", "@types/semver": "^7.7.0", "@typescript-eslint/eslint-plugin": "^8.18.0", "@typescript-eslint/parser": "^8.18.0", "@typescript-eslint/types": "^8.18.0", "@typescript-eslint/utils": "^8.18.0", "babel-loader": "^9.2.1", "babel-plugin-transform-remove-console": "^6.9.0", "eslint": "^8.12.0", "globals": "^15.13.0", "husky": "^9.1.7", "jest": "^29.7.0", "license-checker": "^25.0.1", "npm-run-all": "^4.1.5", "oss-attribution-generator": "^1.7.1", "prettier-plugin-organize-imports": "^4.1.0", "ts-jest": "^29.2.5", "ts-node": "^10.9.2", "typescript": "^5.7.2", "typescript-eslint": "^8.18.0", "webpack": "^5.100.2", "webpack-cli": "^6.0.1"}, "dependencies": {"chalk": "^4.1.2", "jsonc-eslint-parser": ">=2.0.0", "semver": "^7.7.2", "toml": "^3.0.0", "uuid": "^11.0.0", "@amazon-devices/kepler-telemetry-service-config": "*", "@amazon-devices/kepler-telemetry-service-typescript-client": "*"}, "peerDependencies": {"eslint": ">=8.12.0", "jsonc-eslint-parser": ">=2.0.0"}, "husky": {"hooks": {"pre-commit": "npm run format"}}, "license": "See license in LICENSE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|