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

typescript-strictly-typed

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-strictly-typed - npm Package Compare versions

Comparing version 2.10.0 to 2.11.0

20

angular-strict.js

@@ -17,14 +17,14 @@ "use strict";

enableCodelyzerStrict(cwd);
const file = config_utils_1.findConfig(cwd, ['tsconfig.base.json', 'tsconfig.json']);
const file = (0, config_utils_1.findConfig)(cwd, ['tsconfig.base.json', 'tsconfig.json']);
if (!file) {
return false;
}
const config = config_utils_1.getConfig(cwd, file);
const config = (0, config_utils_1.getConfig)(cwd, file);
if (!config) {
return false;
}
config.raw = config_utils_1.modifyJSON(config.raw, ['angularCompilerOptions', 'strictInjectionParameters'], true);
config.raw = config_utils_1.modifyJSON(config.raw, ['angularCompilerOptions', 'strictTemplates'], true);
config.raw = config_utils_1.modifyJSON(config.raw, ['angularCompilerOptions', 'strictInputAccessModifiers'], true);
return config_utils_1.saveConfig(cwd, file, config);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['angularCompilerOptions', 'strictInjectionParameters'], true);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['angularCompilerOptions', 'strictTemplates'], true);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['angularCompilerOptions', 'strictInputAccessModifiers'], true);
return (0, config_utils_1.saveConfig)(cwd, file, config);
}

@@ -38,8 +38,8 @@ exports.default = enableAngularStrict;

function enableCodelyzerStrict(cwd) {
const file = config_utils_1.findConfig(cwd, ['tslint.json', 'tslint.yaml', 'tslint.yml']);
const file = (0, config_utils_1.findConfig)(cwd, ['tslint.json', 'tslint.yaml', 'tslint.yml']);
if (file) {
const config = config_utils_1.getConfig(cwd, file);
const config = (0, config_utils_1.getConfig)(cwd, file);
if (config && isCodelyzer(config.json.rulesDirectory)) {
config.raw = config_utils_1.modifyJSON(config.raw, ['rules', 'template-no-any'], true);
config_utils_1.saveConfig(cwd, file, config);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['rules', 'template-no-any'], true);
(0, config_utils_1.saveConfig)(cwd, file, config);
}

@@ -46,0 +46,0 @@ }

@@ -7,2 +7,2 @@ "use strict";

const cwd = process.cwd();
index_1.default(cwd);
(0, index_1.default)(cwd);

@@ -27,3 +27,3 @@ "use strict";

if (files[0]) {
log_utils_1.logInfo(`Can't find ${path.basename(files[0], '.json')} config file. Skipping this configuration.`);
(0, log_utils_1.logInfo)(`Can't find ${path.basename(files[0], '.json')} config file. Skipping this configuration.`);
}

@@ -51,3 +51,3 @@ return null;

raw,
json: jsonc_parser_1.parse(raw),
json: (0, jsonc_parser_1.parse)(raw),
};

@@ -76,3 +76,3 @@ break;

catch (_a) {
log_utils_1.logError(`Can't parse ${file}. Check the file syntax is valid.`);
(0, log_utils_1.logError)(`Can't parse ${file}. Check the file syntax is valid.`);
}

@@ -107,7 +107,7 @@ return config;

catch (_a) {
log_utils_1.logError(`Can't save ${file} config.`);
(0, log_utils_1.logError)(`Can't save ${file} config.`);
return false;
}
if (!configStringified) {
log_utils_1.logError(`Can't save ${file} config.`);
(0, log_utils_1.logError)(`Can't save ${file} config.`);
return false;

@@ -120,3 +120,3 @@ }

catch (_b) {
log_utils_1.logError(`Can't write ${file} file. Maybe a permission issue?`);
(0, log_utils_1.logError)(`Can't write ${file} file. Maybe a permission issue?`);
return false;

@@ -134,3 +134,3 @@ }

};
return jsonc_parser_1.applyEdits(json, jsonc_parser_1.modify(json.toString(), path, value, options !== null && options !== void 0 ? options : {}));
return (0, jsonc_parser_1.applyEdits)(json, (0, jsonc_parser_1.modify)(json.toString(), path, value, options !== null && options !== void 0 ? options : {}));
}

@@ -147,6 +147,6 @@ exports.modifyJSON = modifyJSON;

var _a, _b;
const filePath = pkg_up_1.sync({ cwd });
const filePath = (0, pkg_up_1.sync)({ cwd });
if (filePath) {
const packageJsonFile = fs.readFileSync(filePath, { encoding: 'utf8' });
const packageJsonConfig = jsonc_parser_1.parse(packageJsonFile);
const packageJsonConfig = (0, jsonc_parser_1.parse)(packageJsonFile);
const prodDependencyVersion = (_a = packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig.dependencies) === null || _a === void 0 ? void 0 : _a[name];

@@ -153,0 +153,0 @@ const devDependencyVersion = (_b = packageJsonConfig === null || packageJsonConfig === void 0 ? void 0 : packageJsonConfig.devDependencies) === null || _b === void 0 ? void 0 : _b[name];

@@ -23,3 +23,3 @@ "use strict";

let packageJSONConfig = null;
const file = config_utils_1.findConfig(cwd, possibleConfigFiles);
const file = (0, config_utils_1.findConfig)(cwd, possibleConfigFiles);
if (!file) {

@@ -29,3 +29,3 @@ return false;

if (file === 'package.json') {
packageJSONConfig = config_utils_1.getConfig(cwd, file);
packageJSONConfig = (0, config_utils_1.getConfig)(cwd, file);
if (!packageJSONConfig || !packageJSONConfig.json.eslintConfig) {

@@ -40,3 +40,3 @@ return false;

else {
config = config_utils_1.getConfig(cwd, file);
config = (0, config_utils_1.getConfig)(cwd, file);
}

@@ -68,11 +68,11 @@ if (!config) {

if (packageJSONConfig) {
config.raw = config_utils_1.modifyJSON(packageJSONConfig.raw, ['eslintConfig'], config.json);
return config_utils_1.saveConfig(cwd, file, packageJSONConfig);
config.raw = (0, config_utils_1.modifyJSON)(packageJSONConfig.raw, ['eslintConfig'], config.json);
return (0, config_utils_1.saveConfig)(cwd, file, packageJSONConfig);
}
else if (file === '.eslintrc.js') {
log_utils_1.logWarning(`Your project is using the advanced .eslintrc.js format for ESLint config, and it can't be overwrited directly, as it could mess up with advanced configuration. So the new strict configuration was saved in .eslintrc.json. As .eslintrc.js has precedence over .eslintrc.json, you need to manually copy the new options from the new .eslintrc.json to your preexisting .eslintrc.js. If you know a way to automate this, please open a PR.`);
return config_utils_1.saveConfig(cwd, '.eslintrc.json', config);
(0, log_utils_1.logWarning)(`Your project is using the advanced .eslintrc.js format for ESLint config, and it can't be overwrited directly, as it could mess up with advanced configuration. So the new strict configuration was saved in .eslintrc.json. As .eslintrc.js has precedence over .eslintrc.json, you need to manually copy the new options from the new .eslintrc.json to your preexisting .eslintrc.js. If you know a way to automate this, please open a PR.`);
return (0, config_utils_1.saveConfig)(cwd, '.eslintrc.json', config);
}
else {
return config_utils_1.saveConfig(cwd, file, config);
return (0, config_utils_1.saveConfig)(cwd, file, config);
}

@@ -110,16 +110,16 @@ }

}
log_utils_1.logWarning(`ESLint must be configured with "${eslintTypeScriptPlugin}" plugin or with a tool extending it like "${eslintVuePlugin}", "${eslintReactPlugin}" or "${eslintAngularPlugin}", otherwise rules won't be checked.`);
(0, log_utils_1.logWarning)(`ESLint must be configured with "${eslintTypeScriptPlugin}" plugin or with a tool extending it like "${eslintVuePlugin}", "${eslintReactPlugin}" or "${eslintAngularPlugin}", otherwise rules won't be checked.`);
}
function addTSConfig(config, path, rules) {
if (Array.isArray(rules === null || rules === void 0 ? void 0 : rules['@typescript-eslint/no-explicit-any'])) {
config.raw = config_utils_1.modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any', 0], 'error');
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any', 0], 'error');
}
else {
config.raw = config_utils_1.modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any'], 'error');
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/no-explicit-any'], 'error');
}
if (Array.isArray(rules === null || rules === void 0 ? void 0 : rules['@typescript-eslint/explicit-module-boundary-types'])) {
config.raw = config_utils_1.modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types', 0], 'error');
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types', 0], 'error');
}
else {
config.raw = config_utils_1.modifyJSON(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types'], 'error');
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@typescript-eslint/explicit-module-boundary-types'], 'error');
}

@@ -129,6 +129,6 @@ }

if (Array.isArray(rules === null || rules === void 0 ? void 0 : rules['@angular-eslint/template/no-any'])) {
config.raw = config_utils_1.modifyJSON(config.raw, [...path, 'rules', '@angular-eslint/template/no-any', 0], 'error');
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@angular-eslint/template/no-any', 0], 'error');
}
else {
config.raw = config_utils_1.modifyJSON(config.raw, [...path, 'rules', '@angular-eslint/template/no-any'], 'error');
config.raw = (0, config_utils_1.modifyJSON)(config.raw, [...path, 'rules', '@angular-eslint/template/no-any'], 'error');
}

@@ -135,0 +135,0 @@ }

@@ -19,22 +19,22 @@ "use strict";

const success = [];
if (typescript_strict_1.default(cwd)) {
if ((0, typescript_strict_1.default)(cwd)) {
success.push('TypeScript');
}
if (eslint_strict_1.default(cwd)) {
if ((0, eslint_strict_1.default)(cwd)) {
success.push('ESLint');
}
if (tslint_strict_1.default(cwd)) {
if ((0, tslint_strict_1.default)(cwd)) {
success.push('TSLint');
}
if (config_utils_1.findConfig(cwd, ['angular.json', '.angular.json', 'angular-cli.json', '.angular-cli.json'])
&& angular_strict_1.default(cwd)) {
if ((0, config_utils_1.findConfig)(cwd, ['angular.json', '.angular.json', 'angular-cli.json', '.angular-cli.json'])
&& (0, angular_strict_1.default)(cwd)) {
success.push('Angular');
}
if (success.length === 0) {
log_utils_1.logError(`Configuration failed. Please fix the issues and run the command again.\n`);
(0, log_utils_1.logError)(`Configuration failed. Please fix the issues and run the command again.\n`);
}
else {
log_utils_1.logSuccess(`Configuration finished. It succeeded for: ${success.join(', ')}.\n`);
(0, log_utils_1.logSuccess)(`Configuration finished. It succeeded for: ${success.join(', ')}.\n`);
}
}
exports.default = typescriptStrictlyTyped;
{
"name": "typescript-strictly-typed",
"version": "2.10.0",
"version": "2.11.0",
"description": "Enable configurations for strictly typed TypeScript, ESLint or TSLint, and optionally Angular.",

@@ -60,9 +60,9 @@ "funding": {

"@types/semver": "7.3.8",
"@typescript-eslint/eslint-plugin": "4.29.2",
"@typescript-eslint/parser": "4.29.2",
"@typescript-eslint/eslint-plugin": "4.29.3",
"@typescript-eslint/parser": "4.29.3",
"copyfiles": "2.4.1",
"eslint": "7.32.0",
"rimraf": "3.0.2",
"typescript": "4.3.5"
"typescript": "4.4.2"
}
}

@@ -19,6 +19,9 @@ # TypeScript Strictly Typed

(TypeScript, ESLint or Angular) to add newly introduced strict options,
to stay up to date on best practices.
to stay up to date with best practices.
## Getting started
Check the Git (or equivalent) status is clean, to be able to revert easily if needed,
then just run the following commands in your terminal:
```bash

@@ -51,2 +54,3 @@ cd path/to/my-project

- `noImplicitOverride`
- `exactOptionalPropertyTypes`
- [ESLint rules](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin)

@@ -53,0 +57,0 @@ - `@typescript-eslint/no-explicit-any`

@@ -17,11 +17,11 @@ "use strict";

var _a;
const file = config_utils_1.findConfig(cwd, ['tslint.json', 'tslint.yaml', 'tslint.yml']);
const file = (0, config_utils_1.findConfig)(cwd, ['tslint.json', 'tslint.yaml', 'tslint.yml']);
if (!file) {
return false;
}
const config = config_utils_1.getConfig(cwd, file);
const config = (0, config_utils_1.getConfig)(cwd, file);
if (!config) {
return false;
}
config.raw = config_utils_1.modifyJSON(config.raw, ['rules', 'no-any'], true);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['rules', 'no-any'], true);
/* `typedef` has multiple options, existing ones must not be deleted */

@@ -31,10 +31,10 @@ const rules = (_a = config.json.rules) !== null && _a !== void 0 ? _a : {};

if (!rules.typedef.includes('call-signature')) {
config.raw = config_utils_1.modifyJSON(config.raw, ['rules', 'typedef'], 'call-signature', { isArrayInsertion: true });
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['rules', 'typedef'], 'call-signature', { isArrayInsertion: true });
}
}
else {
config.raw = config_utils_1.modifyJSON(config.raw, ['rules', 'typedef'], [true, 'call-signature']);
config.raw = (0, config_utils_1.modifyJSON)(config.raw, ['rules', 'typedef'], [true, 'call-signature']);
}
return config_utils_1.saveConfig(cwd, file, config);
return (0, config_utils_1.saveConfig)(cwd, file, config);
}
exports.default = enableTSLintStrict;

@@ -12,2 +12,3 @@ "use strict";

* - `noImplicitOverride`
* - `exactOptionalPropertyTypes`
* {@link https://www.typescriptlang.org/docs/handbook/compiler-options.html}

@@ -20,14 +21,14 @@ *

function enableTypescriptStrict(cwd) {
const file = config_utils_1.findConfig(cwd, ['tsconfig.base.json', 'tsconfig.json']);
const file = (0, config_utils_1.findConfig)(cwd, ['tsconfig.base.json', 'tsconfig.json']);
if (!file) {
return false;
}
const config = config_utils_1.getConfig(cwd, file);
const config = (0, config_utils_1.getConfig)(cwd, file);
if (!config) {
return false;
}
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'strict'], true);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'noFallthroughCasesInSwitch'], true);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'noImplicitReturns'], true);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'forceConsistentCasingInFileNames'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strict'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noFallthroughCasesInSwitch'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitReturns'], true);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'forceConsistentCasingInFileNames'], true);
/*

@@ -38,18 +39,22 @@ if (checkDependencyVersion(cwd, 'typescript', '>=4.1.0')) {

*/
if (config_utils_1.checkDependencyVersion(cwd, 'typescript', '>=4.2.0')) {
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'noPropertyAccessFromIndexSignature'], true);
if ((0, config_utils_1.checkDependencyVersion)(cwd, 'typescript', '>=4.2.0')) {
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noPropertyAccessFromIndexSignature'], true);
}
if (config_utils_1.checkDependencyVersion(cwd, 'typescript', '>=4.3.0')) {
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'noImplicitOverride'], true);
if ((0, config_utils_1.checkDependencyVersion)(cwd, 'typescript', '>=4.3.0')) {
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitOverride'], true);
}
if ((0, config_utils_1.checkDependencyVersion)(cwd, 'typescript', '>=4.4.0')) {
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'exactOptionalPropertyTypes'], true);
}
/* Clean up options included in strict mode */
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'alwaysStrict'], undefined);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'noImplicitAny'], undefined);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'noImplicitThis'], undefined);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'strictBindCallApply'], undefined);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'strictFunctionTypes'], undefined);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'strictNullChecks'], undefined);
config.raw = config_utils_2.modifyJSON(config.raw, ['compilerOptions', 'strictPropertyInitialization'], undefined);
return config_utils_1.saveConfig(cwd, file, config);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'alwaysStrict'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitAny'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'noImplicitThis'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictBindCallApply'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictFunctionTypes'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictNullChecks'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'strictPropertyInitialization'], undefined);
config.raw = (0, config_utils_2.modifyJSON)(config.raw, ['compilerOptions', 'useUnknownInCatchVariables'], undefined);
return (0, config_utils_1.saveConfig)(cwd, file, config);
}
exports.default = enableTypescriptStrict;
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