@so1ve/eslint-plugin 0.93.2 → 0.93.3

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
@@ -62,7 +62,7 @@ const functionStyle = createEslintRule({
62
62
  const params = node.params.map((param) => sourceCode.getText(param)).join(", ");
63
63
  const returnType = node.returnType ? sourceCode.getText(node.returnType) : "";
64
64
  const body = sourceCode.getText(node.body);
65
- const variableDeclaration = asVariable ? `const ${name} = ` : "";
65
+ const variableDeclaration = asVariable && name ? `const ${name} = ` : "";
66
66
  return type === "arrow" ? `${variableDeclaration}${async}${generics}(${params})${returnType} => ${rawStatement};` : `${async}function ${name}${generics}(${params})${returnType} ${body}`;
67
67
  }
68
68
  let currentScope = null;
@@ -106,11 +106,11 @@ const functionStyle = createEslintRule({
106
106
  return;
107
107
  }
108
108
  const statement = getLoneReturnStatement(node);
109
- if (!statement || !node.id?.name || node.generator) {
109
+ const isExportDefault = node.parent?.type === types.AST_NODE_TYPES.ExportDefaultDeclaration;
110
+ if (!statement || !node.id?.name && !isExportDefault || node.generator) {
110
111
  clearThisAccess();
111
112
  return;
112
113
  }
113
- const asVariable = node.parent?.type !== types.AST_NODE_TYPES.ExportDefaultDeclaration;
114
114
  context.report({
115
115
  node,
116
116
  messageId: "arrow",
@@ -118,10 +118,10 @@ const functionStyle = createEslintRule({
118
118
  node.range,
119
119
  generateFunction(
120
120
  "arrow",
121
- node.id.name,
121
+ node.id?.name ?? null,
122
122
  node,
123
123
  getStatementRaw(statement),
124
- asVariable
124
+ !isExportDefault
125
125
  )
126
126
  )
127
127
  });
package/dist/index.mjs CHANGED
@@ -60,7 +60,7 @@ const functionStyle = createEslintRule({
60
60
  const params = node.params.map((param) => sourceCode.getText(param)).join(", ");
61
61
  const returnType = node.returnType ? sourceCode.getText(node.returnType) : "";
62
62
  const body = sourceCode.getText(node.body);
63
- const variableDeclaration = asVariable ? `const ${name} = ` : "";
63
+ const variableDeclaration = asVariable && name ? `const ${name} = ` : "";
64
64
  return type === "arrow" ? `${variableDeclaration}${async}${generics}(${params})${returnType} => ${rawStatement};` : `${async}function ${name}${generics}(${params})${returnType} ${body}`;
65
65
  }
66
66
  let currentScope = null;
@@ -104,11 +104,11 @@ const functionStyle = createEslintRule({
104
104
  return;
105
105
  }
106
106
  const statement = getLoneReturnStatement(node);
107
- if (!statement || !node.id?.name || node.generator) {
107
+ const isExportDefault = node.parent?.type === AST_NODE_TYPES.ExportDefaultDeclaration;
108
+ if (!statement || !node.id?.name && !isExportDefault || node.generator) {
108
109
  clearThisAccess();
109
110
  return;
110
111
  }
111
- const asVariable = node.parent?.type !== AST_NODE_TYPES.ExportDefaultDeclaration;
112
112
  context.report({
113
113
  node,
114
114
  messageId: "arrow",
@@ -116,10 +116,10 @@ const functionStyle = createEslintRule({
116
116
  node.range,
117
117
  generateFunction(
118
118
  "arrow",
119
- node.id.name,
119
+ node.id?.name ?? null,
120
120
  node,
121
121
  getStatementRaw(statement),
122
- asVariable
122
+ !isExportDefault
123
123
  )
124
124
  )
125
125
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-plugin",
3
- "version": "0.93.2",
3
+ "version": "0.93.3",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "keywords": [
6
6
  "eslint",