@so1ve/eslint-plugin 0.80.0 → 0.81.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 CHANGED
@@ -5,11 +5,11 @@ const utils = require('@typescript-eslint/utils');
5
5
 
6
6
  const createEslintRule = utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
7
7
 
8
- const RULE_NAME$4 = "function-style";
8
+ const RULE_NAME$5 = "function-style";
9
9
  const START_RETURN = /^return /;
10
10
  const END_SEMICOLON = /;$/;
11
11
  const functionStyle = createEslintRule({
12
- name: RULE_NAME$4,
12
+ name: RULE_NAME$5,
13
13
  meta: {
14
14
  type: "problem",
15
15
  docs: {
@@ -162,9 +162,9 @@ const functionStyle = createEslintRule({
162
162
  }
163
163
  });
164
164
 
165
- const RULE_NAME$3 = "import-dedupe";
165
+ const RULE_NAME$4 = "import-dedupe";
166
166
  const importDedupe = createEslintRule({
167
- name: RULE_NAME$3,
167
+ name: RULE_NAME$4,
168
168
  meta: {
169
169
  type: "problem",
170
170
  docs: {
@@ -210,9 +210,9 @@ const importDedupe = createEslintRule({
210
210
  })
211
211
  });
212
212
 
213
- const RULE_NAME$2 = "no-inline-type-import";
213
+ const RULE_NAME$3 = "no-inline-type-import";
214
214
  const noInlineTypeImport = createEslintRule({
215
- name: RULE_NAME$2,
215
+ name: RULE_NAME$3,
216
216
  meta: {
217
217
  type: "layout",
218
218
  docs: {
@@ -276,7 +276,7 @@ const noInlineTypeImport = createEslintRule({
276
276
  }
277
277
  });
278
278
 
279
- const RULE_NAME$1 = "no-negated-comparison";
279
+ const RULE_NAME$2 = "no-negated-comparison";
280
280
  const negatedToPositive = {
281
281
  "==": "!=",
282
282
  "===": "!==",
@@ -289,7 +289,7 @@ const negatedToPositive = {
289
289
  };
290
290
  const negatives = Object.keys(negatedToPositive);
291
291
  const noNegatedComparison = createEslintRule({
292
- name: RULE_NAME$1,
292
+ name: RULE_NAME$2,
293
293
  meta: {
294
294
  type: "problem",
295
295
  docs: {
@@ -326,9 +326,9 @@ const noNegatedComparison = createEslintRule({
326
326
  })
327
327
  });
328
328
 
329
- const RULE_NAME = "no-useless-template-string";
329
+ const RULE_NAME$1 = "no-useless-template-string";
330
330
  const noUselessTemplateString = createEslintRule({
331
- name: RULE_NAME,
331
+ name: RULE_NAME$1,
332
332
  meta: {
333
333
  type: "problem",
334
334
  docs: {
@@ -361,13 +361,54 @@ const noUselessTemplateString = createEslintRule({
361
361
  })
362
362
  });
363
363
 
364
+ const RULE_NAME = "pad-after-last-import";
365
+ const padAfterLastImport = createEslintRule({
366
+ name: RULE_NAME,
367
+ meta: {
368
+ type: "problem",
369
+ docs: {
370
+ description: "Pad after the last import.",
371
+ recommended: "error"
372
+ },
373
+ fixable: "code",
374
+ schema: [],
375
+ messages: {
376
+ padAfterLastImport: "Expected a blank line after the last import."
377
+ }
378
+ },
379
+ defaultOptions: [],
380
+ create: (context) => {
381
+ const sourceCode = context.getSourceCode();
382
+ let lastImportNode = null;
383
+ return {
384
+ ImportDeclaration(node) {
385
+ lastImportNode = node;
386
+ },
387
+ "Program:exit"() {
388
+ if (lastImportNode) {
389
+ const nextToken = sourceCode.getTokenAfter(lastImportNode);
390
+ if (nextToken && // Workaround: Vue
391
+ nextToken.value !== "<\/script>" && lastImportNode.loc.end.line + 1 === nextToken.loc.start.line) {
392
+ context.report({
393
+ node: lastImportNode,
394
+ messageId: "padAfterLastImport",
395
+ fix: (fixer) => fixer.insertTextAfter(lastImportNode, "\n")
396
+ });
397
+ }
398
+ }
399
+ }
400
+ };
401
+ }
402
+ });
403
+
364
404
  const index = {
365
405
  rules: {
366
406
  "function-style": functionStyle,
367
407
  "import-dedupe": importDedupe,
368
408
  "no-inline-type-import": noInlineTypeImport,
369
409
  "no-useless-template-string": noUselessTemplateString,
370
- "no-negated-comparison": noNegatedComparison
410
+ "no-negated-comparison": noNegatedComparison,
411
+ "pad-after-last-import": padAfterLastImport
371
412
  }
372
413
  };
373
414
 
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  "no-inline-type-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noInlineTypeImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
10
10
  "no-useless-template-string": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noUselessTemplateString", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
11
11
  "no-negated-comparison": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noNegatedComparison", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
12
+ "pad-after-last-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"padAfterLastImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
12
13
  };
13
14
  };
14
15
 
package/dist/index.mjs CHANGED
@@ -3,11 +3,11 @@ import { ESLintUtils } from '@typescript-eslint/utils';
3
3
 
4
4
  const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
5
5
 
6
- const RULE_NAME$4 = "function-style";
6
+ const RULE_NAME$5 = "function-style";
7
7
  const START_RETURN = /^return /;
8
8
  const END_SEMICOLON = /;$/;
9
9
  const functionStyle = createEslintRule({
10
- name: RULE_NAME$4,
10
+ name: RULE_NAME$5,
11
11
  meta: {
12
12
  type: "problem",
13
13
  docs: {
@@ -160,9 +160,9 @@ const functionStyle = createEslintRule({
160
160
  }
161
161
  });
162
162
 
163
- const RULE_NAME$3 = "import-dedupe";
163
+ const RULE_NAME$4 = "import-dedupe";
164
164
  const importDedupe = createEslintRule({
165
- name: RULE_NAME$3,
165
+ name: RULE_NAME$4,
166
166
  meta: {
167
167
  type: "problem",
168
168
  docs: {
@@ -208,9 +208,9 @@ const importDedupe = createEslintRule({
208
208
  })
209
209
  });
210
210
 
211
- const RULE_NAME$2 = "no-inline-type-import";
211
+ const RULE_NAME$3 = "no-inline-type-import";
212
212
  const noInlineTypeImport = createEslintRule({
213
- name: RULE_NAME$2,
213
+ name: RULE_NAME$3,
214
214
  meta: {
215
215
  type: "layout",
216
216
  docs: {
@@ -274,7 +274,7 @@ const noInlineTypeImport = createEslintRule({
274
274
  }
275
275
  });
276
276
 
277
- const RULE_NAME$1 = "no-negated-comparison";
277
+ const RULE_NAME$2 = "no-negated-comparison";
278
278
  const negatedToPositive = {
279
279
  "==": "!=",
280
280
  "===": "!==",
@@ -287,7 +287,7 @@ const negatedToPositive = {
287
287
  };
288
288
  const negatives = Object.keys(negatedToPositive);
289
289
  const noNegatedComparison = createEslintRule({
290
- name: RULE_NAME$1,
290
+ name: RULE_NAME$2,
291
291
  meta: {
292
292
  type: "problem",
293
293
  docs: {
@@ -324,9 +324,9 @@ const noNegatedComparison = createEslintRule({
324
324
  })
325
325
  });
326
326
 
327
- const RULE_NAME = "no-useless-template-string";
327
+ const RULE_NAME$1 = "no-useless-template-string";
328
328
  const noUselessTemplateString = createEslintRule({
329
- name: RULE_NAME,
329
+ name: RULE_NAME$1,
330
330
  meta: {
331
331
  type: "problem",
332
332
  docs: {
@@ -359,13 +359,54 @@ const noUselessTemplateString = createEslintRule({
359
359
  })
360
360
  });
361
361
 
362
+ const RULE_NAME = "pad-after-last-import";
363
+ const padAfterLastImport = createEslintRule({
364
+ name: RULE_NAME,
365
+ meta: {
366
+ type: "problem",
367
+ docs: {
368
+ description: "Pad after the last import.",
369
+ recommended: "error"
370
+ },
371
+ fixable: "code",
372
+ schema: [],
373
+ messages: {
374
+ padAfterLastImport: "Expected a blank line after the last import."
375
+ }
376
+ },
377
+ defaultOptions: [],
378
+ create: (context) => {
379
+ const sourceCode = context.getSourceCode();
380
+ let lastImportNode = null;
381
+ return {
382
+ ImportDeclaration(node) {
383
+ lastImportNode = node;
384
+ },
385
+ "Program:exit"() {
386
+ if (lastImportNode) {
387
+ const nextToken = sourceCode.getTokenAfter(lastImportNode);
388
+ if (nextToken && // Workaround: Vue
389
+ nextToken.value !== "<\/script>" && lastImportNode.loc.end.line + 1 === nextToken.loc.start.line) {
390
+ context.report({
391
+ node: lastImportNode,
392
+ messageId: "padAfterLastImport",
393
+ fix: (fixer) => fixer.insertTextAfter(lastImportNode, "\n")
394
+ });
395
+ }
396
+ }
397
+ }
398
+ };
399
+ }
400
+ });
401
+
362
402
  const index = {
363
403
  rules: {
364
404
  "function-style": functionStyle,
365
405
  "import-dedupe": importDedupe,
366
406
  "no-inline-type-import": noInlineTypeImport,
367
407
  "no-useless-template-string": noUselessTemplateString,
368
- "no-negated-comparison": noNegatedComparison
408
+ "no-negated-comparison": noNegatedComparison,
409
+ "pad-after-last-import": padAfterLastImport
369
410
  }
370
411
  };
371
412
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
5
5
  "contributors": [
6
6
  {