@so1ve/eslint-plugin 0.101.0 → 0.101.2

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 CHANGED
@@ -237,9 +237,67 @@ const importDedupe = createEslintRule({
237
237
  })
238
238
  });
239
239
 
240
- const RULE_NAME$4 = "no-inline-type-import";
241
- const noInlineTypeImport = createEslintRule({
240
+ const RULE_NAME$4 = "no-import-promises-as";
241
+ const _POSSIBLE_IMPORT_SOURCES = ["dns", "fs", "readline", "stream"];
242
+ const POSSIBLE_IMPORT_SOURCES = [
243
+ ..._POSSIBLE_IMPORT_SOURCES,
244
+ ..._POSSIBLE_IMPORT_SOURCES.map((s) => `node:${s}`)
245
+ ];
246
+ const noImportPromisesAs = createEslintRule({
242
247
  name: RULE_NAME$4,
248
+ meta: {
249
+ type: "problem",
250
+ docs: {
251
+ description: "Disallow import promises as.",
252
+ recommended: "error"
253
+ },
254
+ fixable: "code",
255
+ schema: [],
256
+ messages: {
257
+ noImportPromisesAs: "Expect no import promises as."
258
+ }
259
+ },
260
+ defaultOptions: [],
261
+ create: (context) => {
262
+ const sourceCode = context.getSourceCode();
263
+ const { text } = sourceCode;
264
+ return {
265
+ ImportDeclaration(node) {
266
+ if (!POSSIBLE_IMPORT_SOURCES.includes(node.source.value)) {
267
+ return;
268
+ }
269
+ const promisesSpecifier = node.specifiers.find(
270
+ (s) => s.type === "ImportSpecifier" && s.imported.name === "promises" && s.local.name !== "promises"
271
+ );
272
+ const as = promisesSpecifier?.local.name;
273
+ if (!promisesSpecifier || !as) {
274
+ return;
275
+ }
276
+ context.report({
277
+ node,
278
+ messageId: "noImportPromisesAs",
279
+ *fix(fixer) {
280
+ const s = promisesSpecifier.range[0];
281
+ let e = promisesSpecifier.range[1];
282
+ if (text[e] === ",") {
283
+ e += 1;
284
+ }
285
+ yield fixer.removeRange([s, e]);
286
+ yield fixer.insertTextAfter(
287
+ node,
288
+ `
289
+ import ${as} from "${node.source.value}/promises";`
290
+ );
291
+ }
292
+ });
293
+ }
294
+ };
295
+ }
296
+ });
297
+
298
+ const RULE_NAME$3 = "no-inline-type-import";
299
+ const noInlineTypeImport = createEslintRule({
300
+ name: RULE_NAME$3,
243
301
  meta: {
244
302
  type: "layout",
245
303
  docs: {
@@ -303,7 +361,7 @@ const noInlineTypeImport = createEslintRule({
303
361
  }
304
362
  });
305
363
 
306
- const RULE_NAME$3 = "no-negated-comparison";
364
+ const RULE_NAME$2 = "no-negated-comparison";
307
365
  const negatedToPositive = {
308
366
  "==": "!=",
309
367
  "===": "!==",
@@ -316,7 +374,7 @@ const negatedToPositive = {
316
374
  };
317
375
  const negatives = Object.keys(negatedToPositive);
318
376
  const noNegatedComparison = createEslintRule({
319
- name: RULE_NAME$3,
377
+ name: RULE_NAME$2,
320
378
  meta: {
321
379
  type: "problem",
322
380
  docs: {
@@ -353,9 +411,9 @@ const noNegatedComparison = createEslintRule({
353
411
  })
354
412
  });
355
413
 
356
- const RULE_NAME$2 = "no-useless-template-string";
414
+ const RULE_NAME$1 = "no-useless-template-string";
357
415
  const noUselessTemplateString = createEslintRule({
358
- name: RULE_NAME$2,
416
+ name: RULE_NAME$1,
359
417
  meta: {
360
418
  type: "problem",
361
419
  docs: {
@@ -388,64 +446,6 @@ const noUselessTemplateString = createEslintRule({
388
446
  })
389
447
  });
390
448
 
391
- const RULE_NAME$1 = "no-import-promises-as";
392
- const _POSSIBLE_IMPORT_SOURCES = ["dns", "fs", "readline", "stream"];
393
- const POSSIBLE_IMPORT_SOURCES = [
394
- ..._POSSIBLE_IMPORT_SOURCES,
395
- ..._POSSIBLE_IMPORT_SOURCES.map((s) => `node:${s}`)
396
- ];
397
- const noImportPromisesAs = createEslintRule({
398
- name: RULE_NAME$1,
399
- meta: {
400
- type: "problem",
401
- docs: {
402
- description: "Disallow import promises as.",
403
- recommended: "error"
404
- },
405
- fixable: "code",
406
- schema: [],
407
- messages: {
408
- noImportPromisesAs: "Expect no import promises as."
409
- }
410
- },
411
- defaultOptions: [],
412
- create: (context) => {
413
- const sourceCode = context.getSourceCode();
414
- const { text } = sourceCode;
415
- return {
416
- ImportDeclaration(node) {
417
- if (!POSSIBLE_IMPORT_SOURCES.includes(node.source.value)) {
418
- return;
419
- }
420
- const promisesSpecifier = node.specifiers.find(
421
- (s) => s.type === "ImportSpecifier" && s.imported.name === "promises" && s.local.name !== "promises"
422
- );
423
- const as = promisesSpecifier?.local.name;
424
- if (!promisesSpecifier || !as) {
425
- return;
426
- }
427
- context.report({
428
- node,
429
- messageId: "noImportPromisesAs",
430
- *fix(fixer) {
431
- const s = promisesSpecifier.range[0];
432
- let e = promisesSpecifier.range[1];
433
- if (text[e] === ",") {
434
- e += 1;
435
- }
436
- yield fixer.removeRange([s, e]);
437
- yield fixer.insertTextAfter(
438
- node,
439
- `
440
- import ${as} from "${node.source.value}/promises";`
441
- );
442
- }
443
- });
444
- }
445
- };
446
- }
447
- });
448
-
449
449
  const RULE_NAME = "pad-after-last-import";
450
450
  const padAfterLastImport = createEslintRule({
451
451
  name: RULE_NAME,
package/dist/index.mjs CHANGED
@@ -235,9 +235,67 @@ const importDedupe = createEslintRule({
235
235
  })
236
236
  });
237
237
 
238
- const RULE_NAME$4 = "no-inline-type-import";
239
- const noInlineTypeImport = createEslintRule({
238
+ const RULE_NAME$4 = "no-import-promises-as";
239
+ const _POSSIBLE_IMPORT_SOURCES = ["dns", "fs", "readline", "stream"];
240
+ const POSSIBLE_IMPORT_SOURCES = [
241
+ ..._POSSIBLE_IMPORT_SOURCES,
242
+ ..._POSSIBLE_IMPORT_SOURCES.map((s) => `node:${s}`)
243
+ ];
244
+ const noImportPromisesAs = createEslintRule({
240
245
  name: RULE_NAME$4,
246
+ meta: {
247
+ type: "problem",
248
+ docs: {
249
+ description: "Disallow import promises as.",
250
+ recommended: "error"
251
+ },
252
+ fixable: "code",
253
+ schema: [],
254
+ messages: {
255
+ noImportPromisesAs: "Expect no import promises as."
256
+ }
257
+ },
258
+ defaultOptions: [],
259
+ create: (context) => {
260
+ const sourceCode = context.getSourceCode();
261
+ const { text } = sourceCode;
262
+ return {
263
+ ImportDeclaration(node) {
264
+ if (!POSSIBLE_IMPORT_SOURCES.includes(node.source.value)) {
265
+ return;
266
+ }
267
+ const promisesSpecifier = node.specifiers.find(
268
+ (s) => s.type === "ImportSpecifier" && s.imported.name === "promises" && s.local.name !== "promises"
269
+ );
270
+ const as = promisesSpecifier?.local.name;
271
+ if (!promisesSpecifier || !as) {
272
+ return;
273
+ }
274
+ context.report({
275
+ node,
276
+ messageId: "noImportPromisesAs",
277
+ *fix(fixer) {
278
+ const s = promisesSpecifier.range[0];
279
+ let e = promisesSpecifier.range[1];
280
+ if (text[e] === ",") {
281
+ e += 1;
282
+ }
283
+ yield fixer.removeRange([s, e]);
284
+ yield fixer.insertTextAfter(
285
+ node,
286
+ `
287
+ import ${as} from "${node.source.value}/promises";`
288
+ );
289
+ }
290
+ });
291
+ }
292
+ };
293
+ }
294
+ });
295
+
296
+ const RULE_NAME$3 = "no-inline-type-import";
297
+ const noInlineTypeImport = createEslintRule({
298
+ name: RULE_NAME$3,
241
299
  meta: {
242
300
  type: "layout",
243
301
  docs: {
@@ -301,7 +359,7 @@ const noInlineTypeImport = createEslintRule({
301
359
  }
302
360
  });
303
361
 
304
- const RULE_NAME$3 = "no-negated-comparison";
362
+ const RULE_NAME$2 = "no-negated-comparison";
305
363
  const negatedToPositive = {
306
364
  "==": "!=",
307
365
  "===": "!==",
@@ -314,7 +372,7 @@ const negatedToPositive = {
314
372
  };
315
373
  const negatives = Object.keys(negatedToPositive);
316
374
  const noNegatedComparison = createEslintRule({
317
- name: RULE_NAME$3,
375
+ name: RULE_NAME$2,
318
376
  meta: {
319
377
  type: "problem",
320
378
  docs: {
@@ -351,9 +409,9 @@ const noNegatedComparison = createEslintRule({
351
409
  })
352
410
  });
353
411
 
354
- const RULE_NAME$2 = "no-useless-template-string";
412
+ const RULE_NAME$1 = "no-useless-template-string";
355
413
  const noUselessTemplateString = createEslintRule({
356
- name: RULE_NAME$2,
414
+ name: RULE_NAME$1,
357
415
  meta: {
358
416
  type: "problem",
359
417
  docs: {
@@ -386,64 +444,6 @@ const noUselessTemplateString = createEslintRule({
386
444
  })
387
445
  });
388
446
 
389
- const RULE_NAME$1 = "no-import-promises-as";
390
- const _POSSIBLE_IMPORT_SOURCES = ["dns", "fs", "readline", "stream"];
391
- const POSSIBLE_IMPORT_SOURCES = [
392
- ..._POSSIBLE_IMPORT_SOURCES,
393
- ..._POSSIBLE_IMPORT_SOURCES.map((s) => `node:${s}`)
394
- ];
395
- const noImportPromisesAs = createEslintRule({
396
- name: RULE_NAME$1,
397
- meta: {
398
- type: "problem",
399
- docs: {
400
- description: "Disallow import promises as.",
401
- recommended: "error"
402
- },
403
- fixable: "code",
404
- schema: [],
405
- messages: {
406
- noImportPromisesAs: "Expect no import promises as."
407
- }
408
- },
409
- defaultOptions: [],
410
- create: (context) => {
411
- const sourceCode = context.getSourceCode();
412
- const { text } = sourceCode;
413
- return {
414
- ImportDeclaration(node) {
415
- if (!POSSIBLE_IMPORT_SOURCES.includes(node.source.value)) {
416
- return;
417
- }
418
- const promisesSpecifier = node.specifiers.find(
419
- (s) => s.type === "ImportSpecifier" && s.imported.name === "promises" && s.local.name !== "promises"
420
- );
421
- const as = promisesSpecifier?.local.name;
422
- if (!promisesSpecifier || !as) {
423
- return;
424
- }
425
- context.report({
426
- node,
427
- messageId: "noImportPromisesAs",
428
- *fix(fixer) {
429
- const s = promisesSpecifier.range[0];
430
- let e = promisesSpecifier.range[1];
431
- if (text[e] === ",") {
432
- e += 1;
433
- }
434
- yield fixer.removeRange([s, e]);
435
- yield fixer.insertTextAfter(
436
- node,
437
- `
438
- import ${as} from "${node.source.value}/promises";`
439
- );
440
- }
441
- });
442
- }
443
- };
444
- }
445
- });
446
-
447
447
  const RULE_NAME = "pad-after-last-import";
448
448
  const padAfterLastImport = createEslintRule({
449
449
  name: RULE_NAME,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "0.101.0",
3
+ "version": "0.101.2",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "keywords": [
6
6
  "eslint",