New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript-strictly-typed

Package Overview
Dependencies
Maintainers
0
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 3.19.3 to 3.20.0

5

config-utils.js

@@ -53,2 +53,3 @@ import { dump, load } from "js-yaml";

raw,
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
json: parse(raw),

@@ -60,2 +61,3 @@ };

case ".yml": {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const json = load(raw);

@@ -70,2 +72,3 @@ config = {

case ".cjs": {
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const moduleImport = await import(filePath);

@@ -149,2 +152,3 @@ const json = moduleImport.default;

const packageJsonFile = readFileSync(filePath, { encoding: "utf8" });
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const packageJsonConfig = parse(packageJsonFile);

@@ -170,2 +174,3 @@ const prodDependencyVersion = packageJsonConfig?.dependencies?.[name];

const packageJsonFile = readFileSync(filePath, { encoding: "utf8" });
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
const packageJsonConfig = parse(packageJsonFile);

@@ -172,0 +177,0 @@ if (packageJsonConfig?.dependencies && (name in packageJsonConfig.dependencies)) {

63

eslint-flat-strict.js

@@ -6,31 +6,34 @@ import { writeFileSync } from "node:fs";

import { logWarning } from "./log-utils.js";
const eslintRules = {
"eqeqeq": `"error"`,
"prefer-arrow-callback": `"error"`,
"prefer-template": `"error"`,
"@typescript-eslint/explicit-function-return-type": `"error"`,
"@typescript-eslint/no-explicit-any": `"error"`,
"@typescript-eslint/no-non-null-assertion": `"error"`,
"@typescript-eslint/no-unsafe-argument": `"error"`,
"@typescript-eslint/no-unsafe-assignment": `"error"`,
"@typescript-eslint/no-unsafe-call": `"error"`,
"@typescript-eslint/no-unsafe-member-access": `"error"`,
"@typescript-eslint/no-unsafe-return": `"error"`,
"@typescript-eslint/prefer-for-of": `"error"`,
"@typescript-eslint/prefer-nullish-coalescing": `"error"`,
"@typescript-eslint/prefer-optional-chain": `"error"`,
"@typescript-eslint/restrict-plus-operands": `["error", {
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumberAndString: false,
allowRegExp: false,
}]`,
"@typescript-eslint/restrict-template-expressions": `"error"`,
"@typescript-eslint/strict-boolean-expressions": `["error", {
allowNumber: false,
allowString: false,
}]`,
"@typescript-eslint/use-unknown-in-catch-callback-variable": `"error"`,
};
function getEslintRules(cwd) {
return {
"eqeqeq": `"error"`,
"prefer-arrow-callback": `"error"`,
"prefer-template": `"error"`,
"@typescript-eslint/explicit-function-return-type": `"error"`,
"@typescript-eslint/no-explicit-any": `"error"`,
"@typescript-eslint/no-non-null-assertion": `"error"`,
"@typescript-eslint/no-unsafe-argument": `"error"`,
"@typescript-eslint/no-unsafe-assignment": `"error"`,
"@typescript-eslint/no-unsafe-call": `"error"`,
"@typescript-eslint/no-unsafe-member-access": `"error"`,
"@typescript-eslint/no-unsafe-return": `"error"`,
...(checkDependencyVersion(cwd, "@typescript-eslint/eslint-plugin", ">=8.15.0") ? { "@typescript-eslint/no-unsafe-type-assertion": `"error"` } : {}),
"@typescript-eslint/prefer-for-of": `"error"`,
"@typescript-eslint/prefer-nullish-coalescing": `"error"`,
"@typescript-eslint/prefer-optional-chain": `"error"`,
"@typescript-eslint/restrict-plus-operands": `["error", {
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumberAndString: false,
allowRegExp: false,
}]`,
"@typescript-eslint/restrict-template-expressions": `"error"`,
"@typescript-eslint/strict-boolean-expressions": `["error", {
allowNumber: false,
allowString: false,
}]`,
"@typescript-eslint/use-unknown-in-catch-callback-variable": `"error"`,
};
}
export function enableESLintFlatStrict(cwd) {

@@ -139,3 +142,3 @@ const fileName = findConfig(cwd, ["eslint.config.mjs", "eslint.config.js"]);

}
for (const [ruleName, ruleErrorConfig] of Object.entries(eslintRules)) {
for (const [ruleName, ruleErrorConfig] of Object.entries(getEslintRules(cwd))) {
const ruleProperty = getProperty(rulesObject, ruleName);

@@ -142,0 +145,0 @@ if (ruleProperty) {

@@ -1,2 +0,2 @@

import { dependencyExists, findConfig, getConfig, getSource, isAngularESLint, modifyJSON, saveConfig } from "./config-utils.js";
import { checkDependencyVersion, dependencyExists, findConfig, getConfig, getSource, isAngularESLint, modifyJSON, saveConfig } from "./config-utils.js";
import { enableESLintFlatStrict } from "./eslint-flat-strict.js";

@@ -58,3 +58,3 @@ import { logInfo, logWarning } from "./log-utils.js";

}
addTSConfig(config, ["overrides", indexNumber], config.json.overrides?.[indexNumber]?.rules);
addTSConfig(cwd, config, ["overrides", indexNumber], config.json.overrides?.[indexNumber]?.rules);
tsConfigAdded = true;

@@ -71,3 +71,3 @@ }

}
addTSConfig(config, [], config.json.rules);
addTSConfig(cwd, config, [], config.json.rules);
}

@@ -95,3 +95,3 @@ if (!dependencyExists(cwd, "@typescript-eslint/eslint-plugin") && !dependencyExists(cwd, "typescript-eslint")) {

}
function addTSConfig(config, path, rules) {
function addTSConfig(cwd, config, path, rules) {
config.raw = modifyJSON(config.raw, [...path, "rules", "eqeqeq"], "error");

@@ -116,2 +116,5 @@ config.raw = modifyJSON(config.raw, [...path, "rules", "prefer-arrow-callback"], "error");

config.raw = modifyJSON(config.raw, [...path, "rules", "@typescript-eslint/no-unsafe-return"], "error");
if (checkDependencyVersion(cwd, "@typescript-eslint/eslint-plugin", ">=8.15.0")) {
config.raw = modifyJSON(config.raw, [...path, "rules", "@typescript-eslint/no-unsafe-type-assertion"], "error");
}
config.raw = modifyJSON(config.raw, [...path, "rules", "@typescript-eslint/prefer-for-of"], "error");

@@ -118,0 +121,0 @@ config.raw = modifyJSON(config.raw, [...path, "rules", "@typescript-eslint/prefer-nullish-coalescing"], "error");

{
"name": "typescript-strictly-typed",
"version": "3.19.3",
"version": "3.20.0",
"description": "Enable configurations for strictly typed TypeScript, ESLint, and optionally Angular.",

@@ -40,19 +40,19 @@ "funding": {

"js-yaml": "^4.1.0",
"jsonc-parser": "^3.2.1",
"jsonc-parser": "^3.3.1",
"package-up": "^5.0.0",
"semver": "^7.6.2",
"ts-morph": "^22.0.0"
"semver": "^7.6.3",
"ts-morph": "^24.0.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.2",
"@biomejs/biome": "^1.9.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^18.19.38",
"@types/node": "~22.9.0",
"@types/semver": "^7.5.8",
"better-typescript-lib": "^2.7.0",
"better-typescript-lib": "^2.9.0",
"copyfiles": "^2.4.1",
"eslint": "^9.5.0",
"rimraf": "^5.0.7",
"typescript": "~5.4.5",
"typescript-eslint": "^8.0.0-alpha.24"
"eslint": "^9.15.0",
"rimraf": "^6.0.1",
"typescript": "~5.6.2",
"typescript-eslint": "^8.15.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