@saasmakers/eslint 1.0.17 → 1.0.19

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.
@@ -4,7 +4,7 @@ const antfu = require('@antfu/eslint-config');
4
4
  const saasmakers = require('@saasmakers/eslint');
5
5
  const vitest = require('@vitest/eslint-plugin');
6
6
  const packageJson = require('eslint-plugin-package-json');
7
- const index$1 = require('./shared/eslint.DhFjwkxh.cjs');
7
+ const index$1 = require('./shared/eslint.BqRQ4tAN.cjs');
8
8
  const path = require('node:path');
9
9
  const fs = require('node:fs');
10
10
  const node_module = require('node:module');
@@ -2,7 +2,7 @@ import antfu from '@antfu/eslint-config';
2
2
  import saasmakers from '@saasmakers/eslint';
3
3
  import vitest from '@vitest/eslint-plugin';
4
4
  import packageJson from 'eslint-plugin-package-json';
5
- import { d as distExports } from './shared/eslint.CohBuu1-.mjs';
5
+ import { d as distExports } from './shared/eslint.DOaqyhfZ.mjs';
6
6
  import * as path from 'node:path';
7
7
  import * as fs from 'node:fs';
8
8
  import { createRequire, builtinModules } from 'node:module';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index$1 = require('./shared/eslint.DhFjwkxh.cjs');
3
+ const index$1 = require('./shared/eslint.BqRQ4tAN.cjs');
4
4
  require('eslint');
5
5
  require('eslint/use-at-your-own-risk');
6
6
 
@@ -193,7 +193,7 @@ function getBlankLineRequirement(prevNode, nextNode, sourceCode) {
193
193
  return null;
194
194
  }
195
195
  if (hasLineCommentBetween(prevNode, nextNode, sourceCode)) {
196
- return "always";
196
+ return null;
197
197
  }
198
198
  const nextKind = getStatementKind(nextNode);
199
199
  if (!nextKind) {
@@ -247,6 +247,27 @@ function getStatementKind(node) {
247
247
  }
248
248
  return isSingleLine(node) ? "singleline-expression" : "multiline-expression";
249
249
  }
250
+ if (node.type === index$1.distExports.AST_NODE_TYPES.IfStatement) {
251
+ return isSingleLine(node) ? "singleline-if" : "multiline-if";
252
+ }
253
+ if (node.type === index$1.distExports.AST_NODE_TYPES.ForStatement || node.type === index$1.distExports.AST_NODE_TYPES.ForInStatement || node.type === index$1.distExports.AST_NODE_TYPES.ForOfStatement || node.type === index$1.distExports.AST_NODE_TYPES.WhileStatement || node.type === index$1.distExports.AST_NODE_TYPES.DoWhileStatement) {
254
+ return isSingleLine(node) ? "singleline-loop" : "multiline-loop";
255
+ }
256
+ if (node.type === index$1.distExports.AST_NODE_TYPES.ReturnStatement) {
257
+ return isSingleLine(node) ? "singleline-return" : "multiline-return";
258
+ }
259
+ if (node.type === index$1.distExports.AST_NODE_TYPES.SwitchStatement) {
260
+ return isSingleLine(node) ? "singleline-switch" : "multiline-switch";
261
+ }
262
+ if (node.type === index$1.distExports.AST_NODE_TYPES.TryStatement) {
263
+ return isSingleLine(node) ? "singleline-try" : "multiline-try";
264
+ }
265
+ if (node.type === index$1.distExports.AST_NODE_TYPES.BreakStatement || node.type === index$1.distExports.AST_NODE_TYPES.ContinueStatement) {
266
+ return isSingleLine(node) ? "singleline-jump" : "multiline-jump";
267
+ }
268
+ if (node.type === index$1.distExports.AST_NODE_TYPES.ThrowStatement) {
269
+ return isSingleLine(node) ? "singleline-throw" : "multiline-throw";
270
+ }
250
271
  return null;
251
272
  }
252
273
  function hasEmptyLineBetween(prevNode, nextNode, sourceCode) {
@@ -374,7 +395,7 @@ const rule$a = {
374
395
  return;
375
396
  }
376
397
  const previousLine = sourceCode.lines[commentLine - 2] ?? "";
377
- if (previousLine.trim() === "" || previousLine.trimEnd().endsWith("{")) {
398
+ if (previousLine.trim() === "" || previousLine.trimEnd().endsWith("{") || previousLine.trimStart().startsWith("//")) {
378
399
  return;
379
400
  }
380
401
  context.report({
@@ -421,9 +442,13 @@ const rule$a = {
421
442
  ":statement": verify,
422
443
  "BlockStatement": enterScope,
423
444
  "BlockStatement:exit": exitScope,
424
- "LineComment": verifyComment,
425
445
  "Program": enterScope,
426
- "Program:exit": exitScope,
446
+ "Program:exit": function() {
447
+ for (const comment of sourceCode.getAllComments()) {
448
+ verifyComment(comment);
449
+ }
450
+ exitScope();
451
+ },
427
452
  "StaticBlock": enterScope,
428
453
  "StaticBlock:exit": exitScope,
429
454
  "SwitchCase": verifyThenEnterScope,
@@ -461,8 +486,9 @@ function getSpecificName(testName) {
461
486
  return parts.slice(specialIndex + 1).join(".");
462
487
  }
463
488
  function getTestName(node) {
464
- if (node.arguments && node.arguments[0] && node.arguments[0].type === "Literal") {
465
- return node.arguments[0].value;
489
+ const firstArgument = node.arguments[0];
490
+ if (firstArgument?.type === index$1.distExports.AST_NODE_TYPES.Literal && typeof firstArgument.value === "string") {
491
+ return firstArgument.value;
466
492
  }
467
493
  return "";
468
494
  }
@@ -480,11 +506,9 @@ function getTestPriority(testName) {
480
506
  }
481
507
  }
482
508
  const rule$9 = {
509
+ defaultOptions: [],
483
510
  meta: {
484
- docs: {
485
- description: "Enforce sorted test functions grouped by method with sorted metrics, errors, exceptions and middlewares",
486
- recommended: true
487
- },
511
+ docs: { description: "Enforce sorted test functions grouped by method with sorted metrics, errors, exceptions and middlewares" },
488
512
  fixable: "code",
489
513
  messages: { sortError: "Test functions should be grouped by method with sorted metrics, errors, exceptions and middlewares." },
490
514
  schema: [],
@@ -500,15 +524,15 @@ const rule$9 = {
500
524
  return;
501
525
  }
502
526
  const groupCallback = node.arguments[1];
503
- if (groupCallback.type !== "FunctionExpression" && groupCallback.type !== "ArrowFunctionExpression") {
527
+ if (groupCallback.type !== index$1.distExports.AST_NODE_TYPES.FunctionExpression && groupCallback.type !== index$1.distExports.AST_NODE_TYPES.ArrowFunctionExpression) {
504
528
  return;
505
529
  }
506
530
  const callbackBody = groupCallback.body;
507
- if (callbackBody.type !== "BlockStatement" || !callbackBody.body) {
531
+ if (callbackBody.type !== index$1.distExports.AST_NODE_TYPES.BlockStatement || !callbackBody.body) {
508
532
  return;
509
533
  }
510
534
  const tests = callbackBody.body.filter((statement) => {
511
- return statement.type === "ExpressionStatement" && statement.expression.type === "CallExpression" && statement.expression.callee.type === "Identifier" && (statement.expression.callee.name === "test" || statement.expression.callee.name === "it");
535
+ return statement.type === index$1.distExports.AST_NODE_TYPES.ExpressionStatement && statement.expression.type === index$1.distExports.AST_NODE_TYPES.CallExpression && statement.expression.callee.type === index$1.distExports.AST_NODE_TYPES.Identifier && (statement.expression.callee.name === "test" || statement.expression.callee.name === "it");
512
536
  });
513
537
  const testNames = tests.map((test) => getTestName(test.expression));
514
538
  const sortedTestNames = [...testNames].toSorted(compareTests);