@jupyter/eslint-plugin 1.3.0 → 1.5.0
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 +12 -0
- package/lib/index.d.ts +6 -207
- package/lib/index.js +49 -28
- package/lib/rules/command-described-by.js +18 -27
- package/lib/rules/command-id-convention.d.ts +5 -0
- package/lib/rules/command-id-convention.js +87 -0
- package/lib/rules/no-untranslated-string.d.ts +2 -1
- package/lib/rules/no-untranslated-string.js +11 -3
- package/lib/rules/plugin-activation-args.d.ts +3 -3
- package/lib/rules/plugin-activation-args.js +183 -142
- package/lib/rules/plugin-description.js +12 -9
- package/lib/rules/plugin-id-convention.d.ts +2 -3
- package/lib/rules/plugin-id-convention.js +10 -107
- package/lib/rules/prefer-lazy-imports.d.ts +2 -2
- package/lib/rules/prefer-lazy-imports.js +59 -28
- package/lib/rules/prefer-signal-this-arg.d.ts +3 -3
- package/lib/rules/prefer-signal-this-arg.js +12 -13
- package/lib/rules/require-disposable-ownership.d.ts +1 -2
- package/lib/rules/require-disposable-ownership.js +2 -10
- package/lib/rules/require-disposable-transfer.d.ts +1 -2
- package/lib/rules/require-disposable-transfer.js +7 -12
- package/lib/rules/require-signal-cleanup.d.ts +3 -3
- package/lib/rules/require-signal-cleanup.js +12 -13
- package/lib/rules/require-signal-this-arg.d.ts +1 -2
- package/lib/rules/require-signal-this-arg.js +2 -10
- package/lib/rules/token-format.js +8 -2
- package/lib/utils/ast.d.ts +1 -1
- package/lib/utils/commands.d.ts +17 -1
- package/lib/utils/commands.js +205 -0
- package/lib/utils/disposables.d.ts +2 -13
- package/lib/utils/disposables.js +3 -18
- package/lib/utils/lazy-imports.d.ts +2 -2
- package/lib/utils/lazy-imports.js +10 -1
- package/lib/utils/options.d.ts +9 -0
- package/lib/utils/options.js +22 -0
- package/lib/utils/plugin-utils.d.ts +39 -10
- package/lib/utils/plugin-utils.js +376 -25
- package/lib/utils/signal-lifetime.d.ts +1 -2
- package/lib/utils/signals.d.ts +1 -2
- package/lib/utils/translation.d.ts +1 -1
- package/lib/utils/type-services.d.ts +12 -0
- package/lib/utils/type-services.js +27 -0
- package/package.json +4 -10
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# eslint-plugin
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@jupyter/eslint-plugin)
|
|
4
|
+
[](https://github.com/jupyterlab/eslint-plugin/actions/workflows/build.yml)
|
|
5
|
+
[](https://eslint-plugin.readthedocs.io/en/latest/)
|
|
6
|
+
|
|
3
7
|
ESLint plugin for Jupyter core and extensions with early error catching and best practices enforcement.
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
@@ -12,6 +16,14 @@ npm install --save-dev @jupyter/eslint-plugin
|
|
|
12
16
|
|
|
13
17
|
Add `@jupyter/eslint-plugin` to the plugins section of your ESLint configuration. For detailed usage instructions and available rules, see the [documentation](https://eslint-plugin.readthedocs.io/en/latest/).
|
|
14
18
|
|
|
19
|
+
## Learn more
|
|
20
|
+
|
|
21
|
+
- [Catching Jupyter-specific bugs before CI does](https://blog.jupyter.org/posts/2026/catching-jupyter-specific-bugs-before-ci-does/) - the announcement post on the Jupyter Blog, covering the motivation and the initial set of rules.
|
|
22
|
+
|
|
23
|
+
## Acknowledgments
|
|
24
|
+
|
|
25
|
+
Development of this plugin was supported by the [Jupyter Foundation](https://jupyterfoundation.org/). The [progress reports](https://jupyter-governance.github.io/funding-proposals/projects/2025/custom-linting-for-jupyterlab/) cover the scope of the Foundation-funded work.
|
|
26
|
+
|
|
15
27
|
## License
|
|
16
28
|
|
|
17
29
|
BSD 3-Clause
|
package/lib/index.d.ts
CHANGED
|
@@ -1,210 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const
|
|
3
|
-
rules:
|
|
4
|
-
'plugin-activation-args': import("@typescript-eslint/utils/ts-eslint").RuleModule<"mismatchedOrder" | "incorrectType" | "missingArgument" | "extraArgument" | "appNotFirst" | "serviceManagerFirstArgNotNull" | "invalidAppType" | "wrongArgumentCount" | "unresolvableTokenType" | "optionalNotNullable", [{
|
|
5
|
-
allowedFirstArgumentNames: string[];
|
|
6
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
'command-described-by': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingDescribedBy", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
'plugin-description': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingDescription" | "emptyDescription", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
13
|
-
name: string;
|
|
14
|
-
};
|
|
15
|
-
'plugin-id-convention': import("@typescript-eslint/utils/ts-eslint").RuleModule<"mismatchedPrefix" | "idEqualsPackageName", [{
|
|
16
|
-
reportIdEqualToPackageName: boolean;
|
|
17
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
18
|
-
name: string;
|
|
19
|
-
};
|
|
20
|
-
'no-translation-concatenation': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noConcatenation", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
'no-dynamic-translation': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noInterpolation" | "noDynamicMessage", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
24
|
-
name: string;
|
|
25
|
-
};
|
|
26
|
-
'token-format': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingColon" | "invalidTokenSymbol", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
27
|
-
name: string;
|
|
28
|
-
};
|
|
29
|
-
'no-untranslated-string': import("@typescript-eslint/utils/ts-eslint").RuleModule<"untranslatedCommandProp" | "untranslatedSetAttribute" | "untranslatedPropertyAssign" | "untranslatedDialogOption" | "untranslatedDialogButtonLabel" | "untranslatedJsxText" | "untranslatedJsxAttribute" | "untranslatedProperty", [{
|
|
30
|
-
enforcePunctuation: boolean;
|
|
31
|
-
checkProperties: string[];
|
|
32
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
'no-schema-enum': import("@typescript-eslint/utils/ts-eslint").RuleModule<"forbidEnum" | "requireStringType", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
'require-soft-assertions-before-snapshots': import("@typescript-eslint/utils/ts-eslint").RuleModule<"requireSoftAssertion", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
39
|
-
name: string;
|
|
40
|
-
};
|
|
41
|
-
'no-pageconfig-base-url': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noPageconfigBaseUrl", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
42
|
-
name: string;
|
|
43
|
-
};
|
|
44
|
-
'require-signal-cleanup': import("@typescript-eslint/utils/ts-eslint").RuleModule<"serviceOutlivesReceiver", [{
|
|
45
|
-
additionalCleanupMethods: string[];
|
|
46
|
-
longLivedTypes: string[] | undefined;
|
|
47
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
48
|
-
name: string;
|
|
49
|
-
};
|
|
50
|
-
'require-signal-this-arg': import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingThisArg" | "addThisArg", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
51
|
-
name: string;
|
|
52
|
-
};
|
|
53
|
-
'prefer-signal-this-arg': import("@typescript-eslint/utils/ts-eslint").RuleModule<"addThisArg" | "preferThisArg" | "boundCallback" | "unbindAndAddThisArg", [{
|
|
54
|
-
longLivedTypes: string[] | undefined;
|
|
55
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
56
|
-
name: string;
|
|
57
|
-
};
|
|
58
|
-
'galata-prefer-context-menu-helper': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferNotebookOpenNoKernel" | "preferFilebrowserOpenFactory" | "preferFilebrowserOpen", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
59
|
-
name: string;
|
|
60
|
-
};
|
|
61
|
-
'galata-prefer-filebrowser-helper': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferNotebookOpenByPath" | "preferOpenHomeDirectory" | "preferOpenDirectory" | "preferFilebrowserHelper", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
62
|
-
name: string;
|
|
63
|
-
};
|
|
64
|
-
'galata-prefer-menu-helper': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferMenuOpen" | "preferClickMenuItem" | "preferMenuHelper", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
65
|
-
name: string;
|
|
66
|
-
};
|
|
67
|
-
'galata-prefer-notebook-cell-helper': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferSetCell" | "preferEnterCellEditingMode" | "preferSelectCells" | "preferRunCell", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
68
|
-
name: string;
|
|
69
|
-
};
|
|
70
|
-
'galata-prefer-sidebar-activity-helper': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferSidebarHelper" | "preferActivityHelper", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
71
|
-
name: string;
|
|
72
|
-
};
|
|
73
|
-
'require-disposable-ownership': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unmanagedDisposable" | "unmanagedDisposableVariable", [{}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
74
|
-
name: string;
|
|
75
|
-
};
|
|
76
|
-
'require-disposable-transfer': import("@typescript-eslint/utils/ts-eslint").RuleModule<"unmanagedDisposableVariable" | "unhandledDisposable", [{}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
77
|
-
name: string;
|
|
78
|
-
};
|
|
79
|
-
'incorrect-translator-usage': import("@typescript-eslint/utils/ts-eslint").RuleModule<"chainedBundleMethod" | "invalidBundleName" | "destructuredBundle", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
80
|
-
name: string;
|
|
81
|
-
};
|
|
82
|
-
'prefer-lazy-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<string, [import("./utils/lazy-imports").LazyImportOptions], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
83
|
-
name: string;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
1
|
+
import type { ESLint, Linter, Rule } from 'eslint';
|
|
2
|
+
declare const _default: ESLint.Plugin & {
|
|
3
|
+
rules: Record<string, Rule.RuleModule>;
|
|
86
4
|
configs: {
|
|
87
|
-
recommended:
|
|
88
|
-
|
|
89
|
-
rules: {
|
|
90
|
-
'jupyter/plugin-activation-args': string;
|
|
91
|
-
'jupyter/command-described-by': string;
|
|
92
|
-
'jupyter/plugin-description': string;
|
|
93
|
-
'jupyter/plugin-id-convention': string;
|
|
94
|
-
'jupyter/no-translation-concatenation': string;
|
|
95
|
-
'jupyter/no-dynamic-translation': string;
|
|
96
|
-
'jupyter/token-format': string;
|
|
97
|
-
'jupyter/no-untranslated-string': string;
|
|
98
|
-
'jupyter/no-pageconfig-base-url': string;
|
|
99
|
-
'jupyter/require-signal-cleanup': string;
|
|
100
|
-
'jupyter/require-signal-this-arg': string;
|
|
101
|
-
'jupyter/prefer-signal-this-arg': string;
|
|
102
|
-
'jupyter/require-disposable-ownership': string;
|
|
103
|
-
'jupyter/require-disposable-transfer': string;
|
|
104
|
-
'jupyter/incorrect-translator-usage': string;
|
|
105
|
-
'jupyter/prefer-lazy-imports': string;
|
|
106
|
-
'jupyter/no-schema-enum'?: undefined;
|
|
107
|
-
'jupyter/require-soft-assertions-before-snapshots'?: undefined;
|
|
108
|
-
'jupyter/galata-prefer-context-menu-helper'?: undefined;
|
|
109
|
-
'jupyter/galata-prefer-filebrowser-helper'?: undefined;
|
|
110
|
-
'jupyter/galata-prefer-menu-helper'?: undefined;
|
|
111
|
-
'jupyter/galata-prefer-notebook-cell-helper'?: undefined;
|
|
112
|
-
'jupyter/galata-prefer-sidebar-activity-helper'?: undefined;
|
|
113
|
-
};
|
|
114
|
-
languageOptions?: undefined;
|
|
115
|
-
} | {
|
|
116
|
-
files: string[];
|
|
117
|
-
languageOptions: {
|
|
118
|
-
parser: typeof jsoncParser;
|
|
119
|
-
};
|
|
120
|
-
rules: {
|
|
121
|
-
'jupyter/no-schema-enum': string;
|
|
122
|
-
'jupyter/plugin-activation-args'?: undefined;
|
|
123
|
-
'jupyter/command-described-by'?: undefined;
|
|
124
|
-
'jupyter/plugin-description'?: undefined;
|
|
125
|
-
'jupyter/plugin-id-convention'?: undefined;
|
|
126
|
-
'jupyter/no-translation-concatenation'?: undefined;
|
|
127
|
-
'jupyter/no-dynamic-translation'?: undefined;
|
|
128
|
-
'jupyter/token-format'?: undefined;
|
|
129
|
-
'jupyter/no-untranslated-string'?: undefined;
|
|
130
|
-
'jupyter/no-pageconfig-base-url'?: undefined;
|
|
131
|
-
'jupyter/require-signal-cleanup'?: undefined;
|
|
132
|
-
'jupyter/require-signal-this-arg'?: undefined;
|
|
133
|
-
'jupyter/prefer-signal-this-arg'?: undefined;
|
|
134
|
-
'jupyter/require-disposable-ownership'?: undefined;
|
|
135
|
-
'jupyter/require-disposable-transfer'?: undefined;
|
|
136
|
-
'jupyter/incorrect-translator-usage'?: undefined;
|
|
137
|
-
'jupyter/prefer-lazy-imports'?: undefined;
|
|
138
|
-
'jupyter/require-soft-assertions-before-snapshots'?: undefined;
|
|
139
|
-
'jupyter/galata-prefer-context-menu-helper'?: undefined;
|
|
140
|
-
'jupyter/galata-prefer-filebrowser-helper'?: undefined;
|
|
141
|
-
'jupyter/galata-prefer-menu-helper'?: undefined;
|
|
142
|
-
'jupyter/galata-prefer-notebook-cell-helper'?: undefined;
|
|
143
|
-
'jupyter/galata-prefer-sidebar-activity-helper'?: undefined;
|
|
144
|
-
};
|
|
145
|
-
} | {
|
|
146
|
-
files: string[];
|
|
147
|
-
rules: {
|
|
148
|
-
'jupyter/require-soft-assertions-before-snapshots': string;
|
|
149
|
-
'jupyter/galata-prefer-context-menu-helper': string;
|
|
150
|
-
'jupyter/galata-prefer-filebrowser-helper': string;
|
|
151
|
-
'jupyter/galata-prefer-menu-helper': string;
|
|
152
|
-
'jupyter/galata-prefer-notebook-cell-helper': string;
|
|
153
|
-
'jupyter/galata-prefer-sidebar-activity-helper': string;
|
|
154
|
-
'jupyter/prefer-lazy-imports': string;
|
|
155
|
-
'jupyter/plugin-id-convention': string;
|
|
156
|
-
'jupyter/plugin-activation-args'?: undefined;
|
|
157
|
-
'jupyter/command-described-by'?: undefined;
|
|
158
|
-
'jupyter/plugin-description'?: undefined;
|
|
159
|
-
'jupyter/no-translation-concatenation'?: undefined;
|
|
160
|
-
'jupyter/no-dynamic-translation'?: undefined;
|
|
161
|
-
'jupyter/token-format'?: undefined;
|
|
162
|
-
'jupyter/no-untranslated-string'?: undefined;
|
|
163
|
-
'jupyter/no-pageconfig-base-url'?: undefined;
|
|
164
|
-
'jupyter/require-signal-cleanup'?: undefined;
|
|
165
|
-
'jupyter/require-signal-this-arg'?: undefined;
|
|
166
|
-
'jupyter/prefer-signal-this-arg'?: undefined;
|
|
167
|
-
'jupyter/require-disposable-ownership'?: undefined;
|
|
168
|
-
'jupyter/require-disposable-transfer'?: undefined;
|
|
169
|
-
'jupyter/incorrect-translator-usage'?: undefined;
|
|
170
|
-
'jupyter/no-schema-enum'?: undefined;
|
|
171
|
-
};
|
|
172
|
-
languageOptions?: undefined;
|
|
173
|
-
})[];
|
|
174
|
-
'recommended-legacy': {
|
|
175
|
-
rules: {
|
|
176
|
-
'jupyter/plugin-activation-args': string;
|
|
177
|
-
'jupyter/command-described-by': string;
|
|
178
|
-
'jupyter/plugin-description': string;
|
|
179
|
-
'jupyter/plugin-id-convention': string;
|
|
180
|
-
'jupyter/no-translation-concatenation': string;
|
|
181
|
-
'jupyter/no-dynamic-translation': string;
|
|
182
|
-
'jupyter/token-format': string;
|
|
183
|
-
'jupyter/no-untranslated-string': string;
|
|
184
|
-
'jupyter/no-schema-enum': string;
|
|
185
|
-
'jupyter/no-pageconfig-base-url': string;
|
|
186
|
-
'jupyter/require-signal-cleanup': string;
|
|
187
|
-
'jupyter/require-signal-this-arg': string;
|
|
188
|
-
'jupyter/prefer-signal-this-arg': string;
|
|
189
|
-
'jupyter/require-disposable-ownership': string;
|
|
190
|
-
'jupyter/require-disposable-transfer': string;
|
|
191
|
-
'jupyter/incorrect-translator-usage': string;
|
|
192
|
-
'jupyter/prefer-lazy-imports': string;
|
|
193
|
-
};
|
|
194
|
-
overrides: {
|
|
195
|
-
files: string[];
|
|
196
|
-
rules: {
|
|
197
|
-
'jupyter/require-soft-assertions-before-snapshots': string;
|
|
198
|
-
'jupyter/galata-prefer-context-menu-helper': string;
|
|
199
|
-
'jupyter/galata-prefer-filebrowser-helper': string;
|
|
200
|
-
'jupyter/galata-prefer-menu-helper': string;
|
|
201
|
-
'jupyter/galata-prefer-notebook-cell-helper': string;
|
|
202
|
-
'jupyter/galata-prefer-sidebar-activity-helper': string;
|
|
203
|
-
'jupyter/prefer-lazy-imports': string;
|
|
204
|
-
'jupyter/plugin-id-convention': string;
|
|
205
|
-
};
|
|
206
|
-
}[];
|
|
207
|
-
};
|
|
5
|
+
recommended: Linter.Config[];
|
|
6
|
+
"recommended-legacy": Linter.LegacyConfig;
|
|
208
7
|
};
|
|
209
8
|
};
|
|
210
|
-
export =
|
|
9
|
+
export = _default;
|
package/lib/index.js
CHANGED
|
@@ -39,9 +39,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
40
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
41
|
};
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
42
44
|
const jsoncParser = __importStar(require("jsonc-eslint-parser"));
|
|
43
45
|
const plugin_activation_args_1 = __importDefault(require("./rules/plugin-activation-args"));
|
|
44
46
|
const command_described_by_1 = __importDefault(require("./rules/command-described-by"));
|
|
47
|
+
const command_id_convention_1 = __importDefault(require("./rules/command-id-convention"));
|
|
45
48
|
const plugin_description_1 = __importDefault(require("./rules/plugin-description"));
|
|
46
49
|
const plugin_id_convention_1 = __importDefault(require("./rules/plugin-id-convention"));
|
|
47
50
|
const no_translation_concatenation_1 = __importDefault(require("./rules/no-translation-concatenation"));
|
|
@@ -63,10 +66,20 @@ const require_disposable_ownership_1 = __importDefault(require("./rules/require-
|
|
|
63
66
|
const require_disposable_transfer_1 = __importDefault(require("./rules/require-disposable-transfer"));
|
|
64
67
|
const incorrect_translator_usage_1 = __importDefault(require("./rules/incorrect-translator-usage"));
|
|
65
68
|
const prefer_lazy_imports_1 = __importDefault(require("./rules/prefer-lazy-imports"));
|
|
69
|
+
const { name, version } = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
70
|
+
// Filled in below once `plugin` exists, so that `configs.recommended` registers
|
|
71
|
+
// the plugin itself and works without a separate `plugins` entry.
|
|
72
|
+
const plugins = {};
|
|
66
73
|
const plugin = {
|
|
74
|
+
meta: {
|
|
75
|
+
name,
|
|
76
|
+
version,
|
|
77
|
+
namespace: 'jupyter'
|
|
78
|
+
},
|
|
67
79
|
rules: {
|
|
68
80
|
'plugin-activation-args': plugin_activation_args_1.default,
|
|
69
81
|
'command-described-by': command_described_by_1.default,
|
|
82
|
+
'command-id-convention': command_id_convention_1.default,
|
|
70
83
|
'plugin-description': plugin_description_1.default,
|
|
71
84
|
'plugin-id-convention': plugin_id_convention_1.default,
|
|
72
85
|
'no-translation-concatenation': no_translation_concatenation_1.default,
|
|
@@ -91,11 +104,13 @@ const plugin = {
|
|
|
91
104
|
},
|
|
92
105
|
configs: {
|
|
93
106
|
recommended: [
|
|
107
|
+
{ plugins },
|
|
94
108
|
{
|
|
95
109
|
files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'],
|
|
96
110
|
rules: {
|
|
97
111
|
'jupyter/plugin-activation-args': 'error',
|
|
98
112
|
'jupyter/command-described-by': 'warn',
|
|
113
|
+
'jupyter/command-id-convention': 'warn',
|
|
99
114
|
'jupyter/plugin-description': 'warn',
|
|
100
115
|
'jupyter/plugin-id-convention': 'warn',
|
|
101
116
|
'jupyter/no-translation-concatenation': 'error',
|
|
@@ -128,32 +143,36 @@ const plugin = {
|
|
|
128
143
|
'jupyter/galata-prefer-menu-helper': 'warn',
|
|
129
144
|
'jupyter/galata-prefer-notebook-cell-helper': 'warn',
|
|
130
145
|
'jupyter/galata-prefer-sidebar-activity-helper': 'warn',
|
|
131
|
-
// Test files declare mock plugins; deferring their
|
|
132
|
-
// pointless and their IDs are never used to disable an
|
|
146
|
+
// Test files declare mock plugins and commands; deferring their
|
|
147
|
+
// imports is pointless and their IDs are never used to disable an
|
|
148
|
+
// extension or to query commands.
|
|
133
149
|
'jupyter/prefer-lazy-imports': 'off',
|
|
134
|
-
'jupyter/plugin-id-convention': 'off'
|
|
150
|
+
'jupyter/plugin-id-convention': 'off',
|
|
151
|
+
'jupyter/command-id-convention': 'off'
|
|
135
152
|
}
|
|
136
153
|
}
|
|
137
154
|
],
|
|
138
155
|
'recommended-legacy': {
|
|
156
|
+
plugins: ['@jupyter'],
|
|
139
157
|
rules: {
|
|
140
|
-
'jupyter/plugin-activation-args': 'error',
|
|
141
|
-
'jupyter/command-described-by': 'warn',
|
|
142
|
-
'jupyter/
|
|
143
|
-
'jupyter/plugin-
|
|
144
|
-
'jupyter/
|
|
145
|
-
'jupyter/no-
|
|
146
|
-
'jupyter/
|
|
147
|
-
'jupyter/
|
|
148
|
-
'jupyter/no-
|
|
149
|
-
'jupyter/no-
|
|
150
|
-
'jupyter/
|
|
151
|
-
'jupyter/require-signal-
|
|
152
|
-
'jupyter/
|
|
153
|
-
'jupyter/
|
|
154
|
-
'jupyter/require-disposable-
|
|
155
|
-
'jupyter/
|
|
156
|
-
'jupyter/
|
|
158
|
+
'@jupyter/plugin-activation-args': 'error',
|
|
159
|
+
'@jupyter/command-described-by': 'warn',
|
|
160
|
+
'@jupyter/command-id-convention': 'warn',
|
|
161
|
+
'@jupyter/plugin-description': 'warn',
|
|
162
|
+
'@jupyter/plugin-id-convention': 'warn',
|
|
163
|
+
'@jupyter/no-translation-concatenation': 'error',
|
|
164
|
+
'@jupyter/no-dynamic-translation': 'warn',
|
|
165
|
+
'@jupyter/token-format': 'error',
|
|
166
|
+
'@jupyter/no-untranslated-string': 'warn',
|
|
167
|
+
'@jupyter/no-schema-enum': 'warn',
|
|
168
|
+
'@jupyter/no-pageconfig-base-url': 'warn',
|
|
169
|
+
'@jupyter/require-signal-cleanup': 'warn',
|
|
170
|
+
'@jupyter/require-signal-this-arg': 'error',
|
|
171
|
+
'@jupyter/prefer-signal-this-arg': 'warn',
|
|
172
|
+
'@jupyter/require-disposable-ownership': 'warn',
|
|
173
|
+
'@jupyter/require-disposable-transfer': 'warn',
|
|
174
|
+
'@jupyter/incorrect-translator-usage': 'warn',
|
|
175
|
+
'@jupyter/prefer-lazy-imports': 'warn'
|
|
157
176
|
},
|
|
158
177
|
overrides: [
|
|
159
178
|
{
|
|
@@ -164,18 +183,20 @@ const plugin = {
|
|
|
164
183
|
'**/*.test.js'
|
|
165
184
|
],
|
|
166
185
|
rules: {
|
|
167
|
-
'jupyter/require-soft-assertions-before-snapshots': 'warn',
|
|
168
|
-
'jupyter/galata-prefer-context-menu-helper': 'warn',
|
|
169
|
-
'jupyter/galata-prefer-filebrowser-helper': 'warn',
|
|
170
|
-
'jupyter/galata-prefer-menu-helper': 'warn',
|
|
171
|
-
'jupyter/galata-prefer-notebook-cell-helper': 'warn',
|
|
172
|
-
'jupyter/galata-prefer-sidebar-activity-helper': 'warn',
|
|
173
|
-
'jupyter/prefer-lazy-imports': 'off',
|
|
174
|
-
'jupyter/plugin-id-convention': 'off'
|
|
186
|
+
'@jupyter/require-soft-assertions-before-snapshots': 'warn',
|
|
187
|
+
'@jupyter/galata-prefer-context-menu-helper': 'warn',
|
|
188
|
+
'@jupyter/galata-prefer-filebrowser-helper': 'warn',
|
|
189
|
+
'@jupyter/galata-prefer-menu-helper': 'warn',
|
|
190
|
+
'@jupyter/galata-prefer-notebook-cell-helper': 'warn',
|
|
191
|
+
'@jupyter/galata-prefer-sidebar-activity-helper': 'warn',
|
|
192
|
+
'@jupyter/prefer-lazy-imports': 'off',
|
|
193
|
+
'@jupyter/plugin-id-convention': 'off',
|
|
194
|
+
'@jupyter/command-id-convention': 'off'
|
|
175
195
|
}
|
|
176
196
|
}
|
|
177
197
|
]
|
|
178
198
|
}
|
|
179
199
|
}
|
|
180
200
|
};
|
|
201
|
+
plugins.jupyter = plugin;
|
|
181
202
|
module.exports = plugin;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
const plugin_utils_1 = require("../utils/plugin-utils");
|
|
7
7
|
const commands_1 = require("../utils/commands");
|
|
8
|
+
const type_services_1 = require("../utils/type-services");
|
|
8
9
|
const create_rule_1 = require("../utils/create-rule");
|
|
9
10
|
const jupyterCommandDescribedBy = (0, create_rule_1.createRule)({
|
|
10
11
|
name: 'command-described-by',
|
|
@@ -21,32 +22,17 @@ const jupyterCommandDescribedBy = (0, create_rule_1.createRule)({
|
|
|
21
22
|
},
|
|
22
23
|
defaultOptions: [],
|
|
23
24
|
create(context) {
|
|
25
|
+
const { checker, getTSNode } = (0, type_services_1.getTypeServices)(context);
|
|
24
26
|
return {
|
|
25
27
|
CallExpression(node) {
|
|
26
28
|
// Check if this is <something>.addCommand()
|
|
27
|
-
if (!(0, commands_1.isAddCommandCall)(node)) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
// Get the command ID and options
|
|
31
|
-
if (node.arguments.length < 2) {
|
|
29
|
+
if (!(0, commands_1.isAddCommandCall)(node) || node.arguments.length < 2) {
|
|
32
30
|
return;
|
|
33
31
|
}
|
|
34
32
|
const commandIdArg = node.arguments[0];
|
|
35
33
|
const optionsArg = node.arguments[1];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (commandIdArg.type === 'Literal' &&
|
|
39
|
-
typeof commandIdArg.value === 'string') {
|
|
40
|
-
commandId = commandIdArg.value;
|
|
41
|
-
}
|
|
42
|
-
else if (commandIdArg.type === 'Identifier') {
|
|
43
|
-
commandId = commandIdArg.name;
|
|
44
|
-
}
|
|
45
|
-
else if (commandIdArg.type === 'MemberExpression') {
|
|
46
|
-
// Handle CommandIDs.something pattern
|
|
47
|
-
if (commandIdArg.property.type === 'Identifier') {
|
|
48
|
-
commandId = commandIdArg.property.name;
|
|
49
|
-
}
|
|
34
|
+
if (commandIdArg.type === 'SpreadElement') {
|
|
35
|
+
return;
|
|
50
36
|
}
|
|
51
37
|
// Options must be an object
|
|
52
38
|
if (optionsArg.type !== 'ObjectExpression') {
|
|
@@ -58,18 +44,23 @@ const jupyterCommandDescribedBy = (0, create_rule_1.createRule)({
|
|
|
58
44
|
if (!executeProp || executeProp.value.type === 'Literal') {
|
|
59
45
|
return;
|
|
60
46
|
}
|
|
61
|
-
|
|
62
|
-
if (!describedByProp) {
|
|
63
|
-
context.report({
|
|
64
|
-
node,
|
|
65
|
-
messageId: 'missingDescribedBy',
|
|
66
|
-
data: { commandId }
|
|
67
|
-
});
|
|
47
|
+
if (properties.has('describedBy')) {
|
|
68
48
|
return;
|
|
69
49
|
}
|
|
70
|
-
|
|
50
|
+
// A registry created on the spot, such as one backing a context
|
|
51
|
+
// menu, is never listed or queried alongside the application's.
|
|
52
|
+
const callee = node.callee;
|
|
53
|
+
if (callee.object.type !== 'Super' &&
|
|
54
|
+
(0, commands_1.isPrivateCommandRegistry)(callee.object, context.sourceCode.getScope(node))) {
|
|
71
55
|
return;
|
|
72
56
|
}
|
|
57
|
+
// Extract command ID for error message
|
|
58
|
+
const commandId = (0, commands_1.resolveCommandId)(commandIdArg, context.sourceCode, checker, getTSNode) ?? context.sourceCode.getText(commandIdArg);
|
|
59
|
+
context.report({
|
|
60
|
+
node,
|
|
61
|
+
messageId: 'missingDescribedBy',
|
|
62
|
+
data: { commandId }
|
|
63
|
+
});
|
|
73
64
|
}
|
|
74
65
|
};
|
|
75
66
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Jupyter Development Team.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
7
|
+
const commands_1 = require("../utils/commands");
|
|
8
|
+
const create_rule_1 = require("../utils/create-rule");
|
|
9
|
+
const commandIdConvention = (0, create_rule_1.createRule)({
|
|
10
|
+
name: 'command-id-convention',
|
|
11
|
+
meta: {
|
|
12
|
+
type: 'suggestion',
|
|
13
|
+
docs: {
|
|
14
|
+
description: 'Ensure JupyterLab command IDs follow the "namespace:name" convention',
|
|
15
|
+
url: 'https://eslint-plugin.readthedocs.io/en/latest/rules/command-id-convention/'
|
|
16
|
+
},
|
|
17
|
+
messages: {
|
|
18
|
+
missingNamespace: 'Command ID "{{ commandId }}" has no namespace; use the "namespace:name" form, e.g. "my-extension:{{ commandId }}".',
|
|
19
|
+
emptySegment: 'Command ID "{{ commandId }}" has an empty {{ segment }}; use the "namespace:name" form.'
|
|
20
|
+
},
|
|
21
|
+
schema: []
|
|
22
|
+
},
|
|
23
|
+
defaultOptions: [],
|
|
24
|
+
create(context) {
|
|
25
|
+
let services = null;
|
|
26
|
+
let checker = null;
|
|
27
|
+
try {
|
|
28
|
+
services = utils_1.ESLintUtils.getParserServices(context, true);
|
|
29
|
+
checker = services.program ? services.program.getTypeChecker() : null;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
services = null;
|
|
33
|
+
}
|
|
34
|
+
const getTSNode = services
|
|
35
|
+
? (node) => services?.esTreeNodeToTSNodeMap.get(node)
|
|
36
|
+
: null;
|
|
37
|
+
return {
|
|
38
|
+
CallExpression(node) {
|
|
39
|
+
// `addCommand(id, options)`: the arity filters out unrelated methods
|
|
40
|
+
// that happen to share the name.
|
|
41
|
+
if (!(0, commands_1.isAddCommandCall)(node) || node.arguments.length < 2) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const idArg = node.arguments[0];
|
|
45
|
+
if (idArg.type === 'SpreadElement') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// A registry created on the spot, such as one backing a context
|
|
49
|
+
// menu, is never listed or queried alongside the application's.
|
|
50
|
+
const callee = node.callee;
|
|
51
|
+
if (callee.object.type !== 'Super' &&
|
|
52
|
+
(0, commands_1.isPrivateCommandRegistry)(callee.object, context.sourceCode.getScope(node))) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const commandId = (0, commands_1.resolveCommandId)(idArg, context.sourceCode, checker, getTSNode);
|
|
56
|
+
if (commandId === null) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
// The namespace is everything before the first `:`, as in the
|
|
60
|
+
// `namespace:name` form used by JupyterLab's own commands; the name
|
|
61
|
+
// itself may contain further colons.
|
|
62
|
+
const separator = commandId.indexOf(':');
|
|
63
|
+
if (separator === -1) {
|
|
64
|
+
context.report({
|
|
65
|
+
node: idArg,
|
|
66
|
+
messageId: 'missingNamespace',
|
|
67
|
+
data: { commandId }
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const segment = separator === 0
|
|
72
|
+
? 'namespace'
|
|
73
|
+
: separator === commandId.length - 1
|
|
74
|
+
? 'name'
|
|
75
|
+
: null;
|
|
76
|
+
if (segment) {
|
|
77
|
+
context.report({
|
|
78
|
+
node: idArg,
|
|
79
|
+
messageId: 'emptySegment',
|
|
80
|
+
data: { commandId, segment }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
module.exports = commandIdConvention;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare const noUntranslatedString: import("@typescript-eslint/utils/ts-eslint").RuleModule<"untranslatedCommandProp" | "untranslatedSetAttribute" | "untranslatedPropertyAssign" | "untranslatedDialogOption" | "untranslatedDialogButtonLabel" | "untranslatedJsxText" | "untranslatedJsxAttribute" | "untranslatedProperty", [{
|
|
2
2
|
enforcePunctuation: boolean;
|
|
3
|
-
checkProperties: string[];
|
|
3
|
+
checkProperties: string[] | undefined;
|
|
4
|
+
extendDefaultCheckProperties: boolean;
|
|
4
5
|
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
5
6
|
name: string;
|
|
6
7
|
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Distributed under the terms of the Modified BSD License.
|
|
5
5
|
*/
|
|
6
6
|
const commands_1 = require("../utils/commands");
|
|
7
|
+
const options_1 = require("../utils/options");
|
|
7
8
|
const plugin_utils_1 = require("../utils/plugin-utils");
|
|
8
9
|
const translation_1 = require("../utils/translation");
|
|
9
10
|
const create_rule_1 = require("../utils/create-rule");
|
|
@@ -151,7 +152,13 @@ const noUntranslatedString = (0, create_rule_1.createRule)({
|
|
|
151
152
|
checkProperties: {
|
|
152
153
|
type: 'array',
|
|
153
154
|
items: { type: 'string' },
|
|
154
|
-
uniqueItems: true
|
|
155
|
+
uniqueItems: true,
|
|
156
|
+
description: 'Property or attribute names checked for untranslated strings. Added to the built-in defaults unless extendDefaultCheckProperties is false.'
|
|
157
|
+
},
|
|
158
|
+
extendDefaultCheckProperties: {
|
|
159
|
+
type: 'boolean',
|
|
160
|
+
default: true,
|
|
161
|
+
description: 'Whether checkProperties extends the built-in defaults. Set to false to replace them, or to drop them entirely when no list is given.'
|
|
155
162
|
}
|
|
156
163
|
},
|
|
157
164
|
additionalProperties: false
|
|
@@ -161,13 +168,14 @@ const noUntranslatedString = (0, create_rule_1.createRule)({
|
|
|
161
168
|
defaultOptions: [
|
|
162
169
|
{
|
|
163
170
|
enforcePunctuation: false,
|
|
164
|
-
checkProperties:
|
|
171
|
+
checkProperties: undefined,
|
|
172
|
+
extendDefaultCheckProperties: true
|
|
165
173
|
}
|
|
166
174
|
],
|
|
167
175
|
create(context) {
|
|
168
176
|
const options = context.options[0];
|
|
169
177
|
const enforcePunctuation = options?.enforcePunctuation ?? false;
|
|
170
|
-
const checkProperties =
|
|
178
|
+
const checkProperties = (0, options_1.resolveNameListOption)(options?.checkProperties?.map(normalizeName), DEFAULT_CHECK_PROPERTIES.map(normalizeName), options?.extendDefaultCheckProperties !== false);
|
|
171
179
|
function isMonitoredName(name) {
|
|
172
180
|
return checkProperties.has(normalizeName(name));
|
|
173
181
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const jupyterPluginActivationArgs:
|
|
1
|
+
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
declare const jupyterPluginActivationArgs: TSESLint.RuleModule<"mismatchedOrder" | "incorrectType" | "missingArgument" | "extraArgument" | "appNotFirst" | "serviceManagerFirstArgNotNull" | "invalidAppType" | "wrongArgumentCount" | "unresolvableTokenType" | "optionalNotNullable", [{
|
|
3
3
|
allowedFirstArgumentNames: string[];
|
|
4
|
-
}], unknown,
|
|
4
|
+
}], unknown, TSESLint.RuleListener> & {
|
|
5
5
|
name: string;
|
|
6
6
|
};
|
|
7
7
|
export = jupyterPluginActivationArgs;
|