@saasmakers/eslint 1.0.4 → 1.0.6

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.mjs CHANGED
@@ -2,7 +2,7 @@ import { d as distExports } from './shared/eslint.CohBuu1-.mjs';
2
2
  import 'eslint';
3
3
  import 'eslint/use-at-your-own-risk';
4
4
 
5
- const rule$b = {
5
+ const rule$c = {
6
6
  meta: {
7
7
  docs: {
8
8
  description: "Enforce one-line ternaries if under a character limit, multiline otherwise",
@@ -64,7 +64,7 @@ const rule$b = {
64
64
  }
65
65
  };
66
66
 
67
- const rule$a = {
67
+ const rule$b = {
68
68
  meta: {
69
69
  docs: {
70
70
  description: "Enforce multiline formatting for union types with more than N items",
@@ -134,6 +134,166 @@ const rule$a = {
134
134
  }
135
135
  };
136
136
 
137
+ function collapseBlankLine(text) {
138
+ return text.replace(/\n[^\S\n]*\n[^\S\n]*/, "\n");
139
+ }
140
+ function getActualLastToken(node, sourceCode) {
141
+ const semiToken = sourceCode.getLastToken(node);
142
+ if (!semiToken) {
143
+ return null;
144
+ }
145
+ const prevToken = sourceCode.getTokenBefore(semiToken);
146
+ const nextToken = sourceCode.getTokenAfter(semiToken);
147
+ if (prevToken && nextToken && prevToken.range[0] >= node.range[0] && semiToken.type === "Punctuator" && semiToken.value === ";" && prevToken.loc.end.line < semiToken.loc.start.line && semiToken.loc.end.line === nextToken.loc.start.line) {
148
+ return prevToken;
149
+ }
150
+ return semiToken;
151
+ }
152
+ function getBlankLineRequirement(prevNode, nextNode) {
153
+ if (!isAwaitStatement(prevNode)) {
154
+ return null;
155
+ }
156
+ if (!isAwaitStatement(nextNode)) {
157
+ return "always";
158
+ }
159
+ if (isSingleLine(prevNode) && isSingleLine(nextNode)) {
160
+ return "never";
161
+ }
162
+ return "always";
163
+ }
164
+ function getPaddingLineSequences(prevNode, nextNode, sourceCode) {
165
+ const pairs = [];
166
+ const prevToken = getActualLastToken(prevNode, sourceCode);
167
+ if (!prevToken) {
168
+ return pairs;
169
+ }
170
+ if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
171
+ let currentToken = prevToken;
172
+ while (currentToken.range[0] < nextNode.range[0]) {
173
+ const token = sourceCode.getTokenAfter(currentToken, { includeComments: true });
174
+ if (!token || token.range[0] >= nextNode.range[0]) {
175
+ break;
176
+ }
177
+ if (token.loc.start.line - currentToken.loc.end.line >= 2) {
178
+ pairs.push([currentToken, token]);
179
+ }
180
+ currentToken = token;
181
+ }
182
+ }
183
+ return pairs;
184
+ }
185
+ function isAwaitStatement(node) {
186
+ return node.type === distExports.AST_NODE_TYPES.ExpressionStatement && node.expression.type === distExports.AST_NODE_TYPES.AwaitExpression;
187
+ }
188
+ function isSingleLine(node) {
189
+ return node.loc.start.line === node.loc.end.line;
190
+ }
191
+ const rule$a = {
192
+ defaultOptions: [],
193
+ meta: {
194
+ docs: { description: "Require or disallow padding lines between standalone await statements" },
195
+ fixable: "whitespace",
196
+ messages: {
197
+ expectedBlankLine: "Expected blank line before this statement.",
198
+ unexpectedBlankLine: "Unexpected blank line before this statement."
199
+ },
200
+ schema: [],
201
+ type: "layout"
202
+ },
203
+ create(context) {
204
+ const sourceCode = context.sourceCode;
205
+ let scopeInfo = null;
206
+ function enterScope() {
207
+ scopeInfo = {
208
+ prevNode: null,
209
+ upper: scopeInfo
210
+ };
211
+ }
212
+ function exitScope() {
213
+ if (scopeInfo) {
214
+ scopeInfo = scopeInfo.upper;
215
+ }
216
+ }
217
+ function verify(node) {
218
+ const parentType = node.parent?.type;
219
+ const allowedParents = /* @__PURE__ */ new Set([
220
+ distExports.AST_NODE_TYPES.BlockStatement,
221
+ distExports.AST_NODE_TYPES.Program,
222
+ distExports.AST_NODE_TYPES.StaticBlock,
223
+ distExports.AST_NODE_TYPES.SwitchCase
224
+ ]);
225
+ if (!parentType || !allowedParents.has(parentType)) {
226
+ return;
227
+ }
228
+ const prevNode = scopeInfo?.prevNode;
229
+ if (prevNode) {
230
+ const requirement = getBlankLineRequirement(prevNode, node);
231
+ if (requirement) {
232
+ const paddingLines = getPaddingLineSequences(prevNode, node, sourceCode);
233
+ if (requirement === "never" && paddingLines.length > 0) {
234
+ context.report({
235
+ fix(fixer) {
236
+ if (paddingLines.length >= 2) {
237
+ return null;
238
+ }
239
+ const [prevToken, nextToken] = paddingLines[0];
240
+ const start = prevToken.range[1];
241
+ const end = nextToken.range[0];
242
+ const text = collapseBlankLine(sourceCode.text.slice(start, end));
243
+ return fixer.replaceTextRange([start, end], text);
244
+ },
245
+ messageId: "unexpectedBlankLine",
246
+ node
247
+ });
248
+ } else if (requirement === "always" && paddingLines.length === 0) {
249
+ context.report({
250
+ fix(fixer) {
251
+ const lastToken = getActualLastToken(prevNode, sourceCode);
252
+ if (!lastToken) {
253
+ return null;
254
+ }
255
+ let currentPrevToken = lastToken;
256
+ const nextToken = sourceCode.getFirstTokenBetween(currentPrevToken, node, {
257
+ filter(token) {
258
+ if (token.loc.start.line === currentPrevToken.loc.start.line) {
259
+ currentPrevToken = token;
260
+ return false;
261
+ }
262
+ return true;
263
+ },
264
+ includeComments: true
265
+ }) || node;
266
+ const insertText = currentPrevToken.loc.end.line === nextToken.loc.start.line ? "\n\n" : "\n";
267
+ return fixer.insertTextAfter(currentPrevToken, insertText);
268
+ },
269
+ messageId: "expectedBlankLine",
270
+ node
271
+ });
272
+ }
273
+ }
274
+ }
275
+ if (scopeInfo) {
276
+ scopeInfo.prevNode = node;
277
+ }
278
+ }
279
+ function verifyThenEnterScope(node) {
280
+ verify(node);
281
+ enterScope();
282
+ }
283
+ return {
284
+ ":statement": verify,
285
+ "BlockStatement": enterScope,
286
+ "BlockStatement:exit": exitScope,
287
+ "Program": enterScope,
288
+ "Program:exit": exitScope,
289
+ "StaticBlock": enterScope,
290
+ "StaticBlock:exit": exitScope,
291
+ "SwitchCase": verifyThenEnterScope,
292
+ "SwitchCase:exit": exitScope
293
+ };
294
+ }
295
+ };
296
+
137
297
  function compareTests(testA, testB) {
138
298
  const functionA = getFunctionName(testA);
139
299
  const functionB = getFunctionName(testB);
@@ -860,8 +1020,9 @@ const rule = {
860
1020
 
861
1021
  const index = {
862
1022
  rules: {
863
- "ts-multiline-ternary": rule$b,
864
- "ts-multiline-union": rule$a,
1023
+ "ts-multiline-ternary": rule$c,
1024
+ "ts-multiline-union": rule$b,
1025
+ "ts-padding-await-statements": rule$a,
865
1026
  "ts-sort-tests": rule$9,
866
1027
  "vue-i18n-consistent-locales": rule$8,
867
1028
  "vue-i18n-consistent-t": rule$7,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasmakers/eslint",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "private": false,
5
5
  "description": "Shared ESLint config and rules for SaaS Makers projects",
6
6
  "license": "MIT",
@@ -27,17 +27,16 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@antfu/eslint-config": "7.4.3",
30
- "@unocss/eslint-plugin": "66.6.0",
31
- "@vitest/eslint-plugin": "1.6.9",
30
+ "@unocss/eslint-plugin": "66.7.0",
31
+ "@vitest/eslint-plugin": "1.6.20",
32
32
  "eslint-plugin-package-json": "0.31.0",
33
- "eslint-plugin-storybook": "10.2.8",
34
- "eslint-plugin-turbo": "2.8.10",
33
+ "eslint-plugin-turbo": "2.9.18",
35
34
  "eslint-plugin-zod": "3.4.0",
36
- "typescript-eslint": "8.55.0"
35
+ "typescript-eslint": "8.61.0"
37
36
  },
38
37
  "devDependencies": {
39
38
  "@eslint/config-inspector": "1.4.2",
40
- "eslint": "10.0.1",
39
+ "eslint": "10.4.1",
41
40
  "typescript": "5.9.3"
42
41
  },
43
42
  "peerDependencies": {