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

@peerigon/typescript-exercises-tools

Package Overview
Dependencies
Maintainers
9
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peerigon/typescript-exercises-tools - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0-beta.1

dist/main.d.ts

6

dist/assertions.js

@@ -28,5 +28,5 @@ "use strict";

const actualDiagnostics = Array.from(typescript_1.default.getPreEmitDiagnostics(program, sourceFile));
const expectedDiagnostics = diagnostics_1.getExpectedDiagnostics(sourceFile);
const unexpectedDiagnostics = diagnostics_1.getUnexpectedDiagnostics(actualDiagnostics, expectedDiagnostics);
const missingExpectedDiagnostics = diagnostics_1.getMissingExpectedDiagnostics(actualDiagnostics, expectedDiagnostics);
const expectedDiagnostics = (0, diagnostics_1.getExpectedDiagnostics)(sourceFile);
const unexpectedDiagnostics = (0, diagnostics_1.getUnexpectedDiagnostics)(actualDiagnostics, expectedDiagnostics);
const missingExpectedDiagnostics = (0, diagnostics_1.getMissingExpectedDiagnostics)(actualDiagnostics, expectedDiagnostics);
if (unexpectedDiagnostics.length > 0) {

@@ -33,0 +33,0 @@ throw new Error(unexpectedDiagnostics[0].messageText.toString());

@@ -11,4 +11,5 @@ "use strict";

const sourceCode = sourceFile.getFullText();
const regex =
// eslint-disable-next-line no-unsafe-regex/no-unsafe-regex
const regex = /([\t ]*?\/\/ 💥? ?Expect error (\d+):? ?(.*?)[\n\r])(?:\n|\s|.*?\/\/ 💥? ?Expect error \d+.*?[\n\r])*([^\n\r]*)/g;
/([\t ]*?\/\/ 💥? ?Expect error (\d+):? ?(.*?)[\n\r])(?:\n|\s|.*?\/\/ 💥? ?Expect error \d+.*?[\n\r])*([^\n\r]*)/g;
let match = regex.exec(sourceCode);

@@ -30,4 +31,3 @@ const results = [];

const { code, message, nextLine, nextLineStart } = annotation;
const messageText = `Missing error ${code}` +
(message === "" ? "" : ` "${message}"`);
const messageText = `Missing error ${code}` + (message === "" ? "" : ` "${message}"`);
return {

@@ -58,3 +58,3 @@ file: sourceFile,

const endB = startB + lengthB;
return (startA >= startB && endA <= endB) || (startB >= startA && endB <= endA);
return ((startA >= startB && endA <= endB) || (startB >= startA && endB <= endA));
};

@@ -72,3 +72,3 @@ const matchesDiagnostic = (diagnosticA) => {

const getUnexpectedDiagnostics = (actualDiagnostics, expectedDiagnostics) => {
const unexpectedDiagnostics = actualDiagnostics.filter((actualDiagnostic) => expectedDiagnostics.some(exports.matchesDiagnostic(actualDiagnostic)) === false);
const unexpectedDiagnostics = actualDiagnostics.filter((actualDiagnostic) => expectedDiagnostics.some((0, exports.matchesDiagnostic)(actualDiagnostic)) === false);
return unexpectedDiagnostics;

@@ -78,3 +78,3 @@ };

const getMissingExpectedDiagnostics = (actualDiagnostics, expectedDiagnostics) => {
const missingExpectedDiagnostics = expectedDiagnostics.filter((expectedDiagnostic) => actualDiagnostics.some(exports.matchesDiagnostic(expectedDiagnostic)) === false);
const missingExpectedDiagnostics = expectedDiagnostics.filter((expectedDiagnostic) => actualDiagnostics.some((0, exports.matchesDiagnostic)(expectedDiagnostic)) === false);
return missingExpectedDiagnostics;

@@ -84,13 +84,15 @@ };

const lowerSeverityOfExpectedDiagnostics = (actualDiagnostics, expectedDiagnostics) => {
return expectedDiagnostics.map((expectedDiagnostic) => {
const actualDiagnostic = actualDiagnostics.find(exports.matchesDiagnostic(expectedDiagnostic));
return actualDiagnostic === undefined ?
null :
{
return expectedDiagnostics
.map((expectedDiagnostic) => {
const actualDiagnostic = actualDiagnostics.find((0, exports.matchesDiagnostic)(expectedDiagnostic));
return actualDiagnostic === undefined
? null
: {
...actualDiagnostic,
category: typescript_1.default.DiagnosticCategory.Suggestion,
};
}).filter((diagnostic) => diagnostic !== null);
})
.filter((diagnostic) => diagnostic !== null);
};
exports.lowerSeverityOfExpectedDiagnostics = lowerSeverityOfExpectedDiagnostics;
//# sourceMappingURL=diagnostics.js.map

@@ -9,6 +9,6 @@ "use strict";

const proxy = Object.create(null);
Object.entries(info.languageService)
.forEach(([k, x]) => {
Object.entries(info.languageService).forEach(([k, x]) => {
proxy[k] = (...args) =>
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
proxy[k] = (...args) => x.apply(info.languageService, args);
x.apply(info.languageService, args);
});

@@ -25,8 +25,8 @@ proxy.getSemanticDiagnostics = (...paths) => {

.filter((sourceFile) => sourceFile !== undefined)
.map((sourceFile) => diagnostics_1.getExpectedDiagnostics(sourceFile));
.map((sourceFile) => (0, diagnostics_1.getExpectedDiagnostics)(sourceFile));
// We need to do this separately because of a strange ESLint bug with .flat()
const expectedDiagnosticsFlat = expectedDiagnostics.flat();
const unexpectedDiagnostics = diagnostics_1.getUnexpectedDiagnostics(actualDiagnostics, expectedDiagnosticsFlat);
const missingExpectedDiagnostics = diagnostics_1.getMissingExpectedDiagnostics(actualDiagnostics, expectedDiagnosticsFlat);
const completeDiagnostics = unexpectedDiagnostics.concat(missingExpectedDiagnostics, diagnostics_1.lowerSeverityOfExpectedDiagnostics(actualDiagnostics, expectedDiagnosticsFlat));
const unexpectedDiagnostics = (0, diagnostics_1.getUnexpectedDiagnostics)(actualDiagnostics, expectedDiagnosticsFlat);
const missingExpectedDiagnostics = (0, diagnostics_1.getMissingExpectedDiagnostics)(actualDiagnostics, expectedDiagnosticsFlat);
const completeDiagnostics = unexpectedDiagnostics.concat(missingExpectedDiagnostics, (0, diagnostics_1.lowerSeverityOfExpectedDiagnostics)(actualDiagnostics, expectedDiagnosticsFlat));
return completeDiagnostics;

@@ -33,0 +33,0 @@ };

export { assertProgramToOnlyHaveExpectedErrors } from "./assertions";
export { getExpectedDiagnostics, getMissingExpectedDiagnostics, getUnexpectedDiagnostics } from "./diagnostics";
export { getExpectedDiagnostics, getMissingExpectedDiagnostics, getUnexpectedDiagnostics, } from "./diagnostics";
"use strict";
// This module is necessary because linting got really slow once we imported
// the typescript module directly. That's why we also have to disable eslint here.
/* eslint-disable */
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,0 +5,0 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

{
"name": "@peerigon/typescript-exercises-tools",
"version": "1.1.1",
"version": "1.2.0-beta.1",
"description": "Tools for writing and validating TypeScript exercises",

@@ -8,3 +8,7 @@ "repository": "https://github.com/peerigon/typescript-exercises-tools",

"license": "Unlicense",
"main": "plugin.js",
"main": "./dist/main.js",
"exports": {
".": "./dist/main.js",
"./tests": "./dist/tests.js"
},
"keywords": [

@@ -22,7 +26,3 @@ "typescript",

"files": [
"dist",
"plugin.js",
"plugin.d.ts",
"tests.js",
"tests.d.ts"
"dist"
],

@@ -34,32 +34,48 @@ "scripts": {

"build:tsc:watch": "npm run build:tsc -- -w",
"test": "run-s test:unit test:lint",
"test:unit": "jest",
"test:lint": "eslint --ext ts --ignore-path ./.eslintignore src",
"prepublishOnly": "run-p build"
"test": "run-p test:suite test:lint",
"test:suite": "jest",
"test:lint": "eslint --max-warnings 0 --cache --ext js,jsx,cjs,mjs,ts,tsx --ignore-path .gitignore .",
"prepublishOnly": "run-p build",
"release": "semantic-release",
"prepare": "husky install"
},
"peerDependencies": {
"typescript": "^4.2.4"
"typescript": "^4.5.5"
},
"devDependencies": {
"@peerigon/typescript-exercises-tools": "file:/.",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.41",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"eslint-config-peerigon": "^30.0.2",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^26.6.3",
"nodemon": "^2.0.7",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.13",
"@typescript-eslint/eslint-plugin": "^5.10.1",
"@typescript-eslint/parser": "^5.10.1",
"eslint": "^8.7.0",
"eslint-config-peerigon": "^33.2.4",
"husky": "^7.0.4",
"jest": "^27.4.7",
"lint-staged": "^12.3.2",
"nodemon": "^2.0.15",
"npm-run-all": "^4.1.5",
"prettier": "^2.2.1",
"pin-github-action": "^1.5.0",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"standard-version": "^9.2.0",
"ts-jest": "^26.5.5",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"semantic-release": "^19.0.2",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"typescript": "^4.5.5"
},
"lint-staged": {
"*.js": [
"prettier --write",
"eslint --cache --fix"
],
"*.{css,md}": [
"prettier --write"
],
".github/workflows/*.{yml,yaml}": [
"pin-github-action --allow-empty",
"prettier --write"
]
}
}

@@ -1,3 +0,3 @@

@peerigon/typescript-exercises-tools
=============================
# @peerigon/typescript-exercises-tools
**Tools for writing and validating TypeScript exercises.**

@@ -16,3 +16,3 @@

export const add = (a: number, b: string) => {
return a + b;
return a + b;
};

@@ -29,3 +29,3 @@

Furthermore, these comments will cause the editor to show an error if there is *no type error* at this location:
Furthermore, these comments will cause the editor to show an error if there is _no type error_ at this location:

@@ -37,6 +37,6 @@ ![Screenshot of an editor that shows an error when there is no type error](./docs/editor-screenshot-3.jpg)

```ts
import {assertProgramToOnlyHaveExpectedErrors} from "@peerigon/typescript-exercises-tools/tests";
import { assertProgramToOnlyHaveExpectedErrors } from "@peerigon/typescript-exercises-tools/tests";
test("The program has only expected errors", () => {
assertProgramToOnlyHaveExpectedErrors("/path/to/module.ts");
assertProgramToOnlyHaveExpectedErrors("/path/to/module.ts");
});

@@ -60,7 +60,9 @@ ```

{
"compilerOptions": {
"plugins": [{
"name": "@peerigon/typescript-exercises-tools"
}]
}
"compilerOptions": {
"plugins": [
{
"name": "@peerigon/typescript-exercises-tools"
}
]
}
}

@@ -73,3 +75,3 @@ ```

{
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib"
}

@@ -79,2 +81,3 @@ ```

## Support for multiple errors
If you expect more than one error, you can add multiple comments, like this:

@@ -84,7 +87,7 @@

type Person = {
readonly name: string;
readonly name: string;
};
const person: Person = {
name: "Bob",
name: "Bob",
};

@@ -104,3 +107,3 @@

```ts
import {assertProgramToOnlyHaveExpectedErrors} from "@peerigon/typescript-exercises-tools/tests";
import { assertProgramToOnlyHaveExpectedErrors } from "@peerigon/typescript-exercises-tools/tests";

@@ -110,8 +113,7 @@ assertProgramToOnlyHaveExpectedErrors("/path/to/module.ts"); // may throw

assertProgramToOnlyHaveExpectedErrors(
"/path/to/module.ts",
{strict: true} // custom compiler options
"/path/to/module.ts",
{ strict: true } // custom compiler options
);
```
## License

@@ -121,5 +123,4 @@

## Sponsors
[<img src="https://assets.peerigon.com/peerigon/logo/peerigon-logo-flat-spinat.png" width="150" />](https://peerigon.com)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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