Skip to content

Fixed file paths broke by adding / to every paths #85

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ Typescript plugin that allows turning on strict mode in specific files or direct

## Do I need this plugin?

`typescript-strict-plugin` was created mainly for existing projects that want to incorporate
`tsc-strict` was created mainly for existing projects that want to incorporate
typescript strict mode, but project is so big that refactoring everything would take ages.

Our plugin allows adding strict mode to a TypeScript project without fixing all the errors at once.
@@ -24,13 +24,13 @@ files. Therefore, we have strict errors inside our files and during build time.
Use `npm`:

```bash
npm i --save-dev typescript-strict-plugin
npm i --save-dev tsc-strict
```

or yarn

```bash
yarn add -D typescript-strict-plugin
yarn add -D tsc-strict
```

add plugin to your `tsconfig.json`:
@@ -42,7 +42,7 @@ add plugin to your `tsconfig.json`:
"strict": false,
"plugins": [
{
"name": "typescript-strict-plugin"
"name": "tsc-strict"
}
]
}
@@ -73,7 +73,7 @@ ignored paths you can insert `//@ts-strict` comment.
"strict": false,
"plugins": [
{
"name": "typescript-strict-plugin",
"name": "tsc-strict",
"paths": [
"./src",
"/absolute/path/to/source/"
2 changes: 1 addition & 1 deletion e2e/fixtures/default-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"noImplicitAny": true,
"plugins": [
{
"name": "typescript-strict-plugin"
"name": "tsc-strict"
}
]
}
2 changes: 1 addition & 1 deletion e2e/fixtures/non-root-config/nested/tsconfig.json
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
"noImplicitAny": true,
"plugins": [
{
"name": "typescript-strict-plugin"
"name": "tsc-strict"
}
]
}
2 changes: 1 addition & 1 deletion e2e/fixtures/path-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
"noImplicitAny": true,
"plugins": [
{
"name": "typescript-strict-plugin",
"name": "tsc-strict",
"paths": ["./included"]
}
]
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
{
"name": "typescript-strict-plugin",
"version": "2.4.4",
"name": "tsc-strict",
"version": "2.4.5",
"description": "Typescript tools that help with migration to the strict mode",
"author": "Allegro",
"contributors": [
"Jaroslaw Glegola <jaroslaw.glegola@allegro.pl>",
"Kamil Krysiak <kamil.krysiak@allegro.pl>"
],
"author": "floklein",
"contributors": [],
"keywords": [
"TypeScript Strict",
"TypeScript plugin",
"TypeScript Language Service"
],
"bugs": {
"url": "https://github.com/allegro/typescript-strict-plugin/issues"
"url": "https://github.com/floklein/tsc-strict/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/allegro/typescript-strict-plugin.git"
"url": "git+https://github.com/floklein/tsc-strict.git"
},
"license": "MIT",
"bin": {
@@ -74,7 +71,7 @@
"ts-jest": "^29.1.2",
"ts-node": "10.4.0",
"typescript": "^5.4.5",
"typescript-strict-plugin": "file:./",
"tsc-strict": "file:./",
"which-module": "^2.0.0"
},
"lint-staged": {
@@ -88,5 +85,5 @@
"pre-commit": "lint-staged"
}
},
"homepage": "https://github.com/allegro/typescript-strict-plugin#readme"
"homepage": "https://github.com/floklein/tsc-strict#readme"
}
6 changes: 3 additions & 3 deletions sample-project/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sample-project/package.json
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
"license": "ISC",
"devDependencies": {
"@types/node": "^10.3.2",
"typescript-strict-plugin": "file:../../typescript-strict-plugin",
"tsc-strict": "file:../../tsc-strict",
"typescript": "5.2.2"
}
}
2 changes: 1 addition & 1 deletion sample-project/tsconfig.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
"noImplicitAny": true,
"plugins": [
{
"name": "typescript-strict-plugin"
"name": "tsc-strict"
}
]
}
4 changes: 2 additions & 2 deletions src/cli/errorMessages.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const notConfiguredError = `
typescript-strict-plugin isn't configured in tsconfig.json
tsc-strict isn't configured in tsconfig.json

Please add following configuration:
{
"compilerOptions": {
...
"plugins": [{
"name": "typescript-strict-plugin"
"name": "tsc-strict"
}]
},
}
2 changes: 1 addition & 1 deletion src/cli/tsc-strict/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ describe('tsc-strict root', () => {

// then
expect(console.log).toHaveBeenCalledWith(
expect.stringMatching(/typescript-strict-plugin isn't configured in tsconfig.json/i),
expect.stringMatching(/tsc-strict isn't configured in tsconfig.json/i),
);
expect(process.exit).toHaveBeenCalledWith(1);
});
2 changes: 1 addition & 1 deletion src/cli/update-strict-comments/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ describe('update-strict-comments root', () => {

// then
expect(console.log).toHaveBeenCalledWith(
expect.stringMatching(/typescript-strict-plugin isn't configured in tsconfig.json/i),
expect.stringMatching(/tsc-strict isn't configured in tsconfig.json/i),
);
expect(process.exit).toHaveBeenCalledWith(1);
});
4 changes: 2 additions & 2 deletions src/common/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ describe('utils', () => {
it('should return undefined if --project not present in path', () => {
process.argv = [
'/usr/bin/nodejs/18.7.0/bin/node',
'/home/neenjaw/typescript-strict-plugin/node_modules/.bin/update-strict-comments',
'/home/neenjaw/tsc-strict/node_modules/.bin/update-strict-comments',
];

expect(getProjectPathFromArgs()).toEqual(undefined);
@@ -24,7 +24,7 @@ describe('utils', () => {
it('should return undefined if --project not present in path', () => {
process.argv = [
'/usr/bin/nodejs/18.7.0/bin/node',
'/home/neenjaw/typescript-strict-plugin/node_modules/.bin/update-strict-comments',
'/home/neenjaw/tsc-strict/node_modules/.bin/update-strict-comments',
'--project',
'./some/inner/project/tsconfig.json',
];
2 changes: 1 addition & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const PLUGIN_NAME = 'typescript-strict-plugin';
export const PLUGIN_NAME = 'tsc-strict';
export const TS_STRICT_COMMENT = '@ts-strict';
export const TS_STRICT_IGNORE_COMMENT = '@ts-strict-ignore';
6 changes: 4 additions & 2 deletions src/common/isFileOnPath.ts
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@ export function isFileOnPath({

const absolutePathToStrictFiles = getAbsolutePath(projectPath, targetPath);

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