eslint-plugin-use-agnostic 0.11.4 → 0.11.5
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
CHANGED
|
@@ -78,7 +78,7 @@ Base url and aliased import paths are currently resolved under the assumption th
|
|
|
78
78
|
|
|
79
79
|
It is up to you to confirm that your Agnostic Modules are indeed agnostic, meaning that they have neither server- nor client-side code. `eslint-plugin-use-agnostic`, at least at this time, does not do this verification for you.
|
|
80
80
|
|
|
81
|
-
It is also up to you to ensure, as outlined above, that **you
|
|
81
|
+
It is also up to you to ensure, as outlined above, that **you avoid** exporting React components along with other logics within the same module, which may derail the linting in some cases. Separating exporting React components within their own modules ending with a JSX file extension, from exporting other logics within modules that don't end with a JSX file extension, is crucial for distinguishing between Components Modules and Logics Modules respectively.
|
|
82
82
|
|
|
83
83
|
The import rules are designed to be as permissive as possible, allowing for more obscure use cases as long as they are non-breaking. However, it is still your responsibility as a developer to, within a file, not mix in incompatible ways code that cannot compose.
|
|
84
84
|
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
|
|
21
|
-
* @
|
|
21
|
+
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} U
|
|
22
|
+
* @typedef {import('../../../types/_commons/typedefs').ResolvedDirectives_BlockedImports<T, U>} ResolvedDirectives_BlockedImports
|
|
22
23
|
*/
|
|
23
24
|
|
|
24
25
|
/* resolveImportPath */
|
|
@@ -98,14 +99,14 @@ export const getASTFromFilePath = (resolvedPath) => {
|
|
|
98
99
|
linter.verify(text, { languageOptions: typeScriptAndJSXCompatible });
|
|
99
100
|
// ... to retrieve the raw code as a SourceCode object ...
|
|
100
101
|
const code = linter.getSourceCode();
|
|
101
|
-
// ... from which to
|
|
102
|
+
// ... from which to extract the ESLint-generated AST
|
|
102
103
|
const ast = code.ast;
|
|
103
104
|
|
|
104
105
|
return ast;
|
|
105
106
|
};
|
|
106
107
|
|
|
107
108
|
/* getImportedFileFirstLine */ // for directive21
|
|
108
|
-
// Note: For directive21, I prioritize reading from the file system for performance,
|
|
109
|
+
// Note: For directive21, I prioritize reading from the file system for performance, foregoing the retrieval of the source code comments for imported modules, since the Directive-First Architecture imposes that the first line of the file is reserved for its commented directive.
|
|
109
110
|
|
|
110
111
|
/**
|
|
111
112
|
* Gets the first line of code of the imported module.
|
|
@@ -142,7 +143,7 @@ export const highlightFirstLineOfCode = (context) => ({
|
|
|
142
143
|
* Returns a boolean deciding if an imported file's "resolved" directive is incompatible with the current file's "resolved" directive.
|
|
143
144
|
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
|
|
144
145
|
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} U
|
|
145
|
-
* @param {ResolvedDirectives_BlockedImports<T>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
|
|
146
|
+
* @param {ResolvedDirectives_BlockedImports<T, U>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
|
|
146
147
|
* @param {T} currentFileResolvedDirective The current file's "resolved" directive.
|
|
147
148
|
* @param {U} importedFileResolvedDirective The imported file's "resolved" directive.
|
|
148
149
|
* @returns `true` if the import is blocked, as established in respective `resolvedDirectives_blockedImports`.
|
|
@@ -182,7 +183,8 @@ export const makeIntroForSpecificViolationMessage = (
|
|
|
182
183
|
/**
|
|
183
184
|
* Lists in an message the "resolved" modules incompatible with a "resolved" module based on its "resolved" directive.
|
|
184
185
|
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
|
|
185
|
-
* @
|
|
186
|
+
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} U
|
|
187
|
+
* @param {ResolvedDirectives_BlockedImports<T, U>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
|
|
186
188
|
* @param {T} currentFileResolvedDirective The "resolved" directive of the "resolved" module.
|
|
187
189
|
* @returns The message listing the incompatible "resolved" modules.
|
|
188
190
|
*/
|
|
@@ -223,7 +225,7 @@ export const makeMessageFromCurrentFileResolvedDirective = (
|
|
|
223
225
|
* Finds the `message` for the specific violation of "resolved" directives import rules based on `resolvedDirectives_blockedImports`.
|
|
224
226
|
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} T
|
|
225
227
|
* @template {ResolvedDirectiveWithoutUseAgnosticStrategies} U
|
|
226
|
-
* @param {ResolvedDirectives_BlockedImports<T>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
|
|
228
|
+
* @param {ResolvedDirectives_BlockedImports<T, U>} resolvedDirectives_blockedImports The blocked imports object, either for agnostic20 or for directive21.
|
|
227
229
|
* @param {T} currentFileResolvedDirective The current file's "resolved" directive.
|
|
228
230
|
* @param {U} importedFileResolvedDirective The imported file's "resolved" directive.
|
|
229
231
|
* @returns The corresponding `message`.
|
|
@@ -139,7 +139,7 @@ const makeBlockedImportSuggestingUseAgnostic = (
|
|
|
139
139
|
};
|
|
140
140
|
|
|
141
141
|
export const effectiveDirectives_blockedImports = Object.freeze({
|
|
142
|
-
[USE_SERVER_LOGICS]: [
|
|
142
|
+
[USE_SERVER_LOGICS]: Object.freeze([
|
|
143
143
|
// USE_SERVER_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_LOGICS
|
|
144
144
|
// USE_SERVER_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_COMPONENTS
|
|
145
145
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_SERVER_FUNCTIONS
|
|
@@ -153,8 +153,8 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
153
153
|
) /* $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_CLIENT_COMPONENTS */,
|
|
154
154
|
// USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_AGNOSTIC_LOGICS
|
|
155
155
|
// USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_LOGICS#USE_AGNOSTIC_COMPONENTS
|
|
156
|
-
],
|
|
157
|
-
[USE_SERVER_COMPONENTS]: [
|
|
156
|
+
]),
|
|
157
|
+
[USE_SERVER_COMPONENTS]: Object.freeze([
|
|
158
158
|
// USE_SERVER_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_LOGICS
|
|
159
159
|
// USE_SERVER_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_COMPONENTS
|
|
160
160
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_SERVER_FUNCTIONS
|
|
@@ -165,8 +165,8 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
165
165
|
// USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_CLIENT_COMPONENTS
|
|
166
166
|
// USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_AGNOSTIC_LOGICS
|
|
167
167
|
// USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_COMPONENTS#USE_AGNOSTIC_COMPONENTS
|
|
168
|
-
],
|
|
169
|
-
[USE_SERVER_FUNCTIONS]: [
|
|
168
|
+
]),
|
|
169
|
+
[USE_SERVER_FUNCTIONS]: Object.freeze([
|
|
170
170
|
// USE_SERVER_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_SERVER_LOGICS
|
|
171
171
|
makeBlockedImport(
|
|
172
172
|
USE_SERVER_FUNCTIONS,
|
|
@@ -186,8 +186,8 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
186
186
|
USE_SERVER_FUNCTIONS,
|
|
187
187
|
USE_AGNOSTIC_COMPONENTS
|
|
188
188
|
) /* $COMMENT#AGNOSTIC20#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_COMPONENTS */,
|
|
189
|
-
],
|
|
190
|
-
[USE_CLIENT_LOGICS]: [
|
|
189
|
+
]),
|
|
190
|
+
[USE_CLIENT_LOGICS]: Object.freeze([
|
|
191
191
|
makeBlockedImportSuggestingUseAgnostic(
|
|
192
192
|
USE_CLIENT_LOGICS,
|
|
193
193
|
USE_SERVER_LOGICS
|
|
@@ -201,8 +201,8 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
201
201
|
// USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_CLIENT_COMPONENTS
|
|
202
202
|
// USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_AGNOSTIC_LOGICS
|
|
203
203
|
// USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_LOGICS#USE_AGNOSTIC_COMPONENTS
|
|
204
|
-
],
|
|
205
|
-
[USE_CLIENT_COMPONENTS]: [
|
|
204
|
+
]),
|
|
205
|
+
[USE_CLIENT_COMPONENTS]: Object.freeze([
|
|
206
206
|
makeBlockedImportSuggestingUseAgnostic(
|
|
207
207
|
USE_CLIENT_LOGICS,
|
|
208
208
|
USE_SERVER_LOGICS
|
|
@@ -216,8 +216,8 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
216
216
|
// USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_CLIENT_COMPONENTS
|
|
217
217
|
// USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_LOGICS
|
|
218
218
|
// USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_COMPONENTS
|
|
219
|
-
],
|
|
220
|
-
[USE_AGNOSTIC_LOGICS]: [
|
|
219
|
+
]),
|
|
220
|
+
[USE_AGNOSTIC_LOGICS]: Object.freeze([
|
|
221
221
|
makeBlockedImportSuggestingUseAgnostic(
|
|
222
222
|
USE_AGNOSTIC_LOGICS,
|
|
223
223
|
USE_SERVER_LOGICS
|
|
@@ -240,8 +240,8 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
240
240
|
) /* $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_CLIENT_COMPONENTS */,
|
|
241
241
|
// USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_LOGICS
|
|
242
242
|
// USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_COMPONENTS
|
|
243
|
-
],
|
|
244
|
-
[USE_AGNOSTIC_COMPONENTS]: [
|
|
243
|
+
]),
|
|
244
|
+
[USE_AGNOSTIC_COMPONENTS]: Object.freeze([
|
|
245
245
|
makeBlockedImportSuggestingUseAgnostic(
|
|
246
246
|
USE_AGNOSTIC_COMPONENTS,
|
|
247
247
|
USE_SERVER_LOGICS
|
|
@@ -258,5 +258,5 @@ export const effectiveDirectives_blockedImports = Object.freeze({
|
|
|
258
258
|
// USE_CLIENT_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_COMPONENTS
|
|
259
259
|
// USE_AGNOSTIC_LOGICS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_LOGICS
|
|
260
260
|
// USE_AGNOSTIC_COMPONENTS allowed, because $COMMENT#AGNOSTIC20#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_COMPONENTS
|
|
261
|
-
],
|
|
261
|
+
]),
|
|
262
262
|
});
|
|
@@ -210,7 +210,7 @@ export const makeBlockedImport = (
|
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
export const commentedDirectives_blockedImports = Object.freeze({
|
|
213
|
-
[USE_SERVER_LOGICS]: [
|
|
213
|
+
[USE_SERVER_LOGICS]: Object.freeze([
|
|
214
214
|
// USE_SERVER_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_SERVER_LOGICS
|
|
215
215
|
makeBlockedImport(
|
|
216
216
|
USE_SERVER_LOGICS,
|
|
@@ -229,8 +229,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
229
229
|
USE_CLIENT_CONTEXTS
|
|
230
230
|
) /* $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_CLIENT_CONTEXTS */,
|
|
231
231
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_LOGICS#USE_AGNOSTIC_CONDITIONS
|
|
232
|
-
],
|
|
233
|
-
[USE_CLIENT_LOGICS]: [
|
|
232
|
+
]),
|
|
233
|
+
[USE_CLIENT_LOGICS]: Object.freeze([
|
|
234
234
|
makeBlockedImport(
|
|
235
235
|
USE_CLIENT_LOGICS,
|
|
236
236
|
USE_SERVER_LOGICS
|
|
@@ -246,8 +246,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
246
246
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_SERVER_FUNCTIONS
|
|
247
247
|
// USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_CLIENT_CONTEXTS
|
|
248
248
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_LOGICS#USE_AGNOSTIC_CONDITIONS
|
|
249
|
-
],
|
|
250
|
-
[USE_AGNOSTIC_LOGICS]: [
|
|
249
|
+
]),
|
|
250
|
+
[USE_AGNOSTIC_LOGICS]: Object.freeze([
|
|
251
251
|
makeBlockedImport(
|
|
252
252
|
USE_AGNOSTIC_LOGICS,
|
|
253
253
|
USE_SERVER_LOGICS
|
|
@@ -275,8 +275,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
275
275
|
USE_CLIENT_CONTEXTS
|
|
276
276
|
) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_CLIENT_CONTEXTS */,
|
|
277
277
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_LOGICS#USE_AGNOSTIC_CONDITIONS
|
|
278
|
-
],
|
|
279
|
-
[USE_SERVER_COMPONENTS]: [
|
|
278
|
+
]),
|
|
279
|
+
[USE_SERVER_COMPONENTS]: Object.freeze([
|
|
280
280
|
// USE_SERVER_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_LOGICS
|
|
281
281
|
makeBlockedImport(
|
|
282
282
|
USE_SERVER_COMPONENTS,
|
|
@@ -289,8 +289,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
289
289
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_SERVER_FUNCTIONS
|
|
290
290
|
// USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_CLIENT_CONTEXTS
|
|
291
291
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_COMPONENTS#USE_AGNOSTIC_CONDITIONS
|
|
292
|
-
],
|
|
293
|
-
[USE_CLIENT_COMPONENTS]: [
|
|
292
|
+
]),
|
|
293
|
+
[USE_CLIENT_COMPONENTS]: Object.freeze([
|
|
294
294
|
makeBlockedImport(
|
|
295
295
|
USE_CLIENT_COMPONENTS,
|
|
296
296
|
USE_SERVER_LOGICS
|
|
@@ -306,8 +306,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
306
306
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_SERVER_FUNCTIONS
|
|
307
307
|
// USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_CLIENT_CONTEXTS
|
|
308
308
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_COMPONENTS#USE_AGNOSTIC_CONDITIONS
|
|
309
|
-
],
|
|
310
|
-
[USE_AGNOSTIC_COMPONENTS]: [
|
|
309
|
+
]),
|
|
310
|
+
[USE_AGNOSTIC_COMPONENTS]: Object.freeze([
|
|
311
311
|
makeBlockedImport(
|
|
312
312
|
USE_AGNOSTIC_COMPONENTS,
|
|
313
313
|
USE_SERVER_LOGICS
|
|
@@ -326,8 +326,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
326
326
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_SERVER_FUNCTIONS
|
|
327
327
|
// USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_CLIENT_CONTEXTS
|
|
328
328
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_COMPONENTS#USE_AGNOSTIC_CONDITIONS
|
|
329
|
-
],
|
|
330
|
-
[USE_SERVER_FUNCTIONS]: [
|
|
329
|
+
]),
|
|
330
|
+
[USE_SERVER_FUNCTIONS]: Object.freeze([
|
|
331
331
|
// USE_SERVER_LOGICS allowed, because $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_SERVER_LOGICS
|
|
332
332
|
makeBlockedImport(
|
|
333
333
|
USE_SERVER_FUNCTIONS,
|
|
@@ -355,8 +355,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
355
355
|
USE_SERVER_FUNCTIONS,
|
|
356
356
|
USE_AGNOSTIC_CONDITIONS
|
|
357
357
|
) /* $COMMENT#DIRECTIVE21#USE_SERVER_FUNCTIONS#USE_AGNOSTIC_CONDITIONS */,
|
|
358
|
-
],
|
|
359
|
-
[USE_CLIENT_CONTEXTS]: [
|
|
358
|
+
]),
|
|
359
|
+
[USE_CLIENT_CONTEXTS]: Object.freeze([
|
|
360
360
|
makeBlockedImport(
|
|
361
361
|
USE_CLIENT_CONTEXTS,
|
|
362
362
|
USE_SERVER_LOGICS
|
|
@@ -372,8 +372,8 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
372
372
|
// USE_SERVER_FUNCTIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_SERVER_FUNCTIONS
|
|
373
373
|
// USE_CLIENT_CONTEXTS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_CLIENT_CONTEXTS
|
|
374
374
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_CLIENT_CONTEXTS#USE_AGNOSTIC_CONDITIONS
|
|
375
|
-
],
|
|
376
|
-
[USE_AGNOSTIC_CONDITIONS]: [
|
|
375
|
+
]),
|
|
376
|
+
[USE_AGNOSTIC_CONDITIONS]: Object.freeze([
|
|
377
377
|
makeBlockedImport(
|
|
378
378
|
USE_AGNOSTIC_CONDITIONS,
|
|
379
379
|
USE_SERVER_LOGICS
|
|
@@ -395,5 +395,5 @@ export const commentedDirectives_blockedImports = Object.freeze({
|
|
|
395
395
|
USE_CLIENT_CONTEXTS
|
|
396
396
|
) /* $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_CLIENT_CONTEXTS */,
|
|
397
397
|
// USE_AGNOSTIC_CONDITIONS allowed, because $COMMENT#DIRECTIVE21#USE_AGNOSTIC_CONDITIONS#USE_AGNOSTIC_CONDITIONS
|
|
398
|
-
],
|
|
398
|
+
]),
|
|
399
399
|
});
|
|
@@ -219,14 +219,42 @@ export const getStrategizedDirective = (context, node) => {
|
|
|
219
219
|
return commentedDirective;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
/* addressDirectiveIfAgnosticStrategies */
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Verifies the current node's export strategy if the current commented directive is `"use agnostic strategies"` by reporting `exportNotStrategized` in case an export is not strategized in an Agnostic Strategies Module.
|
|
226
|
+
* @param {Context} context The ESLint rule's `context` object.
|
|
227
|
+
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
|
|
228
|
+
* @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
|
|
229
|
+
* @returns The commented directive, the addressed strategy (as a commented directive) or `null` in case of failure.
|
|
230
|
+
*/
|
|
231
|
+
export const addressDirectiveIfAgnosticStrategies = (
|
|
232
|
+
context,
|
|
233
|
+
node,
|
|
234
|
+
currentFileCommentedDirective
|
|
235
|
+
) => {
|
|
236
|
+
// ignores if not addressing an Agnostic Strategies Module
|
|
237
|
+
if (currentFileCommentedDirective !== USE_AGNOSTIC_STRATEGIES)
|
|
238
|
+
return currentFileCommentedDirective;
|
|
239
|
+
|
|
240
|
+
const exportStrategizedDirective = getStrategizedDirective(context, node);
|
|
241
|
+
|
|
242
|
+
if (exportStrategizedDirective === null) {
|
|
243
|
+
context.report({
|
|
244
|
+
node,
|
|
245
|
+
messageId: exportNotStrategized,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return exportStrategizedDirective; // null indicates failure
|
|
250
|
+
};
|
|
251
|
+
|
|
222
252
|
/* isImportBlocked */
|
|
223
253
|
|
|
224
254
|
/**
|
|
225
255
|
* Returns a boolean deciding if an imported file's commented directive is incompatible with the current file's commented directive.
|
|
226
|
-
* @
|
|
227
|
-
* @
|
|
228
|
-
* @param {T} currentFileCommentedDirective The current file's commented directive.
|
|
229
|
-
* @param {U} importedFileCommentedDirective The imported file's commented directive.
|
|
256
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective The current file's commented directive.
|
|
257
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
|
|
230
258
|
* @returns `true` if the import is blocked, as established in `commentedDirectives_BlockedImports`.
|
|
231
259
|
*/
|
|
232
260
|
export const isImportBlocked = (
|
|
@@ -258,10 +286,8 @@ export const makeMessageFromCurrentFileCommentedDirective = (
|
|
|
258
286
|
|
|
259
287
|
/**
|
|
260
288
|
* Finds the `message` for the specific violation of commented directives import rules based on `commentedDirectives_BlockedImports`.
|
|
261
|
-
* @
|
|
262
|
-
* @
|
|
263
|
-
* @param {T} currentFileCommentedDirective The current file's commented directive.
|
|
264
|
-
* @param {U} importedFileCommentedDirective The imported file's commented directive.
|
|
289
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} currentFileCommentedDirective The current file's commented directive.
|
|
290
|
+
* @param {CommentedDirectiveWithoutUseAgnosticStrategies} importedFileCommentedDirective The imported file's commented directive.
|
|
265
291
|
* @returns The corresponding `message`.
|
|
266
292
|
*/
|
|
267
293
|
export const findSpecificViolationMessage = (
|
|
@@ -273,33 +299,3 @@ export const findSpecificViolationMessage = (
|
|
|
273
299
|
currentFileCommentedDirective,
|
|
274
300
|
importedFileCommentedDirective
|
|
275
301
|
);
|
|
276
|
-
|
|
277
|
-
/* addressDirectiveIfAgnosticStrategies */
|
|
278
|
-
|
|
279
|
-
/**
|
|
280
|
-
* Verifies the current node's export strategy if the current commented directive is `"use agnostic strategies"` by reporting `exportNotStrategized` in case an export is not strategized in an Agnostic Strategies Module.
|
|
281
|
-
* @param {Context} context The ESLint rule's `context` object.
|
|
282
|
-
* @param {ExportNamedDeclaration | ExportAllDeclaration | ExportDefaultDeclaration} node The ESLint `node` of the rule's current traversal.
|
|
283
|
-
* @param {CommentedDirective} currentFileCommentedDirective The current file's commented directive.
|
|
284
|
-
* @returns The commented directive, the addressed strategy (as a commented directive) or `null` in case of failure.
|
|
285
|
-
*/
|
|
286
|
-
export const addressDirectiveIfAgnosticStrategies = (
|
|
287
|
-
context,
|
|
288
|
-
node,
|
|
289
|
-
currentFileCommentedDirective
|
|
290
|
-
) => {
|
|
291
|
-
// ignores if not addressing an Agnostic Strategies Module
|
|
292
|
-
if (currentFileCommentedDirective !== USE_AGNOSTIC_STRATEGIES)
|
|
293
|
-
return currentFileCommentedDirective;
|
|
294
|
-
|
|
295
|
-
const exportStrategizedDirective = getStrategizedDirective(context, node);
|
|
296
|
-
|
|
297
|
-
if (exportStrategizedDirective === null) {
|
|
298
|
-
context.report({
|
|
299
|
-
node,
|
|
300
|
-
messageId: exportNotStrategized,
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
return exportStrategizedDirective; // null indicates failure
|
|
305
|
-
};
|