eslint-plugin-absolute 0.11.0-beta.2 → 0.11.0-beta.4

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 +60 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3744,6 +3744,65 @@ var noRedundantTypeAnnotation = createRule({
3744
3744
  name: "no-redundant-type-annotation"
3745
3745
  });
3746
3746
 
3747
+ // src/rules/no-import-meta-path.ts
3748
+ var FILESYSTEM_PATH_PROPERTIES = new Set(["dir", "dirname", "filename"]);
3749
+ var isImportMeta = (node) => node.type === "MetaProperty" && node.meta.name === "import" && node.property.name === "meta";
3750
+ var importMetaProperty = (node) => {
3751
+ if (!isImportMeta(node.object))
3752
+ return null;
3753
+ if (node.computed || node.property.type !== "Identifier")
3754
+ return null;
3755
+ return node.property.name;
3756
+ };
3757
+ var calleeName = (callee) => {
3758
+ if (callee.type === "Identifier")
3759
+ return callee.name;
3760
+ if (callee.type === "MemberExpression" && callee.property.type === "Identifier") {
3761
+ return callee.property.name;
3762
+ }
3763
+ return null;
3764
+ };
3765
+ var noImportMetaPath = createRule({
3766
+ create(context) {
3767
+ return {
3768
+ CallExpression(node) {
3769
+ if (calleeName(node.callee) !== "fileURLToPath")
3770
+ return;
3771
+ const urlArgument = node.arguments.find((argument) => argument.type === "MemberExpression" && importMetaProperty(argument) === "url");
3772
+ if (urlArgument) {
3773
+ context.report({
3774
+ messageId: "importMetaUrl",
3775
+ node: urlArgument
3776
+ });
3777
+ }
3778
+ },
3779
+ MemberExpression(node) {
3780
+ const property = importMetaProperty(node);
3781
+ if (property && FILESYSTEM_PATH_PROPERTIES.has(property)) {
3782
+ context.report({
3783
+ data: { property },
3784
+ messageId: "importMetaPath",
3785
+ node
3786
+ });
3787
+ }
3788
+ }
3789
+ };
3790
+ },
3791
+ defaultOptions: [],
3792
+ meta: {
3793
+ 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()`. 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
+ },
3796
+ messages: {
3797
+ 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()`).",
3798
+ importMetaUrl: "`fileURLToPath(import.meta.url)` derives a filesystem path from this module's own location, which moves when the server is bundled (src/ in `absolute dev`, dist/ in `absolute start`) \u2014 so the path silently breaks in production. Anchor runtime/data paths to `projectRoot` from @absolutejs/absolute (or `process.cwd()`)."
3799
+ },
3800
+ schema: [],
3801
+ type: "problem"
3802
+ },
3803
+ name: "no-import-meta-path"
3804
+ });
3805
+
3747
3806
  // src/rules/no-trivial-alias.ts
3748
3807
  var isBareTypeReference = (node) => {
3749
3808
  if (node.type === "TSTypeReference") {
@@ -3995,6 +4054,7 @@ var src_default = {
3995
4054
  "min-var-length": minVarLength,
3996
4055
  "no-button-navigation": noButtonNavigation,
3997
4056
  "no-explicit-return-type": noExplicitReturnTypes,
4057
+ "no-import-meta-path": noImportMetaPath,
3998
4058
  "no-inline-object-types": noInlineObjectTypes,
3999
4059
  "no-multi-style-objects": noMultiStyleObjects,
4000
4060
  "no-nested-jsx-return": noNestedJSXReturn,
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.2"
43
+ "version": "0.11.0-beta.4"
44
44
  }