@so1ve/eslint-plugin 0.40.1 → 0.42.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/dist/index.cjs +89 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +89 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,9 +4,9 @@ const utils = require('@typescript-eslint/utils');
|
|
|
4
4
|
|
|
5
5
|
const createEslintRule = utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
6
6
|
|
|
7
|
-
const RULE_NAME$
|
|
7
|
+
const RULE_NAME$6 = "generic-spacing";
|
|
8
8
|
const genericSpacing = createEslintRule({
|
|
9
|
-
name: RULE_NAME$
|
|
9
|
+
name: RULE_NAME$6,
|
|
10
10
|
meta: {
|
|
11
11
|
type: "layout",
|
|
12
12
|
docs: {
|
|
@@ -248,9 +248,9 @@ const genericSpacing = createEslintRule({
|
|
|
248
248
|
}
|
|
249
249
|
});
|
|
250
250
|
|
|
251
|
-
const RULE_NAME$
|
|
251
|
+
const RULE_NAME$5 = "import-dedupe";
|
|
252
252
|
const importDedupe = createEslintRule({
|
|
253
|
-
name: RULE_NAME$
|
|
253
|
+
name: RULE_NAME$5,
|
|
254
254
|
meta: {
|
|
255
255
|
type: "problem",
|
|
256
256
|
docs: {
|
|
@@ -298,9 +298,9 @@ const importDedupe = createEslintRule({
|
|
|
298
298
|
}
|
|
299
299
|
});
|
|
300
300
|
|
|
301
|
-
const RULE_NAME$
|
|
301
|
+
const RULE_NAME$4 = "space-between-generic-and-paren";
|
|
302
302
|
const spaceBetweenGenericAndParen = createEslintRule({
|
|
303
|
-
name: RULE_NAME$
|
|
303
|
+
name: RULE_NAME$4,
|
|
304
304
|
meta: {
|
|
305
305
|
type: "layout",
|
|
306
306
|
docs: {
|
|
@@ -374,6 +374,87 @@ const spaceBetweenGenericAndParen = createEslintRule({
|
|
|
374
374
|
}
|
|
375
375
|
});
|
|
376
376
|
|
|
377
|
+
const RULE_NAME$3 = "no-spaces-before-paren";
|
|
378
|
+
const noSpacesBeforeParen = createEslintRule({
|
|
379
|
+
name: RULE_NAME$3,
|
|
380
|
+
meta: {
|
|
381
|
+
type: "layout",
|
|
382
|
+
docs: {
|
|
383
|
+
description: "Spaces before paren",
|
|
384
|
+
recommended: "error"
|
|
385
|
+
},
|
|
386
|
+
fixable: "whitespace",
|
|
387
|
+
schema: [],
|
|
388
|
+
messages: {
|
|
389
|
+
noSpacesBeforeParen: "Expected no space between function name and paren"
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
defaultOptions: [],
|
|
393
|
+
create: (context) => {
|
|
394
|
+
const sourceCode = context.getSourceCode();
|
|
395
|
+
const text = sourceCode.getText();
|
|
396
|
+
return {
|
|
397
|
+
ImportExpression(node) {
|
|
398
|
+
const sourceRange = node.source.range;
|
|
399
|
+
const parenStart = sourceRange[0] - 1;
|
|
400
|
+
const importEnd = node.range[0] + 6;
|
|
401
|
+
const textBetweenImportAndParenRange = [importEnd, parenStart];
|
|
402
|
+
const textBetweenImportAndParen = text.slice(...textBetweenImportAndParenRange);
|
|
403
|
+
if (textBetweenImportAndParen.length > 0) {
|
|
404
|
+
context.report({
|
|
405
|
+
node,
|
|
406
|
+
messageId: "noSpacesBeforeParen",
|
|
407
|
+
*fix(fixer) {
|
|
408
|
+
yield fixer.removeRange(textBetweenImportAndParenRange);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
CallExpression(node) {
|
|
414
|
+
const caller = "property" in node.callee ? node.callee.property : node.callee;
|
|
415
|
+
const firstArgument = node.arguments[0];
|
|
416
|
+
const firstArgumentStart = firstArgument ? firstArgument.range[0] : void 0;
|
|
417
|
+
const parenStart = firstArgument ? firstArgumentStart - 1 : node.range[1] - 2;
|
|
418
|
+
const textBetweenFunctionNameAndParenRange = [caller.range[1], parenStart];
|
|
419
|
+
const textBetweenFunctionNameAndParen = text.slice(...textBetweenFunctionNameAndParenRange);
|
|
420
|
+
const hasGenerics = !/^\s*$/.test(textBetweenFunctionNameAndParen);
|
|
421
|
+
if (!hasGenerics) {
|
|
422
|
+
if (textBetweenFunctionNameAndParen.length > 0) {
|
|
423
|
+
context.report({
|
|
424
|
+
node,
|
|
425
|
+
messageId: "noSpacesBeforeParen",
|
|
426
|
+
*fix(fixer) {
|
|
427
|
+
yield fixer.removeRange(textBetweenFunctionNameAndParenRange);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
} else {
|
|
432
|
+
const preSpaces = /^(\s*)/.exec(textBetweenFunctionNameAndParen)[1];
|
|
433
|
+
const postSpaces = /(\s*)$/.exec(textBetweenFunctionNameAndParen)[1];
|
|
434
|
+
if (preSpaces.length > 0) {
|
|
435
|
+
context.report({
|
|
436
|
+
node,
|
|
437
|
+
messageId: "noSpacesBeforeParen",
|
|
438
|
+
*fix(fixer) {
|
|
439
|
+
yield fixer.removeRange([caller.range[1], caller.range[1] + preSpaces.length]);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
if (postSpaces.length > 0) {
|
|
444
|
+
context.report({
|
|
445
|
+
node,
|
|
446
|
+
messageId: "noSpacesBeforeParen",
|
|
447
|
+
*fix(fixer) {
|
|
448
|
+
yield fixer.removeRange([parenStart - postSpaces.length, parenStart]);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
377
458
|
const RULE_NAME$2 = "space-in-empty-block";
|
|
378
459
|
const spaceInEmptyBlock = createEslintRule({
|
|
379
460
|
name: RULE_NAME$2,
|
|
@@ -546,7 +627,8 @@ const index = {
|
|
|
546
627
|
"space-between-generic-and-paren": spaceBetweenGenericAndParen,
|
|
547
628
|
"space-in-empty-block": spaceInEmptyBlock,
|
|
548
629
|
"semi-spacing": semiSpacing,
|
|
549
|
-
"no-inline-type-import": noInlineTypeImport
|
|
630
|
+
"no-inline-type-import": noInlineTypeImport,
|
|
631
|
+
"no-spaces-before-paren": noSpacesBeforeParen
|
|
550
632
|
}
|
|
551
633
|
};
|
|
552
634
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare const _default: {
|
|
|
8
8
|
"space-in-empty-block": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noSpaceInEmptyBlock", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
9
9
|
"semi-spacing": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noSpaceBeforeSemi", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
10
10
|
"no-inline-type-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noInlineTypeImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
11
|
+
"no-spaces-before-paren": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noSpacesBeforeParen", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
2
2
|
|
|
3
3
|
const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
4
4
|
|
|
5
|
-
const RULE_NAME$
|
|
5
|
+
const RULE_NAME$6 = "generic-spacing";
|
|
6
6
|
const genericSpacing = createEslintRule({
|
|
7
|
-
name: RULE_NAME$
|
|
7
|
+
name: RULE_NAME$6,
|
|
8
8
|
meta: {
|
|
9
9
|
type: "layout",
|
|
10
10
|
docs: {
|
|
@@ -246,9 +246,9 @@ const genericSpacing = createEslintRule({
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
const RULE_NAME$
|
|
249
|
+
const RULE_NAME$5 = "import-dedupe";
|
|
250
250
|
const importDedupe = createEslintRule({
|
|
251
|
-
name: RULE_NAME$
|
|
251
|
+
name: RULE_NAME$5,
|
|
252
252
|
meta: {
|
|
253
253
|
type: "problem",
|
|
254
254
|
docs: {
|
|
@@ -296,9 +296,9 @@ const importDedupe = createEslintRule({
|
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
-
const RULE_NAME$
|
|
299
|
+
const RULE_NAME$4 = "space-between-generic-and-paren";
|
|
300
300
|
const spaceBetweenGenericAndParen = createEslintRule({
|
|
301
|
-
name: RULE_NAME$
|
|
301
|
+
name: RULE_NAME$4,
|
|
302
302
|
meta: {
|
|
303
303
|
type: "layout",
|
|
304
304
|
docs: {
|
|
@@ -372,6 +372,87 @@ const spaceBetweenGenericAndParen = createEslintRule({
|
|
|
372
372
|
}
|
|
373
373
|
});
|
|
374
374
|
|
|
375
|
+
const RULE_NAME$3 = "no-spaces-before-paren";
|
|
376
|
+
const noSpacesBeforeParen = createEslintRule({
|
|
377
|
+
name: RULE_NAME$3,
|
|
378
|
+
meta: {
|
|
379
|
+
type: "layout",
|
|
380
|
+
docs: {
|
|
381
|
+
description: "Spaces before paren",
|
|
382
|
+
recommended: "error"
|
|
383
|
+
},
|
|
384
|
+
fixable: "whitespace",
|
|
385
|
+
schema: [],
|
|
386
|
+
messages: {
|
|
387
|
+
noSpacesBeforeParen: "Expected no space between function name and paren"
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
defaultOptions: [],
|
|
391
|
+
create: (context) => {
|
|
392
|
+
const sourceCode = context.getSourceCode();
|
|
393
|
+
const text = sourceCode.getText();
|
|
394
|
+
return {
|
|
395
|
+
ImportExpression(node) {
|
|
396
|
+
const sourceRange = node.source.range;
|
|
397
|
+
const parenStart = sourceRange[0] - 1;
|
|
398
|
+
const importEnd = node.range[0] + 6;
|
|
399
|
+
const textBetweenImportAndParenRange = [importEnd, parenStart];
|
|
400
|
+
const textBetweenImportAndParen = text.slice(...textBetweenImportAndParenRange);
|
|
401
|
+
if (textBetweenImportAndParen.length > 0) {
|
|
402
|
+
context.report({
|
|
403
|
+
node,
|
|
404
|
+
messageId: "noSpacesBeforeParen",
|
|
405
|
+
*fix(fixer) {
|
|
406
|
+
yield fixer.removeRange(textBetweenImportAndParenRange);
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
CallExpression(node) {
|
|
412
|
+
const caller = "property" in node.callee ? node.callee.property : node.callee;
|
|
413
|
+
const firstArgument = node.arguments[0];
|
|
414
|
+
const firstArgumentStart = firstArgument ? firstArgument.range[0] : void 0;
|
|
415
|
+
const parenStart = firstArgument ? firstArgumentStart - 1 : node.range[1] - 2;
|
|
416
|
+
const textBetweenFunctionNameAndParenRange = [caller.range[1], parenStart];
|
|
417
|
+
const textBetweenFunctionNameAndParen = text.slice(...textBetweenFunctionNameAndParenRange);
|
|
418
|
+
const hasGenerics = !/^\s*$/.test(textBetweenFunctionNameAndParen);
|
|
419
|
+
if (!hasGenerics) {
|
|
420
|
+
if (textBetweenFunctionNameAndParen.length > 0) {
|
|
421
|
+
context.report({
|
|
422
|
+
node,
|
|
423
|
+
messageId: "noSpacesBeforeParen",
|
|
424
|
+
*fix(fixer) {
|
|
425
|
+
yield fixer.removeRange(textBetweenFunctionNameAndParenRange);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
} else {
|
|
430
|
+
const preSpaces = /^(\s*)/.exec(textBetweenFunctionNameAndParen)[1];
|
|
431
|
+
const postSpaces = /(\s*)$/.exec(textBetweenFunctionNameAndParen)[1];
|
|
432
|
+
if (preSpaces.length > 0) {
|
|
433
|
+
context.report({
|
|
434
|
+
node,
|
|
435
|
+
messageId: "noSpacesBeforeParen",
|
|
436
|
+
*fix(fixer) {
|
|
437
|
+
yield fixer.removeRange([caller.range[1], caller.range[1] + preSpaces.length]);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
if (postSpaces.length > 0) {
|
|
442
|
+
context.report({
|
|
443
|
+
node,
|
|
444
|
+
messageId: "noSpacesBeforeParen",
|
|
445
|
+
*fix(fixer) {
|
|
446
|
+
yield fixer.removeRange([parenStart - postSpaces.length, parenStart]);
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
375
456
|
const RULE_NAME$2 = "space-in-empty-block";
|
|
376
457
|
const spaceInEmptyBlock = createEslintRule({
|
|
377
458
|
name: RULE_NAME$2,
|
|
@@ -544,7 +625,8 @@ const index = {
|
|
|
544
625
|
"space-between-generic-and-paren": spaceBetweenGenericAndParen,
|
|
545
626
|
"space-in-empty-block": spaceInEmptyBlock,
|
|
546
627
|
"semi-spacing": semiSpacing,
|
|
547
|
-
"no-inline-type-import": noInlineTypeImport
|
|
628
|
+
"no-inline-type-import": noInlineTypeImport,
|
|
629
|
+
"no-spaces-before-paren": noSpacesBeforeParen
|
|
548
630
|
}
|
|
549
631
|
};
|
|
550
632
|
|