Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-strict-plugin

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-strict-plugin - npm Package Compare versions

Comparing version 2.3.2 to 2.4.0

dist/common/isFileExcludedByPattern.js

6

CHANGELOG.md

@@ -8,2 +8,8 @@ # Changelog

## [2.4.0] - 2024-03-07
### Added
- Add feature to exclude files from strict check based on `excludePattern` config property
## [2.2.0] - 2022-10-17

@@ -10,0 +16,0 @@

@@ -106,2 +106,13 @@ "use strict";

});
it('should return false when file is on path and matched by exclude pattern', () => {
// given
const config = {
paths: ['otherFilePath', filePath, 'otherFilePath'],
excludePattern: ['*'],
};
// when
const result = (0, isFileStrict_1.isFileStrict)({ filePath, isCommentPresent, config });
// then
expect(result).toBe(false);
});
it('should return true when path config is empty', () => {

@@ -108,0 +119,0 @@ // given

12

dist/common/isFileStrict.js

@@ -7,5 +7,6 @@ "use strict";

const isFileExcludedByPath_1 = require("./isFileExcludedByPath");
const isFileExcludedByPattern_1 = require("./isFileExcludedByPattern");
// Common logic determining whether file is strict or not
function isFileStrict({ filePath, config, projectPath, isCommentPresent, }) {
var _a, _b;
var _a, _b, _c;
if (isCommentPresent(constants_1.TS_STRICT_IGNORE_COMMENT, filePath)) {

@@ -18,2 +19,3 @@ return false;

const configExclude = (_a = config === null || config === void 0 ? void 0 : config.exclude) !== null && _a !== void 0 ? _a : [];
const configExcludePattern = (_b = config === null || config === void 0 ? void 0 : config.excludePattern) !== null && _b !== void 0 ? _b : [];
if ((0, isFileExcludedByPath_1.isFileExcludedByPath)({

@@ -23,6 +25,10 @@ filePath,

projectPath,
})) {
}) ||
(0, isFileExcludedByPattern_1.isFileExcludedByPattern)({
filePath,
configExcludePattern,
})) {
return false;
}
const configPaths = (_b = config === null || config === void 0 ? void 0 : config.paths) !== null && _b !== void 0 ? _b : [];
const configPaths = (_c = config === null || config === void 0 ? void 0 : config.paths) !== null && _c !== void 0 ? _c : [];
const fileStrictByPath = (0, isFileStrictByPath_1.isFileStrictByPath)({ filePath, configPaths, projectPath });

@@ -29,0 +35,0 @@ if (configPaths.length > 0 && !fileStrictByPath) {

{
"name": "typescript-strict-plugin",
"version": "2.3.2",
"version": "2.4.0",
"description": "Typescript tools that help with migration to the strict mode",

@@ -50,2 +50,3 @@ "author": "Allegro",

"execa": "^4.0.0",
"minimatch": "^9.0.3",
"ora": "^5.4.1",

@@ -68,3 +69,3 @@ "yargs": "^16.2.0"

"husky": "4.2.3",
"jest": "27.4.7",
"jest": "^29.7.0",
"lint-staged": "^10.5.4",

@@ -74,3 +75,3 @@ "prettier": "3.0.3",

"tmp-promise": "2.0.2",
"ts-jest": "27.1.2",
"ts-jest": "^29.1.2",
"ts-node": "10.4.0",

@@ -77,0 +78,0 @@ "typescript": "5.2.2",

@@ -63,5 +63,7 @@ # Typescript strict mode plugin

Plugin takes extra, non-mandatory arguments `paths` and `exclude`. Both of them take an array of
relative or absolute paths that should be included (property `paths`) or excluded (property
`exclude`). To add strict mode to files from ignored paths you can insert `//@ts-strict` comment.
Plugin takes extra, non-mandatory arguments `paths`, `exlude` and `excludePattern`. Args `paths` and
`exclude` accept an array of relative or absolute paths that should be included (property `paths`)
or excluded (property `exclude`). Arg `excludePattern` accepts an array of strings that will be
matched with [minimatch](https://github.com/isaacs/minimatch). To add strict mode to files from
ignored paths you can insert `//@ts-strict` comment.

@@ -83,2 +85,5 @@ ```json

"./src/fileToExclude.ts"
],
"excludePattern": [
"**/*.spec.ts"
]

@@ -85,0 +90,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc