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/" 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 a168dc7..fa0aff0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "typescript-strict-plugin", - "version": "2.4.3", + "name": "tsc-strict", + "version": "2.4.4", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "typescript-strict-plugin", - "version": "2.4.3", + "name": "tsc-strict", + "version": "2.4.4", "license": "MIT", "dependencies": { "chalk": "^3.0.0", @@ -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 35b77a1..04113d1 100644 --- a/package.json +++ b/package.json @@ -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 ", - "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/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" } 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'; 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) ); }