@so1ve/eslint-plugin 0.93.1 → 0.93.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
@@ -4,6 +4,22 @@ const types = require('@typescript-eslint/types');
4
4
  const utils = require('@typescript-eslint/utils');
5
5
 
6
6
  const createEslintRule = utils.ESLintUtils.RuleCreator((ruleName) => ruleName);
7
+ function getPreviousNode(node) {
8
+ if (!node) {
9
+ return;
10
+ }
11
+ const { parent } = node;
12
+ if (parent && "body" in parent) {
13
+ const { body } = parent;
14
+ if (!Array.isArray(body)) {
15
+ return;
16
+ }
17
+ const index = body.indexOf(node);
18
+ if (index > 0) {
19
+ return body[index - 1];
20
+ }
21
+ }
22
+ }
7
23
 
8
24
  const RULE_NAME$6 = "function-style";
9
25
  const START_RETURN = /^return /;
@@ -85,6 +101,10 @@ const functionStyle = createEslintRule({
85
101
  if (haveThisAccess) {
86
102
  return;
87
103
  }
104
+ const previousNode = getPreviousNode(node.parent);
105
+ if (previousNode?.type === types.AST_NODE_TYPES.ExportNamedDeclaration && previousNode.declaration.type === types.AST_NODE_TYPES.TSDeclareFunction) {
106
+ return;
107
+ }
88
108
  const statement = getLoneReturnStatement(node);
89
109
  if (!statement || !node.id?.name || node.generator) {
90
110
  clearThisAccess();
package/dist/index.mjs CHANGED
@@ -2,6 +2,22 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
2
  import { ESLintUtils } from '@typescript-eslint/utils';
3
3
 
4
4
  const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
5
+ function getPreviousNode(node) {
6
+ if (!node) {
7
+ return;
8
+ }
9
+ const { parent } = node;
10
+ if (parent && "body" in parent) {
11
+ const { body } = parent;
12
+ if (!Array.isArray(body)) {
13
+ return;
14
+ }
15
+ const index = body.indexOf(node);
16
+ if (index > 0) {
17
+ return body[index - 1];
18
+ }
19
+ }
20
+ }
5
21
 
6
22
  const RULE_NAME$6 = "function-style";
7
23
  const START_RETURN = /^return /;
@@ -83,6 +99,10 @@ const functionStyle = createEslintRule({
83
99
  if (haveThisAccess) {
84
100
  return;
85
101
  }
102
+ const previousNode = getPreviousNode(node.parent);
103
+ if (previousNode?.type === AST_NODE_TYPES.ExportNamedDeclaration && previousNode.declaration.type === AST_NODE_TYPES.TSDeclareFunction) {
104
+ return;
105
+ }
86
106
  const statement = getLoneReturnStatement(node);
87
107
  if (!statement || !node.id?.name || node.generator) {
88
108
  clearThisAccess();
package/package.json CHANGED
@@ -1,12 +1,7 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "0.93.1",
4
- "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
5
- "contributors": [
6
- {
7
- "name": "Ray <i@mk1.io> (https://github.com/so1ve/)"
8
- }
9
- ],
3
+ "version": "0.93.2",
4
+ "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
10
5
  "keywords": [
11
6
  "eslint",
12
7
  "eslint-config",