Skip to content

Don't match path on prefix alone#68

Merged
KostkaBrukowa merged 1 commit into
allegro:masterfrom
heyimalex:fix-prefixed-paths-2
Mar 7, 2024
Merged

Don't match path on prefix alone#68
KostkaBrukowa merged 1 commit into
allegro:masterfrom
heyimalex:fix-prefixed-paths-2

Conversation

@heyimalex

Copy link
Copy Markdown
Contributor

Noticed that path/to/good was matching path/to/goodness-no/file.ts, so just the prefix and not the exact directory. I will maybe add tests this weekend.

@kellyrmilligan

Copy link
Copy Markdown

would love to see this merged if it passes tests. I have the same issue.

@kellyrmilligan

Copy link
Copy Markdown

if anyone else ends up here, I ended up for now just using pnpm's built in patch feature. another option if not using pnpm would be:

https://www.npmjs.com/package/patch-package

@KostkaBrukowa KostkaBrukowa merged commit 7c9d48e into allegro:master Mar 7, 2024
KostkaBrukowa added a commit that referenced this pull request Mar 7, 2024
@KostkaBrukowa

Copy link
Copy Markdown
Collaborator

Thanks for contribution! Published with 2.3.2

@solomkinmv

solomkinmv commented Apr 1, 2024

Copy link
Copy Markdown

Hey. My use case was to use exact file path like path/to/goodness-no/file.ts, but looks like this change breaks it. Now exact matches doesn't work any more

@heyimalex

Copy link
Copy Markdown
Contributor Author

@solomkinmv If you want to contribute, I think a fix would be:

const posixFilePath = getPosixFilePath(filePath);
const posixStrictPath = getPosixFilePath(absolutePathToStrictFiles);
return posixFilePath === posixStrictPath || posixFilePath.startsWith(posixStrictPath + path.posix.sep);

@floklein

floklein commented Aug 13, 2024

Copy link
Copy Markdown

This breaks every file paths. So the README.md is not accurate anymore:

{
  "compilerOptions": {
    ...
    "strict": false,
    "plugins": [
      {
        "name": "typescript-strict-plugin",
        "paths": [
          "./src",
          "/absolute/path/to/source/"
        ],
        "exclude": [
          "./src/tests",
          "./src/fileToExclude.ts"
        ],
        "excludePattern": [
          "**/*.spec.ts"
        ]
      }
    ]
  }
}

@floklein

floklein commented Aug 13, 2024

Copy link
Copy Markdown

Submitted a PR (#86) to fix this. Thanks @heyimalex!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants