@amazon-devices/eslint-plugin-kepler 0.1.11 → 0.1.15-rn-83
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 +132 -11
- package/dist/formatters/default.js +3 -3
- package/dist/index.js +1 -1
- package/package.json +83 -1
package/README.md
CHANGED
|
@@ -36,11 +36,12 @@ To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Available configs:
|
|
39
|
-
- `kepler` - All Vega rules (performance + system distributed library checks + API privileges + backward compatibility)
|
|
39
|
+
- `kepler` - All Vega rules (performance + system distributed library checks + API privileges + backward compatibility + component migration)
|
|
40
40
|
- `performance` - Performance-related rules only
|
|
41
41
|
- `system-distributed-libs` - System distributed library checks (package.json validation and import informational flagging)
|
|
42
42
|
- `api-privileges` - API privileges validation rules
|
|
43
43
|
- `backward-compatibility` - Backward compatibility validation rules for Vega library projects
|
|
44
|
+
- `vega-ui-components` - Component migration and best practices rules (e.g., deprecated Carousel detection)
|
|
44
45
|
|
|
45
46
|
You can use multiple configs:
|
|
46
47
|
```javascript
|
|
@@ -50,7 +51,7 @@ To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
|
50
51
|
"plugin:@amazon-devices/eslint-plugin-kepler/performance",
|
|
51
52
|
"plugin:@amazon-devices/eslint-plugin-kepler/system-distributed-libs",
|
|
52
53
|
"plugin:@amazon-devices/eslint-plugin-kepler/api-privileges",
|
|
53
|
-
"plugin:@amazon-devices/eslint-plugin-kepler/backward-compatibility"
|
|
54
|
+
"plugin:@amazon-devices/eslint-plugin-kepler/backward-compatibility",
|
|
54
55
|
],
|
|
55
56
|
}
|
|
56
57
|
```
|
|
@@ -70,13 +71,15 @@ To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
|
70
71
|
extends: ["plugin:@amazon-devices/eslint-plugin-kepler/kepler"],
|
|
71
72
|
rules: {
|
|
72
73
|
"@amazon-devices/kepler/flat-list": "error",
|
|
74
|
+
"@amazon-devices/kepler/url-constructor-check": "warn",
|
|
73
75
|
"@amazon-devices/kepler/sdl-package-version-check": "warn",
|
|
74
76
|
"@amazon-devices/kepler/sdl-package-version-check-imports": "off",
|
|
77
|
+
"@amazon-devices/kepler/turbo-module-sdl-native-module-check": "error",
|
|
75
78
|
"@amazon-devices/kepler/api-privileges-check": "error",
|
|
76
79
|
"@amazon-devices/kepler/api-privilege-state-check": "error",
|
|
77
80
|
"@amazon-devices/kepler/backward-compatibility": "error",
|
|
78
81
|
"@amazon-devices/kepler/backward-compatibility-copy-on-pack": "error",
|
|
79
|
-
"@amazon-devices/kepler/package-migration": "error"
|
|
82
|
+
"@amazon-devices/kepler/package-migration": "error",
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
```
|
|
@@ -90,7 +93,7 @@ To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
|
90
93
|
plugins: ["@amazon-devices/eslint-plugin-kepler"],
|
|
91
94
|
rules: {
|
|
92
95
|
"@amazon-devices/kepler/sdl-package-version-check": ["error", { "semverGuidance": "auto" }],
|
|
93
|
-
"@amazon-devices/kepler/sdl-package-version-check-imports": ["warn", { "semverGuidance": "auto" }]
|
|
96
|
+
"@amazon-devices/kepler/sdl-package-version-check-imports": ["warn", { "semverGuidance": "auto" }],
|
|
94
97
|
}
|
|
95
98
|
}
|
|
96
99
|
```
|
|
@@ -147,11 +150,11 @@ To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
|
147
150
|
> eslint src test --ext .ts,.tsx --format node_modules/@amazon-devices/eslint-plugin-kepler/dist/formatters/default.js
|
|
148
151
|
|
|
149
152
|
/Volumes/workspace/VegaSampleApp/src/components/Link.tsx
|
|
150
|
-
32:5 ❌ 'useNativeDriver' property is set to 'false'. Set useNativeDriver to 'true' to run animations on UI thread for better performance. See https://developer.amazon.com/docs/vega/
|
|
151
|
-
43:5 ⚠️ Subscription must be kept in variable so that it can be cleaned up on the component is detached. See https://developer.amazon.com/docs/vega/
|
|
152
|
-
64:11 ⚠️ FlatList missing props: 'initialNumToRender,windowSize,removeClippedSubviews,maxToRenderPerBatch,updateCellsBatchingPeriod'. FlatList performance is not fully unlocked without these props. See https://developer.amazon.com/docs/vega/
|
|
153
|
+
32:5 ❌ 'useNativeDriver' property is set to 'false'. Set useNativeDriver to 'true' to run animations on UI thread for better performance. See https://developer.amazon.com/docs/vega/latest/best_practices.html#the-animated-library for more. @amazon-devices/kepler/animated
|
|
154
|
+
43:5 ⚠️ Subscription must be kept in variable so that it can be cleaned up on the component is detached. See https://developer.amazon.com/docs/vega/latest/best_practices.html#listeners-event-subscriptions-and-timers for more. @amazon-devices/kepler/check-subscription
|
|
155
|
+
64:11 ⚠️ FlatList missing props: 'initialNumToRender,windowSize,removeClippedSubviews,maxToRenderPerBatch,updateCellsBatchingPeriod'. FlatList performance is not fully unlocked without these props. See https://developer.amazon.com/docs/vega/latest/best_practices.html#flatlist for more. @amazon-devices/kepler/flat-list
|
|
153
156
|
|
|
154
|
-
⚠️ useReportFullyDrawn() call not found in project. Add useReportFullyDrawn() in your App to accurately measure Time To Fully Drawn (TTFD) KPI. See https://developer.amazon.com/docs/vega/
|
|
157
|
+
⚠️ useReportFullyDrawn() call not found in project. Add useReportFullyDrawn() in your App to accurately measure Time To Fully Drawn (TTFD) KPI. See https://developer.amazon.com/docs/vega/latest/measure-app-kpis.html#fully-drawn-marker for more. @amazon-devices/kepler/detect-report-fully-drawn
|
|
155
158
|
|
|
156
159
|
⚠️ usePreventHideSplashScreen() call not found in project. Use usePreventHideSplashScreen() to natively render SplashScreen for better App launch performance. See https://developer.amazon.com/docs/react-native-vega/0.72/splashscreenmanager.html for more. @amazon-devices/kepler/detect-splash-screen
|
|
157
160
|
|
|
@@ -189,7 +192,7 @@ To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
|
189
192
|
|
|
190
193
|
## System Distributed Library Rules
|
|
191
194
|
|
|
192
|
-
The plugin includes
|
|
195
|
+
The plugin includes rules for managing system distributed libraries:
|
|
193
196
|
|
|
194
197
|
### `@amazon-devices/kepler/sdl-package-version-check`
|
|
195
198
|
Validates that SDL dependencies in `package.json` use proper semantic versioning:
|
|
@@ -200,6 +203,21 @@ Validates that SDL dependencies in `package.json` use proper semantic versioning
|
|
|
200
203
|
### `@amazon-devices/kepler/sdl-package-version-check-imports`
|
|
201
204
|
Flags imports of system distributed libraries with informational messages to ensure developers understand the implications of using these libraries.
|
|
202
205
|
|
|
206
|
+
### `@amazon-devices/kepler/turbo-module-sdl-native-module-check`
|
|
207
|
+
Validates that System Distributed Library (SDL) dependencies with native modules are properly declared in the `kepler-system-conf.toml` file for Turbo Modules:
|
|
208
|
+
- Checks that SDL packages are installed in `node_modules`
|
|
209
|
+
- Validates that SDL packages include required `kepler-compatibility.json` files
|
|
210
|
+
- Ensures native module dependencies are declared in `kepler-system-conf.toml`
|
|
211
|
+
- Verifies that installed SDL versions are supported by the compatibility configuration
|
|
212
|
+
|
|
213
|
+
**Example errors:**
|
|
214
|
+
```
|
|
215
|
+
System Distributed Library (SDL) dependency '@amazon-devices/kepler-example' is not installed in node_modules. Run npm install to resolve.
|
|
216
|
+
```
|
|
217
|
+
```
|
|
218
|
+
System Distributed Library (SDL) dependency '@amazon-devices/kepler-example@1.0.0' requires native module 'ExampleNativeModule' to be declared in kepler-system-conf.toml
|
|
219
|
+
```
|
|
220
|
+
|
|
203
221
|
## Backward Compatibility Rules
|
|
204
222
|
|
|
205
223
|
The plugin includes rules for managing backward compatibility in Vega library projects:
|
|
@@ -216,11 +234,64 @@ Ensures that the `kepler-compatibility.json` file is included in npm packages:
|
|
|
216
234
|
- Only runs in repositories with SDL project configuration
|
|
217
235
|
- Required for proper version compatibility validation in published packages
|
|
218
236
|
|
|
237
|
+
### `@amazon-devices/kepler/backward-compatibility-sysconf-check`
|
|
238
|
+
Validates that SDL library projects properly declare their native modules in the system configuration:
|
|
239
|
+
- Checks that `kepler-system-conf.toml` exists in SDL library projects
|
|
240
|
+
- Validates that the library's native modules are declared in the system configuration
|
|
241
|
+
- Ensures proper integration with the Vega system distributed library architecture
|
|
242
|
+
- Only runs in repositories with SDL project configuration
|
|
243
|
+
|
|
244
|
+
**Example error:**
|
|
245
|
+
```
|
|
246
|
+
SDL library project must declare native module 'ExampleNativeModule' in kepler-system-conf.toml
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Component Migration Rules
|
|
250
|
+
|
|
251
|
+
The plugin includes rules for detecting deprecated component usage and suggesting migrations:
|
|
252
|
+
|
|
253
|
+
### `@amazon-devices/kepler/carousel-deprecated`
|
|
254
|
+
Detects deprecated Carousel V1 usage from @amazon-devices/kepler-ui-components and suggests migration to @amazon-devices/vega-carousel. This rule helps identify code that needs to be updated for better performance and features.
|
|
255
|
+
|
|
256
|
+
**What it detects:**
|
|
257
|
+
- Carousel imports from `@amazon-devices/kepler-ui-components`
|
|
258
|
+
- Usage of deprecated props on Carousel components (from `@amazon-devices/kepler-ui-components`)
|
|
259
|
+
|
|
260
|
+
**Deprecated V1 props detected:**
|
|
261
|
+
- Props removed/replaced: `data`, `keyProvider`, `rowId`, `itemDimensions`, `getItemForIndex`, `selectionBorderStrategy`
|
|
262
|
+
- Props renamed: `maxToRenderPerBatch`, `hasTVPreferredFocus`, `trapFocusOnAxis`, `itemPadding`, `itemSelectionExpansion`, `itemScrollDelay`, `focusIndicatorType`, `pinnedFocusOffset`
|
|
263
|
+
|
|
264
|
+
**Example warnings:**
|
|
265
|
+
```
|
|
266
|
+
Carousel imported from @amazon-devices/kepler-ui-components. Consider migrating to @amazon-devices/vega-carousel for better performance and features.
|
|
267
|
+
Carousel uses deprecated props (data, keyProvider). Consider migrating to @amazon-devices/vega-carousel.
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
This rule provides the same detection capabilities as the Vega Studio Performance Extension's Carousel detection system, ensuring consistent warnings across different development environments.
|
|
271
|
+
|
|
219
272
|
### `@amazon-devices/kepler/package-migration`
|
|
220
273
|
Validates that packages requiring migration to system distributed libraries are updated to newer versions:
|
|
221
274
|
- Checks specific packages that have been released as system distributed libraries
|
|
222
275
|
- Provides package version recommendations to make use of SDL released libs
|
|
223
276
|
|
|
277
|
+
## URL Constructor Check Rule
|
|
278
|
+
|
|
279
|
+
The plugin includes a rule for managing URL polyfill usage in Kepler projects:
|
|
280
|
+
|
|
281
|
+
### `@amazon-devices/kepler/url-constructor-check`
|
|
282
|
+
Flags usage of `react-native-url-polyfill` when it's no longer needed in Kepler versions > 2.0.0. Amazon has fixed the URL implementation issues in newer releases of React Native for Vega, making the polyfill unnecessary.
|
|
283
|
+
|
|
284
|
+
**Rule behavior:**
|
|
285
|
+
- Only activates when Kepler version > 2.0.0 AND `react-native-url-polyfill` is in dependencies
|
|
286
|
+
- Flags imports from `react-native-url-polyfill` package
|
|
287
|
+
- Flags usage of `new URL()` and `new URLSearchParams()` constructors
|
|
288
|
+
- Does nothing if Kepler <= 2.0.0 or polyfill is not a dependency
|
|
289
|
+
|
|
290
|
+
**Example error:**
|
|
291
|
+
```
|
|
292
|
+
URL polyfill is not needed in this version of "@amazon-devices/react-native-kepler" as Amazon has fixed the issues with the stock React Native implementation.
|
|
293
|
+
```
|
|
294
|
+
|
|
224
295
|
## API Privileges Rules
|
|
225
296
|
|
|
226
297
|
The plugin includes two rules for validating API privilege requirements:
|
|
@@ -244,5 +315,55 @@ Validates that APIs requiring user privilege prompts have proper SecurityManager
|
|
|
244
315
|
|
|
245
316
|
**Example error:**
|
|
246
317
|
```
|
|
247
|
-
The API @amazon-devices/kepler-identifiers requires you prompt the user for
|
|
248
|
-
```
|
|
318
|
+
The API @amazon-devices/kepler-identifiers requires you prompt the user for privilege acceptance. See the Vega documentation for this API as well as for SecurityManager.
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### `@amazon-devices/kepler/privilege-request-pattern-check`
|
|
322
|
+
Validates that APIs requiring user prompts properly handle both `PrivilegeState.ALLOW` and `PrivilegeState.DENY` cases when calling `SecurityManager.requestPrivilege()`. This rule ensures developers implement the complete privilege request pattern to prevent runtime errors and improve user experience.
|
|
323
|
+
|
|
324
|
+
**Supported patterns:**
|
|
325
|
+
- Promise chains with `.then()` callbacks
|
|
326
|
+
- Async/await with if/else or switch statements
|
|
327
|
+
- Nested conditionals and ternary operators
|
|
328
|
+
|
|
329
|
+
**Example of correct implementation (Promise chain):**
|
|
330
|
+
```typescript
|
|
331
|
+
import { SecurityManager, PrivilegeState } from '@amazon-devices/kepler-security-manager';
|
|
332
|
+
|
|
333
|
+
SecurityManager.requestPrivilege('com.amazon.device-messaging.privilege.access')
|
|
334
|
+
.then((state) => {
|
|
335
|
+
if (state === PrivilegeState.ALLOW) {
|
|
336
|
+
// Handle permission granted
|
|
337
|
+
console.log('Permission granted');
|
|
338
|
+
} else if (state === PrivilegeState.DENY) {
|
|
339
|
+
// Handle permission denied
|
|
340
|
+
console.log('Permission denied');
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Example of correct implementation (async/await):**
|
|
346
|
+
```typescript
|
|
347
|
+
import { SecurityManager, PrivilegeState } from '@amazon-devices/kepler-security-manager';
|
|
348
|
+
|
|
349
|
+
const requestPermission = async () => {
|
|
350
|
+
const state = await SecurityManager.requestPrivilege('com.amazon.device-messaging.privilege.access');
|
|
351
|
+
if (state === PrivilegeState.ALLOW) {
|
|
352
|
+
// Handle permission granted
|
|
353
|
+
console.log('Permission granted');
|
|
354
|
+
} else if (state === PrivilegeState.DENY) {
|
|
355
|
+
// Handle permission denied
|
|
356
|
+
console.log('Permission denied');
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Example errors:**
|
|
362
|
+
```
|
|
363
|
+
API @amazon-devices/kepler-amazon-device-messaging requires proper privilege request pattern implementation. Your code is missing the DENY case handling for privilege 'com.amazon.device-messaging.privilege.access' in the Promise chain.
|
|
364
|
+
```
|
|
365
|
+
```
|
|
366
|
+
API @amazon-devices/kepler-amazon-device-messaging requires proper privilege request pattern implementation. Your code is missing the ALLOW and DENY case handling for privilege 'com.amazon.device-messaging.privilege.access' in the Promise chain.
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
The rule automatically applies to APIs configured in `API_PRIV_NEEDED` with `requiresUserPrompt: true`, and provides detailed error messages with code examples and documentation links.
|