@pobammer-ts/small-rules 2.4.0 → 2.4.1

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 +13 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { definePlugin, defineRule } from "oxlint-plugin-utilities";
2
2
  import ignore from "ignore";
3
- import path, { basename, dirname, extname, join, relative } from "node:path";
3
+ import path, { basename, dirname, extname, isAbsolute, join, relative } from "node:path";
4
4
  import { parseSync } from "oxc-parser";
5
5
  import { existsSync, readFileSync, readdirSync } from "node:fs";
6
6
  import { ResolverFactory } from "oxc-resolver";
@@ -5818,6 +5818,16 @@ const NAME_MATCH_OPTIONS = {
5818
5818
  dot: true,
5819
5819
  magicalBraces: true
5820
5820
  };
5821
+ function normalizePath(value) {
5822
+ return value.replaceAll("\\", "/");
5823
+ }
5824
+ function createFileCandidates(filename) {
5825
+ const normalizedFilename = normalizePath(filename);
5826
+ if (!isAbsolute(filename)) return [normalizedFilename];
5827
+ const relativeFilename = normalizePath(relative(process.cwd(), filename));
5828
+ if (relativeFilename === "" || relativeFilename.startsWith("..")) return [normalizedFilename];
5829
+ return [normalizedFilename, relativeFilename];
5830
+ }
5821
5831
  function compileMatcher(pattern, options) {
5822
5832
  const matcher = new Minimatch(pattern, options);
5823
5833
  const hasMagic = matcher.hasMagic();
@@ -5851,7 +5861,8 @@ function getEffectiveOptions(context) {
5851
5861
  restrictions: []
5852
5862
  };
5853
5863
  const { allowFiles, checkComputed, restrictions } = options;
5854
- const isAllowedFile = allowFiles?.some((pattern) => minimatch(context.filename, pattern, FILE_MATCH_OPTIONS)) ?? false;
5864
+ const fileCandidates = createFileCandidates(context.filename);
5865
+ const isAllowedFile = allowFiles?.some((pattern) => fileCandidates.some((filename) => minimatch(filename, pattern, FILE_MATCH_OPTIONS))) ?? false;
5855
5866
  return {
5856
5867
  checkComputed: checkComputed ?? true,
5857
5868
  isAllowedFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pobammer-ts/small-rules",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Various Oxlint-native rules for linting roblox-ts projects.",
5
5
  "keywords": [
6
6
  "lint",