eslint-plugin-absolute 0.11.0-beta.3 → 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.
- package/dist/index.js +13 -4
- 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
|
|
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:
|
|
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
|
|
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);
|
|
@@ -3791,7 +3800,7 @@ var noImportMetaPath = createRule({
|
|
|
3791
3800
|
defaultOptions: [],
|
|
3792
3801
|
meta: {
|
|
3793
3802
|
docs: {
|
|
3794
|
-
description: "Disallow deriving filesystem paths from a module's own location (`import.meta.dir`/`dirname`/`filename`, `fileURLToPath(import.meta.url)`). They move when the server is bundled, so paths break in `absolute start`. Anchor to `projectRoot` from @absolutejs/absolute or `process.cwd()`."
|
|
3803
|
+
description: "Disallow deriving filesystem paths from a module's own location (`import.meta.dir`/`dirname`/`filename`, `fileURLToPath(import.meta.url)`). They move when the server is bundled, so paths break in `absolute start`. Anchor to `projectRoot` from @absolutejs/absolute or `process.cwd()`. This targets application server code; a library locating its OWN shipped assets is a legitimate exception (projectRoot is the consuming app's root, not the package's location) \u2014 turn the rule off for those files via an override."
|
|
3795
3804
|
},
|
|
3796
3805
|
messages: {
|
|
3797
3806
|
importMetaPath: "`import.meta.{{property}}` resolves this module's own location, which is your src/ tree in `absolute dev` but the bundled dist/ in `absolute start` \u2014 module-relative paths silently break in production. Anchor runtime/data paths to `projectRoot` from @absolutejs/absolute (or `process.cwd()`).",
|
package/package.json
CHANGED