From 1564f73fdb9030119bf1dde89d02acaba39b0b02 Mon Sep 17 00:00:00 2001 From: Florent Klein Date: Tue, 13 Aug 2024 17:41:24 +0200 Subject: [PATCH 1/4] fixed file paths usage --- package-lock.json | 4 ++-- src/common/isFileOnPath.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a168dc7..f5afc45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "typescript-strict-plugin", - "version": "2.4.3", + "version": "2.4.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "typescript-strict-plugin", - "version": "2.4.3", + "version": "2.4.4", "license": "MIT", "dependencies": { "chalk": "^3.0.0", diff --git a/src/common/isFileOnPath.ts b/src/common/isFileOnPath.ts index 5db446c..fc5a66a 100644 --- a/src/common/isFileOnPath.ts +++ b/src/common/isFileOnPath.ts @@ -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) ); } From 61387fbb2c3a3cbe5738fc76c8d7697bce4541a9 Mon Sep 17 00:00:00 2001 From: Florent Klein Date: Wed, 14 Aug 2024 14:29:57 +0200 Subject: [PATCH 2/4] Update package.json --- package.json | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 35b77a1..b5e49cf 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,20 @@ { - "name": "typescript-strict-plugin", + "name": "tsc-strict", "version": "2.4.4", "description": "Typescript tools that help with migration to the strict mode", - "author": "Allegro", - "contributors": [ - "Jaroslaw Glegola ", - "Kamil Krysiak " - ], + "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/typescript-strict-plugin/issues" }, "repository": { "type": "git", - "url": "git+https://github.com/allegro/typescript-strict-plugin.git" + "url": "git+https://github.com/floklein/typescript-strict-plugin.git" }, "license": "MIT", "bin": { @@ -88,5 +85,5 @@ "pre-commit": "lint-staged" } }, - "homepage": "https://github.com/allegro/typescript-strict-plugin#readme" + "homepage": "https://github.com/floklein/typescript-strict-plugin#readme" } From 5e5349432c1fa82a5959fabc2c8d638e6e29f7dc Mon Sep 17 00:00:00 2001 From: Florent Klein Date: Wed, 14 Aug 2024 14:40:33 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 25140fa..8349ef0 100644 --- a/README.md +++ b/README.md @@ -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/" From a68f6cebeb5b8ed6d41a5452e783379feeb8fe76 Mon Sep 17 00:00:00 2001 From: Florent Klein Date: Wed, 14 Aug 2024 17:41:26 +0200 Subject: [PATCH 4/4] Renamed plugin --- e2e/fixtures/default-config/tsconfig.json | 2 +- e2e/fixtures/non-root-config/nested/tsconfig.json | 2 +- e2e/fixtures/path-config/tsconfig.json | 2 +- package-lock.json | 14 +++++++------- package.json | 10 +++++----- sample-project/package-lock.json | 6 +++--- sample-project/package.json | 2 +- sample-project/tsconfig.json | 2 +- src/cli/errorMessages.ts | 4 ++-- src/cli/tsc-strict/__tests__/index.spec.ts | 2 +- .../update-strict-comments/__tests__/index.spec.ts | 2 +- src/common/__tests__/utils.spec.ts | 4 ++-- src/common/constants.ts | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/e2e/fixtures/default-config/tsconfig.json b/e2e/fixtures/default-config/tsconfig.json index d200b5f..8726fdd 100644 --- a/e2e/fixtures/default-config/tsconfig.json +++ b/e2e/fixtures/default-config/tsconfig.json @@ -11,7 +11,7 @@ "noImplicitAny": true, "plugins": [ { - "name": "typescript-strict-plugin" + "name": "tsc-strict" } ] } diff --git a/e2e/fixtures/non-root-config/nested/tsconfig.json b/e2e/fixtures/non-root-config/nested/tsconfig.json index d200b5f..8726fdd 100644 --- a/e2e/fixtures/non-root-config/nested/tsconfig.json +++ b/e2e/fixtures/non-root-config/nested/tsconfig.json @@ -11,7 +11,7 @@ "noImplicitAny": true, "plugins": [ { - "name": "typescript-strict-plugin" + "name": "tsc-strict" } ] } diff --git a/e2e/fixtures/path-config/tsconfig.json b/e2e/fixtures/path-config/tsconfig.json index 9e8490c..432a342 100644 --- a/e2e/fixtures/path-config/tsconfig.json +++ b/e2e/fixtures/path-config/tsconfig.json @@ -10,7 +10,7 @@ "noImplicitAny": true, "plugins": [ { - "name": "typescript-strict-plugin", + "name": "tsc-strict", "paths": ["./included"] } ] diff --git a/package-lock.json b/package-lock.json index f5afc45..fa0aff0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "typescript-strict-plugin", + "name": "tsc-strict", "version": "2.4.4", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "typescript-strict-plugin", + "name": "tsc-strict", "version": "2.4.4", "license": "MIT", "dependencies": { @@ -40,8 +40,8 @@ "tmp-promise": "2.0.2", "ts-jest": "^29.1.2", "ts-node": "10.4.0", + "tsc-strict": "file:./", "typescript": "^5.4.5", - "typescript-strict-plugin": "file:./", "which-module": "^2.0.0" } }, @@ -8080,6 +8080,10 @@ } } }, + "node_modules/tsc-strict": { + "resolved": "", + "link": true + }, "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -8132,10 +8136,6 @@ "node": ">=14.17" } }, - "node_modules/typescript-strict-plugin": { - "resolved": "", - "link": true - }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", diff --git a/package.json b/package.json index b5e49cf..04113d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tsc-strict", - "version": "2.4.4", + "version": "2.4.5", "description": "Typescript tools that help with migration to the strict mode", "author": "floklein", "contributors": [], @@ -10,11 +10,11 @@ "TypeScript Language Service" ], "bugs": { - "url": "https://github.com/floklein/typescript-strict-plugin/issues" + "url": "https://github.com/floklein/tsc-strict/issues" }, "repository": { "type": "git", - "url": "git+https://github.com/floklein/typescript-strict-plugin.git" + "url": "git+https://github.com/floklein/tsc-strict.git" }, "license": "MIT", "bin": { @@ -71,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": { @@ -85,5 +85,5 @@ "pre-commit": "lint-staged" } }, - "homepage": "https://github.com/floklein/typescript-strict-plugin#readme" + "homepage": "https://github.com/floklein/tsc-strict#readme" } diff --git a/sample-project/package-lock.json b/sample-project/package-lock.json index 9abe84d..dee614c 100644 --- a/sample-project/package-lock.json +++ b/sample-project/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@types/node": "^10.3.2", "typescript": "5.2.2", - "typescript-strict-plugin": "file:../../typescript-strict-plugin" + "tsc-strict": "file:../../tsc-strict" } }, "..": { @@ -8837,7 +8837,7 @@ "node": ">=14.17" } }, - "node_modules/typescript-strict-plugin": { + "node_modules/tsc-strict": { "resolved": "..", "link": true } @@ -8854,7 +8854,7 @@ "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true }, - "typescript-strict-plugin": { + "tsc-strict": { "version": "file:..", "requires": { "@babel/core": "7.9.0", diff --git a/sample-project/package.json b/sample-project/package.json index 2417439..c9141ed 100644 --- a/sample-project/package.json +++ b/sample-project/package.json @@ -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" } } diff --git a/sample-project/tsconfig.json b/sample-project/tsconfig.json index 308e3eb..ed41e9a 100644 --- a/sample-project/tsconfig.json +++ b/sample-project/tsconfig.json @@ -10,7 +10,7 @@ "noImplicitAny": true, "plugins": [ { - "name": "typescript-strict-plugin" + "name": "tsc-strict" } ] } diff --git a/src/cli/errorMessages.ts b/src/cli/errorMessages.ts index adddd19..6b96aa3 100644 --- a/src/cli/errorMessages.ts +++ b/src/cli/errorMessages.ts @@ -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" }] }, } diff --git a/src/cli/tsc-strict/__tests__/index.spec.ts b/src/cli/tsc-strict/__tests__/index.spec.ts index 129fbf0..a6f6793 100644 --- a/src/cli/tsc-strict/__tests__/index.spec.ts +++ b/src/cli/tsc-strict/__tests__/index.spec.ts @@ -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); }); diff --git a/src/cli/update-strict-comments/__tests__/index.spec.ts b/src/cli/update-strict-comments/__tests__/index.spec.ts index 3affa1c..a4b2aa4 100644 --- a/src/cli/update-strict-comments/__tests__/index.spec.ts +++ b/src/cli/update-strict-comments/__tests__/index.spec.ts @@ -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); }); diff --git a/src/common/__tests__/utils.spec.ts b/src/common/__tests__/utils.spec.ts index 713108d..3c1e464 100644 --- a/src/common/__tests__/utils.spec.ts +++ b/src/common/__tests__/utils.spec.ts @@ -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', ]; diff --git a/src/common/constants.ts b/src/common/constants.ts index 6e0d0fb..95ec113 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -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';