eslint-plugin-absolute 0.11.0-beta.4 → 0.11.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.
Files changed (2) hide show
  1. package/dist/index.js +12 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2032,6 +2032,12 @@ var visitImmediateReferences = (node, onReference) => {
2032
2032
  };
2033
2033
  visit(node);
2034
2034
  };
2035
+ var getDeclarationDecorators = (declaration) => {
2036
+ if (declaration && "decorators" in declaration && Array.isArray(declaration.decorators)) {
2037
+ return declaration.decorators;
2038
+ }
2039
+ return [];
2040
+ };
2035
2041
  var getImmediateDependencyNames = (node) => {
2036
2042
  const names = new Set;
2037
2043
  const { declaration } = node;
@@ -2047,6 +2053,7 @@ var getImmediateDependencyNames = (node) => {
2047
2053
  }
2048
2054
  if (declaration.type === "ClassDeclaration") {
2049
2055
  visitImmediateReferences(declaration.superClass, addName);
2056
+ getDeclarationDecorators(declaration).forEach((decorator) => visitImmediateReferences(decorator, addName));
2050
2057
  declaration.body.body.forEach(addClassElementDependencies);
2051
2058
  }
2052
2059
  return names;
@@ -2060,7 +2067,9 @@ var sortExports = createRule({
2060
2067
  const natural = option && typeof option.natural === "boolean" ? option.natural : false;
2061
2068
  const minKeys = option && typeof option.minKeys === "number" ? option.minKeys : 2;
2062
2069
  const variablesBeforeFunctions = option && typeof option.variablesBeforeFunctions === "boolean" ? option.variablesBeforeFunctions : false;
2063
- const generateExportText = (node) => sourceCode.getText(node).trim().replace(/\s*;?\s*$/, ";");
2070
+ const getNodeStart = (node) => getDeclarationDecorators(node.declaration).reduce((start, decorator) => Math.min(start, decorator.range[0]), node.range[0]);
2071
+ const getNodeText = (node) => sourceCode.getText().slice(getNodeStart(node), node.range[1]);
2072
+ const generateExportText = (node) => getNodeText(node).trim().replace(/\s*;?\s*$/, ";");
2064
2073
  const compareStrings = (strLeft, strRight) => {
2065
2074
  let left = strLeft;
2066
2075
  let right = strRight;
@@ -2115,7 +2124,7 @@ var sortExports = createRule({
2115
2124
  isFunction: isFunctionExport(node),
2116
2125
  name,
2117
2126
  node,
2118
- text: sourceCode.getText(node)
2127
+ text: getNodeText(node)
2119
2128
  };
2120
2129
  return item;
2121
2130
  }).filter((item) => item !== null);
@@ -2208,7 +2217,7 @@ var sortExports = createRule({
2208
2217
  }
2209
2218
  const sortedText = sortedItems.map((item) => generateExportText(item.node)).join(`
2210
2219
  `);
2211
- const [rangeStart] = firstNode.range;
2220
+ const rangeStart = getNodeStart(firstNode);
2212
2221
  const [, rangeEnd] = lastNode.range;
2213
2222
  const fullText = sourceCode.getText();
2214
2223
  const originalText = fullText.slice(rangeStart, rangeEnd);
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "typecheck": "bun run tsc --noEmit"
41
41
  },
42
42
  "type": "module",
43
- "version": "0.11.0-beta.4"
43
+ "version": "0.11.0"
44
44
  }