Skip to content

Commit f3e8232

Browse files
committed
Update development toolchain
1 parent 5a26830 commit f3e8232

18 files changed

+480
-257
lines changed

.eslintrc.json

-64
This file was deleted.

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/nodejs.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Node.js Automation
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- uses: actions/setup-node@v4
13+
with:
14+
node-version: lts/*
15+
- run: npm install
16+
- run: npm test
17+
- run: npm run lint
18+
- run: npm run type-check

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
dist
21
node_modules
32
package-lock.json

.npmignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
.eslintrc.json
2-
**/*.spec.ts
3-
lib/gherkin.ts
1+
.github/
2+
eslint.config.js
3+
**/*.test.js
4+
lib/gherkin.js
45
tsconfig.json

eslint.config.js

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import tseslint from "typescript-eslint";
2+
import stylistic from "@stylistic/eslint-plugin";
3+
// @ts-expect-error No types available
4+
import importPlugin from "eslint-plugin-import";
5+
6+
7+
export default tseslint.config(
8+
...tseslint.configs.recommendedTypeChecked,
9+
...tseslint.configs.stylisticTypeChecked,
10+
importPlugin.flatConfigs.recommended, // eslint-disable-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
11+
importPlugin.flatConfigs.typescript, // eslint-disable-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
12+
stylistic.configs.customize({
13+
arrowParens: true,
14+
braceStyle: "1tbs",
15+
commaDangle: "never",
16+
jsx: false,
17+
quotes: "double",
18+
semi: true
19+
}),
20+
{
21+
languageOptions: {
22+
parserOptions: {
23+
projectService: true,
24+
tsconfigRootDir: import.meta.dirname
25+
}
26+
},
27+
settings: {
28+
"import/resolver": {
29+
typescript: {}
30+
}
31+
},
32+
rules: {
33+
// TypeScript
34+
"@typescript-eslint/no-unused-vars": ["error", {
35+
argsIgnorePattern: "^_",
36+
varsIgnorePattern: "^_",
37+
caughtErrorsIgnorePattern: "^_"
38+
}],
39+
"@typescript-eslint/no-empty-function": "off",
40+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
41+
"no-console": "error",
42+
43+
// Imports
44+
"import/extensions": ["error", "ignorePackages"],
45+
// "import/newline-after-import": ["error", {
46+
// count: 2,
47+
// exactCount: false,
48+
// considerComments: true
49+
// }], // Doesn't respect @import
50+
51+
// Stylistic
52+
"@stylistic/yield-star-spacing": ["error", "after"],
53+
"@stylistic/multiline-ternary": "off",
54+
"@stylistic/no-mixed-operators": "off",
55+
"@stylistic/no-multiple-empty-lines": ["error", { max: 2, maxEOF: 0, maxBOF: 0 }], // Allow max=2 for imports
56+
"@stylistic/quote-props": ["error", "as-needed"]
57+
}
58+
}
59+
);
File renamed without changes.

lib/assign.spec.ts renamed to lib/assign.test.js

+20-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { beforeEach, describe, expect } from "vitest";
22
import { Given, When, Then } from "./gherkin.js";
33
import * as JsonPointer from "./index.js";
4-
import type { Json, JsonObject, Pointable } from "./index.js";
4+
5+
/**
6+
* @import { Json, JsonObject } from "./index.js"
7+
*/
58

69

710
describe("JsonPointer.assign", () => {
@@ -13,7 +16,7 @@ describe("JsonPointer.assign", () => {
1316
JsonPointer.assign(pointer, subject, "foo");
1417

1518
Then("the value is not changed", () => {
16-
expect(subject).to.eql({ "foo": "bar" });
19+
expect(subject).to.eql({ foo: "bar" });
1720
});
1821
});
1922
});
@@ -22,7 +25,7 @@ describe("JsonPointer.assign", () => {
2225
const pointer = "/aaa";
2326

2427
When("mutating a property", () => {
25-
const subject = { "aaa": 111, "bbb": [] };
28+
const subject = { aaa: 111, bbb: [] };
2629
JsonPointer.assign(pointer, subject, "foo");
2730

2831
Then("the new value should be set", () => {
@@ -48,7 +51,7 @@ describe("JsonPointer.assign", () => {
4851
const pointer = "/aaa/ccc";
4952

5053
When("mutating a property", () => {
51-
const subject = { "aaa": { "ccc": 333, "ddd": 444 }, "bbb": 222 };
54+
const subject = { aaa: { ccc: 333, ddd: 444 }, bbb: 222 };
5255
JsonPointer.assign(pointer, subject, "foo");
5356

5457
Then("the new value should be set", () => {
@@ -58,7 +61,8 @@ describe("JsonPointer.assign", () => {
5861
});
5962

6063
Given("an object", () => {
61-
let subject: JsonObject;
64+
/** @type JsonObject */
65+
let subject;
6266

6367
beforeEach(() => {
6468
subject = { aaa: { bbb: {} } };
@@ -84,7 +88,8 @@ describe("JsonPointer.assign", () => {
8488
});
8589

8690
Given("an array", () => {
87-
let subject: Json[];
91+
/** @type Json[] */
92+
let subject;
8893

8994
beforeEach(() => {
9095
subject = [];
@@ -112,7 +117,8 @@ describe("JsonPointer.assign", () => {
112117
});
113118

114119
Given("a number", () => {
115-
let subject: unknown;
120+
/** @type number */
121+
let subject;
116122

117123
beforeEach(() => {
118124
subject = 42;
@@ -122,13 +128,14 @@ describe("JsonPointer.assign", () => {
122128
const assign = JsonPointer.assign("/0");
123129

124130
Then("an error should be thrown", () => {
125-
expect(() => assign(subject as Pointable, "foo")).to.throw(Error, "Value at '' is a number and does not have property '0'");
131+
expect(() => assign(subject, "foo")).to.throw(Error, "Value at '' is a number and does not have property '0'");
126132
});
127133
});
128134
});
129135

130136
Given("a string", () => {
131-
let subject: unknown;
137+
/** @type string */
138+
let subject;
132139

133140
beforeEach(() => {
134141
subject = "foo";
@@ -138,13 +145,14 @@ describe("JsonPointer.assign", () => {
138145
const assign = JsonPointer.assign("/0");
139146

140147
Then("an error should be thrown", () => {
141-
expect(() => assign(subject as Pointable, "foo")).to.throw(Error, "Value at '' is a string and does not have property '0'");
148+
expect(() => assign(subject, "foo")).to.throw(Error, "Value at '' is a string and does not have property '0'");
142149
});
143150
});
144151
});
145152

146153
Given("null", () => {
147-
let subject: unknown;
154+
/** @type null */
155+
let subject;
148156

149157
beforeEach(() => {
150158
subject = null;
@@ -154,7 +162,7 @@ describe("JsonPointer.assign", () => {
154162
const assign = JsonPointer.assign("/0");
155163

156164
Then("an error should be thrown", () => {
157-
expect(() => assign(subject as Pointable, "foo")).to.throw(Error, "Value at '' is null and does not have property '0'");
165+
expect(() => assign(subject, "foo")).to.throw(Error, "Value at '' is null and does not have property '0'");
158166
});
159167
});
160168
});

lib/get.spec.ts renamed to lib/get.test.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import { beforeEach, describe, expect, test } from "vitest";
22
import * as JsonPointer from "./index.js";
3-
import type { Getter } from "./index.js";
3+
4+
/**
5+
* @import { Getter } from "./index.js"
6+
*/
47

58

69
describe("JsonPointer", () => {
710
const subject = {
8-
"foo": ["bar", "baz"],
11+
foo: ["bar", "baz"],
912
"": 0,
1013
"a/b": 1,
1114
"c%d": 2,
@@ -19,12 +22,13 @@ describe("JsonPointer", () => {
1922
"~1": 10,
2023
"/0": 11,
2124
"/1": 12,
22-
"aaa": null,
23-
"bbb": { "-": { "ccc": 13 } }
25+
aaa: null,
26+
bbb: { "-": { ccc: 13 } }
2427
};
2528

2629
describe("get", () => {
27-
const tests: [string, unknown][] = [
30+
/** @type [string, unknown][] */
31+
const tests = [
2832
["", subject],
2933
["/foo", ["bar", "baz"]],
3034
["/foo/0", "bar"],
@@ -42,15 +46,16 @@ describe("JsonPointer", () => {
4246
["/~10", 11],
4347
["/~11", 12],
4448
["/bbb/-/ccc", 13],
45-
["/bbb/-", { "ccc": 13 }],
49+
["/bbb/-", { ccc: 13 }],
4650
["/bar", undefined],
4751
["/foo/2", undefined],
4852
["/foo/-", undefined],
4953
["/0", undefined]
5054
];
5155
tests.forEach(([pointer, expected]) => {
5256
describe(JSON.stringify(pointer), () => {
53-
let ptr: Getter;
57+
/** @type Getter */
58+
let ptr;
5459

5560
beforeEach(() => {
5661
ptr = JsonPointer.get(pointer);

lib/gherkin.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { describe, it } from "vitest";
2+
3+
/**
4+
* @import { SuiteCollector, SuiteFactory, TestFunction } from "vitest"
5+
*/
6+
7+
8+
/** @type (message: string, fn?: SuiteFactory) => SuiteCollector */
9+
export const Given = (message, fn) => describe("Given " + message, fn);
10+
11+
/** @type (message: string, fn?: SuiteFactory) => SuiteCollector */
12+
export const When = (message, fn) => describe("When " + message, fn);
13+
14+
/** @type (message: string, fn?: TestFunction) => void */
15+
export const Then = (message, fn) => {
16+
it("Then " + message, fn);
17+
};
18+
19+
/** @type (message: string, fn?: SuiteFactory) => SuiteCollector */
20+
export const And = (message, fn) => describe("And " + message, fn);

lib/gherkin.ts

-11
This file was deleted.

0 commit comments

Comments
 (0)