@amazon-devices/eslint-plugin-kepler 0.1.4 → 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 +200 -23
- package/dist/formatters/default.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,51 +1,138 @@
|
|
|
1
|
-
|
|
2
1
|
# eslint-plugin-kepler
|
|
3
2
|
|
|
4
|
-
An ESLint Plugin to suggest
|
|
3
|
+
An ESLint Plugin to suggest Vega App Development best practices.
|
|
5
4
|
|
|
6
5
|
## Install
|
|
7
|
-
1.
|
|
8
|
-
2. Add this package to `devDependencies` section of `package.json`:
|
|
6
|
+
1. Add this package to `devDependencies` section of `package.json`:
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
```
|
|
9
|
+
npm install --save-dev @amazon-devices/eslint-plugin-kepler
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
2. For package.json validation (System Distributed Library rules), you must install the ESLint JSON parser:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
npm install --save-dev jsonc-eslint-parser
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
You must also add the `package.json` to the `lint` command line in your `package.json` scripts as shown below.
|
|
19
|
+
```
|
|
20
|
+
"lint": "eslint src test package.json --ext .ts,.tsx --format node_modules/@amazon-devices/eslint-plugin-kepler/dist/formatters/default.js"
|
|
21
|
+
```
|
|
13
22
|
|
|
14
23
|
## Set up
|
|
15
24
|
|
|
16
|
-
To use
|
|
25
|
+
To use Vega ESLint Plugin, complete the below steps in your Vega App Project.
|
|
17
26
|
|
|
18
|
-
1. Configure
|
|
27
|
+
1. Configure Vega rules in the App's eslint config
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
`eslint-plugin-kepler` provides default configs that can be directly imported in App projects. To do so, add the following configuration in Vega App's ESLint config file `.eslintrc.js`.
|
|
21
30
|
|
|
22
31
|
``` javascript
|
|
23
32
|
module.exports = {
|
|
24
33
|
plugins: ["@amazon-devices/eslint-plugin-kepler"],
|
|
25
|
-
extends: ["plugin:@amazon-devices/eslint-plugin-kepler/
|
|
34
|
+
extends: ["plugin:@amazon-devices/eslint-plugin-kepler/kepler"],
|
|
26
35
|
}
|
|
27
36
|
```
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
Available configs:
|
|
39
|
+
- `kepler` - All Vega rules (performance + system distributed library checks + API privileges + backward compatibility)
|
|
40
|
+
- `performance` - Performance-related rules only
|
|
41
|
+
- `system-distributed-libs` - System distributed library checks (package.json validation and import informational flagging)
|
|
42
|
+
- `api-privileges` - API privileges validation rules
|
|
43
|
+
- `backward-compatibility` - Backward compatibility validation rules for Vega library projects
|
|
44
|
+
|
|
45
|
+
You can use multiple configs:
|
|
30
46
|
```javascript
|
|
31
47
|
module.exports = {
|
|
32
48
|
plugins: ["@amazon-devices/eslint-plugin-kepler"],
|
|
33
|
-
extends: [
|
|
49
|
+
extends: [
|
|
50
|
+
"plugin:@amazon-devices/eslint-plugin-kepler/performance",
|
|
51
|
+
"plugin:@amazon-devices/eslint-plugin-kepler/system-distributed-libs",
|
|
52
|
+
"plugin:@amazon-devices/eslint-plugin-kepler/api-privileges",
|
|
53
|
+
"plugin:@amazon-devices/eslint-plugin-kepler/backward-compatibility"
|
|
54
|
+
],
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or use the comprehensive config:
|
|
59
|
+
```javascript
|
|
60
|
+
module.exports = {
|
|
61
|
+
plugins: ["@amazon-devices/eslint-plugin-kepler"],
|
|
62
|
+
extends: ["plugin:@amazon-devices/eslint-plugin-kepler/kepler"],
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
You can also override severity of specific rules:
|
|
67
|
+
```javascript
|
|
68
|
+
module.exports = {
|
|
69
|
+
plugins: ["@amazon-devices/eslint-plugin-kepler"],
|
|
70
|
+
extends: ["plugin:@amazon-devices/eslint-plugin-kepler/kepler"],
|
|
34
71
|
rules: {
|
|
35
72
|
"@amazon-devices/kepler/flat-list": "error",
|
|
73
|
+
"@amazon-devices/kepler/sdl-package-version-check": "warn",
|
|
74
|
+
"@amazon-devices/kepler/sdl-package-version-check-imports": "off",
|
|
75
|
+
"@amazon-devices/kepler/api-privileges-check": "error",
|
|
76
|
+
"@amazon-devices/kepler/api-privilege-state-check": "error",
|
|
77
|
+
"@amazon-devices/kepler/backward-compatibility": "error",
|
|
78
|
+
"@amazon-devices/kepler/backward-compatibility-copy-on-pack": "error",
|
|
79
|
+
"@amazon-devices/kepler/package-migration": "error"
|
|
36
80
|
}
|
|
37
81
|
}
|
|
38
82
|
```
|
|
39
83
|
|
|
84
|
+
### System Distributed Library Rules Configuration
|
|
85
|
+
|
|
86
|
+
The system distributed library rules support a `semverGuidance` configuration option:
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
module.exports = {
|
|
90
|
+
plugins: ["@amazon-devices/eslint-plugin-kepler"],
|
|
91
|
+
rules: {
|
|
92
|
+
"@amazon-devices/kepler/sdl-package-version-check": ["error", { "semverGuidance": "auto" }],
|
|
93
|
+
"@amazon-devices/kepler/sdl-package-version-check-imports": ["warn", { "semverGuidance": "auto" }]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**`semverGuidance` Options:**
|
|
99
|
+
- `"patch"` - Conservative mode: Only allows patch updates (`~` prefix)
|
|
100
|
+
- `"minor"` - Allows minor updates (`^` prefix) in addition to patch
|
|
101
|
+
- `"auto"` (default) - Automatically detects mode based on signatures in the project repo
|
|
102
|
+
|
|
103
|
+
The rules for System Distributed Libraries require an ESLint JSON parser to parse the `package.json` and the addition of this parser to the `.eslintrc` (or `.eslintrc.json`). To install the parser (if you did not above):
|
|
104
|
+
|
|
105
|
+
``` bash
|
|
106
|
+
npm install -D jsonc-eslint-parser
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Then, in your ESLint config file, add the JSON parser for `package.json`:
|
|
110
|
+
|
|
111
|
+
``` javascript
|
|
112
|
+
overrides: [
|
|
113
|
+
{
|
|
114
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
115
|
+
parser: '@typescript-eslint/parser',
|
|
116
|
+
parserOptions: {
|
|
117
|
+
project: './tsconfig.json',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
files: ['package.json'],
|
|
122
|
+
parser: 'jsonc-eslint-parser',
|
|
123
|
+
},
|
|
124
|
+
]
|
|
125
|
+
```
|
|
126
|
+
|
|
40
127
|
2. Specify formatter on lint tasks:
|
|
41
128
|
```javascript
|
|
42
129
|
"scripts": {
|
|
43
130
|
:
|
|
44
|
-
"lint": "eslint src test --ext .ts,.tsx --format node_modules/@amazon-devices/eslint-plugin-kepler/dist/formatters/default.js",
|
|
131
|
+
"lint": "eslint src test package.json --ext .ts,.tsx --format node_modules/@amazon-devices/eslint-plugin-kepler/dist/formatters/default.js",
|
|
45
132
|
"lint:fix": "eslint src test --ext .ts,.tsx --fix --format node_modules/@amazon-devices/eslint-plugin-kepler/dist/formatters/default.js",
|
|
46
133
|
```
|
|
47
134
|
|
|
48
|
-
3. Run
|
|
135
|
+
3. Run ESLint
|
|
49
136
|
|
|
50
137
|
```bash
|
|
51
138
|
$ npm run lint
|
|
@@ -56,16 +143,106 @@ To use Kepler ESLint Plugin, complete the below steps in your Kepler App Project
|
|
|
56
143
|
```bash
|
|
57
144
|
$ npm run lint
|
|
58
145
|
|
|
59
|
-
> @amazon-devices/
|
|
146
|
+
> @amazon-devices/vega-sample-app@0.1.0 lint
|
|
60
147
|
> eslint src test --ext .ts,.tsx --format node_modules/@amazon-devices/eslint-plugin-kepler/dist/formatters/default.js
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
148
|
+
|
|
149
|
+
/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/0.21/best_practices.html#the-animated-library for more. @amazon-devices/kepler/animated
|
|
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/0.21/best_practices.html#listeners-event-subscriptions-and-timers for more. @amazon-devices/kepler/check-subscription
|
|
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/0.21/best_practices.html#flatlist for more. @amazon-devices/kepler/flat-list
|
|
153
|
+
|
|
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/0.21/measure-app-kpis.html#fully-drawn-marker for more. @amazon-devices/kepler/detect-report-fully-drawn
|
|
155
|
+
|
|
156
|
+
⚠️ 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
|
+
|
|
158
|
+
Summary:
|
|
159
|
+
❌ 1 error(s)
|
|
160
|
+
⚠️ 4 warning(s)
|
|
161
|
+
|
|
162
|
+
Vega ESLint HTML report generated at: /Volumes/workspace/VegaSampleApp/generated/eslint-plugin-kepler/vega-eslint-report.html
|
|
67
163
|
```
|
|
68
164
|
|
|
69
|
-
4.
|
|
165
|
+
4. Vega ESLint Plugin generated warnings will show in VS Code Editor when [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) is installed.
|
|
70
166
|
|
|
71
167
|

|
|
168
|
+
|
|
169
|
+
5. Seeing errors and warnings in VSCode in the `package.json` requires an additional configuration step. In the VSCode `settings.json` file you will need to add `json` to the following entries, as shown:
|
|
170
|
+
|
|
171
|
+
``` javascript
|
|
172
|
+
"eslint.validate": [
|
|
173
|
+
"javascript",
|
|
174
|
+
"javascriptreact",
|
|
175
|
+
"typescript",
|
|
176
|
+
"typescriptreact",
|
|
177
|
+
// add the line below
|
|
178
|
+
"json"
|
|
179
|
+
],
|
|
180
|
+
"eslint.probe": [
|
|
181
|
+
"javascript",
|
|
182
|
+
"javascriptreact",
|
|
183
|
+
"typescript",
|
|
184
|
+
"typescriptreact",
|
|
185
|
+
// add the line below
|
|
186
|
+
"json"
|
|
187
|
+
],
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## System Distributed Library Rules
|
|
191
|
+
|
|
192
|
+
The plugin includes two rules for managing system distributed libraries:
|
|
193
|
+
|
|
194
|
+
### `@amazon-devices/kepler/sdl-package-version-check`
|
|
195
|
+
Validates that SDL dependencies in `package.json` use proper semantic versioning:
|
|
196
|
+
- **Patch only mode** (`semverGuidance: "patch"`): Only allows patch updates using `~` prefix.
|
|
197
|
+
- **Minor and patch mode** (`semverGuidance: "minor"`): Allows minor updates using `^` prefix.
|
|
198
|
+
- **Auto mode** (`semverGuidance: "auto"`): Automatically detects based on signatures in the project repo. This is the default.
|
|
199
|
+
|
|
200
|
+
### `@amazon-devices/kepler/sdl-package-version-check-imports`
|
|
201
|
+
Flags imports of system distributed libraries with informational messages to ensure developers understand the implications of using these libraries.
|
|
202
|
+
|
|
203
|
+
## Backward Compatibility Rules
|
|
204
|
+
|
|
205
|
+
The plugin includes rules for managing backward compatibility in Vega library projects:
|
|
206
|
+
|
|
207
|
+
### `@amazon-devices/kepler/backward-compatibility`
|
|
208
|
+
Validates that Vega library projects have proper version compatibility configuration:
|
|
209
|
+
- Checks for the existence of `kepler-compatibility.json` file in the project root
|
|
210
|
+
- Validates that the current package version is listed in the compatibility file
|
|
211
|
+
- Only runs in repositories with SDL project configuration
|
|
212
|
+
|
|
213
|
+
### `@amazon-devices/kepler/backward-compatibility-copy-on-pack`
|
|
214
|
+
Ensures that the `kepler-compatibility.json` file is included in npm packages:
|
|
215
|
+
- Validates that `kepler-compatibility.json` is listed in the `files` array of `package.json`
|
|
216
|
+
- Only runs in repositories with SDL project configuration
|
|
217
|
+
- Required for proper version compatibility validation in published packages
|
|
218
|
+
|
|
219
|
+
### `@amazon-devices/kepler/package-migration`
|
|
220
|
+
Validates that packages requiring migration to system distributed libraries are updated to newer versions:
|
|
221
|
+
- Checks specific packages that have been released as system distributed libraries
|
|
222
|
+
- Provides package version recommendations to make use of SDL released libs
|
|
223
|
+
|
|
224
|
+
## API Privileges Rules
|
|
225
|
+
|
|
226
|
+
The plugin includes two rules for validating API privilege requirements:
|
|
227
|
+
|
|
228
|
+
### `@amazon-devices/kepler/api-privileges-check`
|
|
229
|
+
Validates that APIs requiring permissions have the proper entries in the Vega `manifest.toml` file. Some Vega APIs require specific privileges to be declared in the manifest for the app to function correctly.
|
|
230
|
+
|
|
231
|
+
**Supported privilege types:**
|
|
232
|
+
- `[[needs.privilege]]` - Required privileges that must be present
|
|
233
|
+
- `[[wants.privilege]]` - Optional privileges that should be present
|
|
234
|
+
|
|
235
|
+
**Example error:**
|
|
236
|
+
```
|
|
237
|
+
Using the APIs in @amazon-devices/kepler-amazon-device-messaging requires the [[needs.privilege]] id="com.amazon.device-messaging.privilege.access" entry in the Vega manifest.toml.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The rule checks imports of known privilege-requiring packages and ensures the corresponding privilege entries exist in your project's `manifest.toml` file.
|
|
241
|
+
|
|
242
|
+
### `@amazon-devices/kepler/api-privilege-state-check`
|
|
243
|
+
Validates that APIs requiring user privilege prompts have proper SecurityManager implementation. Some APIs require explicit user consent through privilege request dialogs.
|
|
244
|
+
|
|
245
|
+
**Example error:**
|
|
246
|
+
```
|
|
247
|
+
The API @amazon-devices/kepler-identifiers requires you prompt the user for privilige acceptance. See the Vega documentation for this API as well as for SecurityManager.
|
|
248
|
+
```
|