@nx/eslint-plugin 21.2.2 → 21.3.0-beta.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.3.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The eslint-plugin package is an ESLint plugin that contains a collection of recommended ESLint rule configurations which you can extend from in your own ESLint configs, as well as an Nx-specific lint rule called enforce-module-boundaries.",
|
|
6
6
|
"repository": {
|
|
@@ -34,9 +34,8 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "21.
|
|
38
|
-
"@nx/js": "21.
|
|
39
|
-
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
37
|
+
"@nx/devkit": "21.3.0-beta.0",
|
|
38
|
+
"@nx/js": "21.3.0-beta.0",
|
|
40
39
|
"@typescript-eslint/type-utils": "^8.0.0",
|
|
41
40
|
"@typescript-eslint/utils": "^8.0.0",
|
|
42
41
|
"chalk": "^4.1.0",
|
|
@@ -24,4 +24,3 @@ export declare function validateEntry(baseNode: AST.JSONObjectExpression, key: s
|
|
|
24
24
|
export declare function validateImplementationNode(implementationNode: AST.JSONProperty, key: string, context: TSESLint.RuleContext<MessageIds, Options>, options: NormalizedOptions): void;
|
|
25
25
|
export declare function validatePackageGroup(baseNode: AST.JSONObjectExpression, context: TSESLint.RuleContext<MessageIds, Options>): void;
|
|
26
26
|
export declare function validateVersionJsonExpression(node: AST.JSONExpression, context: TSESLint.RuleContext<MessageIds, Options>): string | boolean;
|
|
27
|
-
export declare function checkIfIdentifierIsFunction(filePath: string, identifier: string): boolean;
|
|
@@ -7,11 +7,8 @@ exports.validateEntry = validateEntry;
|
|
|
7
7
|
exports.validateImplementationNode = validateImplementationNode;
|
|
8
8
|
exports.validatePackageGroup = validatePackageGroup;
|
|
9
9
|
exports.validateVersionJsonExpression = validateVersionJsonExpression;
|
|
10
|
-
exports.checkIfIdentifierIsFunction = checkIfIdentifierIsFunction;
|
|
11
10
|
const tslib_1 = require("tslib");
|
|
12
11
|
const utils_1 = require("@typescript-eslint/utils");
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
|
-
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
15
12
|
const devkit_1 = require("@nx/devkit");
|
|
16
13
|
const js_1 = require("@nx/js");
|
|
17
14
|
const internal_1 = require("@nx/js/src/internal");
|
|
@@ -349,7 +346,8 @@ function validateImplementationNode(implementationNode, key, context, options) {
|
|
|
349
346
|
}
|
|
350
347
|
if (identifier) {
|
|
351
348
|
try {
|
|
352
|
-
|
|
349
|
+
const m = require(resolvedPath);
|
|
350
|
+
if (!(identifier in m && typeof m[identifier] === 'function')) {
|
|
353
351
|
context.report({
|
|
354
352
|
messageId: 'invalidImplementationModule',
|
|
355
353
|
node: implementationNode.value,
|
|
@@ -361,7 +359,6 @@ function validateImplementationNode(implementationNode, key, context, options) {
|
|
|
361
359
|
}
|
|
362
360
|
}
|
|
363
361
|
catch {
|
|
364
|
-
// require can throw if the module is not found
|
|
365
362
|
context.report({
|
|
366
363
|
messageId: 'unableToReadImplementationExports',
|
|
367
364
|
node: implementationNode.value,
|
|
@@ -432,26 +429,3 @@ function validateVersionJsonExpression(node, context) {
|
|
|
432
429
|
((0, semver_1.valid)(node.value) ||
|
|
433
430
|
context.options[0]?.allowedVersionStrings.includes(node.value)));
|
|
434
431
|
}
|
|
435
|
-
function checkIfIdentifierIsFunction(filePath, identifier) {
|
|
436
|
-
try {
|
|
437
|
-
const ts = require('typescript');
|
|
438
|
-
const sourceCode = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
439
|
-
const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true);
|
|
440
|
-
const exportedFunctions = (0, tsquery_1.tsquery)(sourceFile, `
|
|
441
|
-
FunctionDeclaration[name.text="${identifier}"][modifiers],
|
|
442
|
-
ExportDeclaration > FunctionDeclaration[name.text="${identifier}"],
|
|
443
|
-
VariableStatement[modifiers] VariableDeclaration[name.text="${identifier}"] ArrowFunction,
|
|
444
|
-
VariableStatement[modifiers] VariableDeclaration[name.text="${identifier}"] FunctionExpression,
|
|
445
|
-
ExportDeclaration > VariableStatement VariableDeclaration[name.text="${identifier}"] ArrowFunction,
|
|
446
|
-
ExportDeclaration > VariableStatement VariableDeclaration[name.text="${identifier}"] FunctionExpression,
|
|
447
|
-
ExportDeclaration ExportSpecifier[name.text="${identifier}"]
|
|
448
|
-
`);
|
|
449
|
-
return exportedFunctions.length > 0;
|
|
450
|
-
}
|
|
451
|
-
catch {
|
|
452
|
-
// ignore
|
|
453
|
-
}
|
|
454
|
-
// Fallback to require()
|
|
455
|
-
const m = require(filePath);
|
|
456
|
-
return identifier in m && typeof m[identifier] === 'function';
|
|
457
|
-
}
|