eslint-plugin-nima 0.1.2 → 0.1.4
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/dist/index.d.ts
CHANGED
|
@@ -8,13 +8,14 @@ declare const rules: {
|
|
|
8
8
|
checkProperties: boolean;
|
|
9
9
|
checkVariables: boolean;
|
|
10
10
|
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
11
|
-
"manage-functions": RuleModule<"noOptional",
|
|
11
|
+
"manage-functions": RuleModule<"noOptional", {
|
|
12
12
|
options: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
allowFunctions?: string[];
|
|
14
|
+
disableFunctions?: string[];
|
|
15
|
+
files?: string[];
|
|
16
|
+
folders?: string[];
|
|
16
17
|
}[];
|
|
17
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
18
|
+
}[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
18
19
|
"no-handler-suffix": RuleModule<"badHandleName", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
19
20
|
"no-objects-in-deps": RuleModule<"noObjects", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
20
21
|
"params-naming-convention": RuleModule<"useObjectParams", [{
|
|
@@ -65,13 +66,14 @@ declare const plugin: {
|
|
|
65
66
|
checkProperties: boolean;
|
|
66
67
|
checkVariables: boolean;
|
|
67
68
|
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
68
|
-
"manage-functions": RuleModule<"noOptional",
|
|
69
|
+
"manage-functions": RuleModule<"noOptional", {
|
|
69
70
|
options: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
allowFunctions?: string[];
|
|
72
|
+
disableFunctions?: string[];
|
|
73
|
+
files?: string[];
|
|
74
|
+
folders?: string[];
|
|
73
75
|
}[];
|
|
74
|
-
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
76
|
+
}[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
75
77
|
"no-handler-suffix": RuleModule<"badHandleName", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
76
78
|
"no-objects-in-deps": RuleModule<"noObjects", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
77
79
|
"params-naming-convention": RuleModule<"useObjectParams", [{
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
|
|
3
|
-
export declare const rule: ESLintUtils.RuleModule<"noOptional", [{
|
|
2
|
+
type ManageFunctionsOption = {
|
|
4
3
|
options: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
allowFunctions?: string[];
|
|
5
|
+
disableFunctions?: string[];
|
|
6
|
+
files?: string[];
|
|
7
|
+
folders?: string[];
|
|
8
8
|
}[];
|
|
9
|
-
}]
|
|
9
|
+
}[];
|
|
10
|
+
export declare const name = "manage-functions";
|
|
11
|
+
export declare const rule: ESLintUtils.RuleModule<"noOptional", ManageFunctionsOption, unknown, ESLintUtils.RuleListener>;
|
|
12
|
+
export {};
|
|
@@ -1,40 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.rule = exports.name = void 0;
|
|
4
7
|
const utils_1 = require("@typescript-eslint/utils");
|
|
8
|
+
const minimatch_1 = require("minimatch");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
5
10
|
exports.name = "manage-functions";
|
|
6
11
|
exports.rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
7
12
|
create(context, options) {
|
|
8
13
|
var _a;
|
|
9
14
|
const allOptions = ((_a = options[0]) === null || _a === void 0 ? void 0 : _a.options) || [];
|
|
10
|
-
function isFileMatched(filename) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (files.some((f) => filename.endsWith(f)))
|
|
17
|
-
return true;
|
|
18
|
-
return false;
|
|
19
|
-
});
|
|
15
|
+
function isFileMatched(filename, folders, files) {
|
|
16
|
+
const dir = path_1.default.dirname(filename);
|
|
17
|
+
const base = path_1.default.basename(filename);
|
|
18
|
+
const folderMatch = folders.some((f) => (0, minimatch_1.minimatch)(dir, f));
|
|
19
|
+
const fileMatch = files.some((f) => (0, minimatch_1.minimatch)(base, f));
|
|
20
|
+
return folderMatch || fileMatch;
|
|
20
21
|
}
|
|
21
|
-
function isFunctionDisabled(
|
|
22
|
+
function isFunctionDisabled(fnName, filename) {
|
|
22
23
|
return allOptions.some((option) => {
|
|
23
24
|
const disableFunctions = option.disableFunctions || [];
|
|
24
|
-
|
|
25
|
+
const allowFunctions = option.allowFunctions || [];
|
|
26
|
+
const folders = option.folders || [];
|
|
27
|
+
const files = option.files || [];
|
|
28
|
+
if (allowFunctions.some((fn) => fn.toLowerCase() === fnName)) {
|
|
29
|
+
return !isFileMatched(filename, folders, files);
|
|
30
|
+
}
|
|
31
|
+
return disableFunctions.some((fn) => fn.toLowerCase() === fnName);
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
34
|
return {
|
|
28
35
|
CallExpression(node) {
|
|
29
36
|
const callee = node.callee;
|
|
30
|
-
|
|
31
|
-
return;
|
|
37
|
+
const filename = context.filename;
|
|
32
38
|
if (callee.type === "Identifier") {
|
|
33
|
-
if (isFunctionDisabled(callee.name.toLowerCase())) {
|
|
39
|
+
if (isFunctionDisabled(callee.name.toLowerCase(), filename)) {
|
|
34
40
|
context.report({
|
|
35
|
-
data: {
|
|
36
|
-
fnName: callee.name,
|
|
37
|
-
},
|
|
41
|
+
data: { filename, fnName: callee.name },
|
|
38
42
|
messageId: "noOptional",
|
|
39
43
|
node: callee,
|
|
40
44
|
});
|
|
@@ -42,11 +46,9 @@ exports.rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
42
46
|
}
|
|
43
47
|
else if (callee.type === "MemberExpression" &&
|
|
44
48
|
callee.property.type === "Identifier") {
|
|
45
|
-
if (isFunctionDisabled(callee.property.name.toLowerCase())) {
|
|
49
|
+
if (isFunctionDisabled(callee.property.name.toLowerCase(), filename)) {
|
|
46
50
|
context.report({
|
|
47
|
-
data: {
|
|
48
|
-
fnName: callee.property.name,
|
|
49
|
-
},
|
|
51
|
+
data: { filename, fnName: callee.property.name },
|
|
50
52
|
messageId: "noOptional",
|
|
51
53
|
node: callee.property,
|
|
52
54
|
});
|
|
@@ -59,6 +61,7 @@ exports.rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
59
61
|
{
|
|
60
62
|
options: [
|
|
61
63
|
{
|
|
64
|
+
allowFunctions: [],
|
|
62
65
|
disableFunctions: [],
|
|
63
66
|
files: [],
|
|
64
67
|
folders: [],
|
|
@@ -68,10 +71,10 @@ exports.rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
68
71
|
],
|
|
69
72
|
meta: {
|
|
70
73
|
docs: {
|
|
71
|
-
description: "Disallow use of any functions in any files or folders.",
|
|
74
|
+
description: "Disallow use of any functions in any files or folders unless explicitly allowed.",
|
|
72
75
|
},
|
|
73
76
|
messages: {
|
|
74
|
-
noOptional: "Do not use {{ fnName }}
|
|
77
|
+
noOptional: "Do not use {{ fnName }} inside {{ filename }}.",
|
|
75
78
|
},
|
|
76
79
|
schema: [
|
|
77
80
|
{
|
|
@@ -80,18 +83,10 @@ exports.rule = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
|
80
83
|
options: {
|
|
81
84
|
items: {
|
|
82
85
|
properties: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
files: {
|
|
88
|
-
items: { type: "string" },
|
|
89
|
-
type: "array",
|
|
90
|
-
},
|
|
91
|
-
folders: {
|
|
92
|
-
items: { type: "string" },
|
|
93
|
-
type: "array",
|
|
94
|
-
},
|
|
86
|
+
allowFunctions: { items: { type: "string" }, type: "array" },
|
|
87
|
+
disableFunctions: { items: { type: "string" }, type: "array" },
|
|
88
|
+
files: { items: { type: "string" }, type: "array" },
|
|
89
|
+
folders: { items: { type: "string" }, type: "array" },
|
|
95
90
|
},
|
|
96
91
|
type: "object",
|
|
97
92
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage-functions.js","sourceRoot":"","sources":["../../src/rules/manage-functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manage-functions.js","sourceRoot":"","sources":["../../src/rules/manage-functions.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAiE;AACjE,yCAAsC;AACtC,gDAAwB;AAWX,QAAA,IAAI,GAAG,kBAAkB,CAAC;AAE1B,QAAA,IAAI,GAAG,mBAAW,CAAC,WAAW,CAAC,WAAW,CAGrD;IACA,MAAM,CAAC,OAAO,EAAE,OAAO;;QACrB,MAAM,UAAU,GAAG,CAAA,MAAA,OAAO,CAAC,CAAC,CAAC,0CAAE,OAAO,KAAI,EAAE,CAAC;QAE7C,SAAS,aAAa,CACpB,QAAgB,EAChB,OAAiB,EACjB,KAAe;YAEf,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAErC,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAS,EAAC,IAAI,EAAE,CAA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,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;6BACtD;4BACD,IAAI,EAAE,QAAQ;yBACf;wBACD,IAAI,EAAE,OAAO;qBACd;iBACF;gBACD,IAAI,EAAE,QAAQ;aACf;SACF;QACD,IAAI,EAAE,SAAS;KAChB;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-nima",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "ESLint plugin for NIMA Labs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@typescript-eslint/utils": "^8.40.0",
|
|
31
|
+
"minimatch": "^10.0.3",
|
|
31
32
|
"ts-node": "^10.9.2"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|