@checkdigit/eslint-plugin 7.13.0-PR.57-e6c4 → 7.13.0-PR.57-1e3a
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-mjs/no-util.mjs +9 -6
- package/package.json +1 -1
- package/src/no-util.ts +8 -7
package/dist-mjs/no-util.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// src/no-util.ts
|
|
2
|
-
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
+
import { AST_TOKEN_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
3
|
var ruleId = "no-util";
|
|
4
4
|
var NO_UTIL = "NO_UTIL";
|
|
5
|
-
var DISABLE_NEXT_LINE = "eslint-disable-next-line";
|
|
6
5
|
var createRule = ESLintUtils.RuleCreator((name) => name);
|
|
7
6
|
var rule = createRule({
|
|
8
7
|
name: ruleId,
|
|
@@ -23,12 +22,16 @@ var rule = createRule({
|
|
|
23
22
|
const filename = context.filename;
|
|
24
23
|
const utilRegex = /(?:^|[-_/])util(?=[-_./]|$)/iu;
|
|
25
24
|
if (utilRegex.test(filename)) {
|
|
26
|
-
const
|
|
27
|
-
|
|
25
|
+
const sourceCode = context.sourceCode;
|
|
26
|
+
const tokens = sourceCode.tokensAndComments;
|
|
27
|
+
const firstNonCommentToken = tokens.find(
|
|
28
|
+
(token) => token.type !== AST_TOKEN_TYPES.Block && token.type !== AST_TOKEN_TYPES.Line
|
|
29
|
+
);
|
|
30
|
+
if (firstNonCommentToken !== void 0) {
|
|
28
31
|
context.report({
|
|
29
32
|
messageId: NO_UTIL,
|
|
30
33
|
data: { filename },
|
|
31
|
-
node:
|
|
34
|
+
node: firstNonCommentToken
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -41,4 +44,4 @@ export {
|
|
|
41
44
|
no_util_default as default,
|
|
42
45
|
ruleId
|
|
43
46
|
};
|
|
44
|
-
//# sourceMappingURL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Y7QUFBQSxNQUNGO0FBQUEsSUFDRjtBQUFBLEVBQ0Y7QUFDRixDQUFDO0FBRUQsSUFBTyxrQkFBUTsiLAogICJuYW1lcyI6IFtdCn0K
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@checkdigit/eslint-plugin","version":"7.13.0-PR.57-
|
|
1
|
+
{"name":"@checkdigit/eslint-plugin","version":"7.13.0-PR.57-1e3a","description":"Check Digit eslint plugins","keywords":["eslint","eslintplugin"],"homepage":"https://github.com/checkdigit/eslint-plugin#readme","bugs":{"url":"https://github.com/checkdigit/eslint-plugin/issues"},"repository":{"type":"git","url":"https://github.com/checkdigit/eslint-plugin"},"license":"MIT","author":"Check Digit, LLC","sideEffects":false,"type":"module","exports":{".":{"types":"./dist-types/index.d.ts","import":"./dist-mjs/index.mjs","default":"./dist-mjs/index.mjs"}},"files":["src","dist-types","dist-mjs","!src/**/test/**","!src/**/*.test.ts","!src/**/*.spec.ts","!dist-types/**/test/**","!dist-types/**/*.test.d.ts","!dist-types/**/*.spec.d.ts","!dist-mjs/**/test/**","!dist-mjs/**/*.test.mjs","!dist-mjs/**/*.spec.mjs","SECURITY.md"],"scripts":{"build:dist-mjs":"rimraf dist-mjs && npx builder --type=module --sourceMap --outDir=dist-mjs && node dist-mjs/index.mjs","build:dist-types":"rimraf dist-types && npx builder --type=types --outDir=dist-types","ci:compile":"tsc --noEmit","ci:coverage":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=true","ci:lint":"npm run lint","ci:style":"npm run prettier","ci:test":"NODE_OPTIONS=\"--disable-warning ExperimentalWarning --experimental-vm-modules\" jest --coverage=false","lint":"eslint --max-warnings 0 .","lint:fix":"eslint --max-warnings 0 --fix .","prepare":"","prepublishOnly":"npm run build:dist-types && npm run build:dist-mjs","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style"},"prettier":"@checkdigit/prettier-config","jest":{"preset":"@checkdigit/jest-config"},"dependencies":{"@typescript-eslint/type-utils":"^8.23.0","@typescript-eslint/utils":"^8.23.0","http-status-codes":"^2.3.0","ts-api-utils":"^2.0.1"},"devDependencies":{"@checkdigit/jest-config":"^6.0.2","@checkdigit/prettier-config":"^6.1.0","@checkdigit/typescript-config":"^9.0.0","@eslint/js":"^9.19.0","@types/eslint":"^9.6.1","@types/eslint-config-prettier":"^6.11.3","@typescript-eslint/parser":"^8.23.0","@typescript-eslint/rule-tester":"^8.23.0","eslint":"^9.19.0","eslint-config-prettier":"^10.0.1","eslint-import-resolver-typescript":"^3.7.0","eslint-plugin-eslint-plugin":"^6.4.0","eslint-plugin-import":"^2.31.0","eslint-plugin-no-only-tests":"^3.3.0","eslint-plugin-no-secrets":"^2.2.1","eslint-plugin-node":"^11.1.0","eslint-plugin-sonarjs":"1.0.4","rimraf":"^6.0.1","typescript-eslint":"^8.23.0"},"peerDependencies":{"eslint":">=9 <10"},"engines":{"node":">=22.11"}}
|
package/src/no-util.ts
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
* This code is licensed under the MIT license (see LICENSE.txt for details).
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
9
|
+
import { AST_TOKEN_TYPES, ESLintUtils } from '@typescript-eslint/utils';
|
|
10
10
|
|
|
11
11
|
export const ruleId = 'no-util';
|
|
12
12
|
const NO_UTIL = 'NO_UTIL';
|
|
13
|
-
const DISABLE_NEXT_LINE = 'eslint-disable-next-line';
|
|
14
13
|
|
|
15
14
|
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
16
15
|
|
|
@@ -33,14 +32,16 @@ const rule: ESLintUtils.RuleModule<typeof NO_UTIL> = createRule({
|
|
|
33
32
|
const filename = context.filename;
|
|
34
33
|
const utilRegex = /(?:^|[-_/])util(?=[-_./]|$)/iu;
|
|
35
34
|
if (utilRegex.test(filename)) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const sourceCode = context.sourceCode;
|
|
36
|
+
const tokens = sourceCode.tokensAndComments;
|
|
37
|
+
const firstNonCommentToken = tokens.find(
|
|
38
|
+
(token) => token.type !== AST_TOKEN_TYPES.Block && token.type !== AST_TOKEN_TYPES.Line,
|
|
39
|
+
);
|
|
40
|
+
if (firstNonCommentToken !== undefined) {
|
|
40
41
|
context.report({
|
|
41
42
|
messageId: NO_UTIL,
|
|
42
43
|
data: { filename },
|
|
43
|
-
node:
|
|
44
|
+
node: firstNonCommentToken,
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
}
|