Skip to content

Commit 262dc74

Browse files
committed
feat: rewrite in TypeScript
1 parent b7b168c commit 262dc74

23 files changed

+1486
-2262
lines changed

.eslintrc.js

+27-15
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,57 @@ module.exports = {
44
plugins: ["prettier"],
55
overrides: [
66
{
7-
files: ["*.js"],
7+
files: ["*.{ts,tsx}"],
88
extends: [
9-
"@susisu/eslint-config/preset/es",
10-
"plugin:eslint-comments/recommended",
9+
"@susisu/eslint-config/preset/ts-types",
1110
"prettier",
11+
"prettier/@typescript-eslint",
12+
"plugin:eslint-comments/recommended",
1213
],
1314
parserOptions: {
1415
ecmaVersion: 2019,
15-
sourceType: "script",
16+
sourceType: "module",
17+
project: "./tsconfig.json",
1618
},
1719
env: {
1820
es6: true,
19-
node: true,
2021
},
2122
rules: {
2223
"prettier/prettier": "error",
2324
"eslint-comments/no-unused-disable": "error",
2425
},
2526
},
2627
{
27-
files: ["rollup.config.js"],
28-
parserOptions: {
29-
sourceType: "module",
28+
files: ["*.{test,spec}.{ts,tsx}", "src/**/__tests__/**/*.{ts,tsx}"],
29+
extends: ["plugin:jest/recommended", "plugin:jest-formatting/recommended"],
30+
env: {
31+
"jest/globals": true,
3032
},
3133
},
3234
{
33-
files: ["lib/**/*.js"],
35+
files: ["*.js"],
36+
extends: [
37+
"@susisu/eslint-config/preset/es",
38+
"plugin:eslint-comments/recommended",
39+
"prettier",
40+
],
3441
parserOptions: {
35-
sourceType: "module",
42+
ecmaVersion: 2019,
43+
sourceType: "script",
3644
},
3745
env: {
38-
node: false,
46+
es6: true,
47+
node: true,
48+
},
49+
rules: {
50+
"prettier/prettier": "error",
51+
"eslint-comments/no-unused-disable": "error",
3952
},
4053
},
4154
{
42-
files: ["lib/**/*.{test,spec}.js", "lib/**/__tests__/**/*.js"],
43-
extends: ["plugin:jest/recommended", "plugin:jest-formatting/recommended"],
44-
env: {
45-
"jest/globals": true,
55+
files: ["rollup.config.js"],
56+
parserOptions: {
57+
sourceType: "module",
4658
},
4759
},
4860
],

babel.config.js

-14
This file was deleted.

jest.config.js

+12-181
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,18 @@
11
"use strict";
22

3-
// For a detailed explanation regarding each configuration property, visit:
4-
// https://jestjs.io/docs/en/configuration.html
5-
63
module.exports = {
7-
// All imported modules in your tests should be mocked automatically
8-
// automock: false,
9-
10-
// Stop running tests after `n` failures
11-
// bail: 0,
12-
13-
// Respect "browser" field in package.json when resolving modules
14-
// browser: false,
15-
16-
// The directory where Jest should store its cached dependency information
17-
// cacheDirectory: "/private/var/folders/3c/ctp7bgwj7v9c8s56k_zn9wnr0000gn/T/jest_dx",
18-
19-
// Automatically clear mock calls and instances between every test
20-
// clearMocks: false,
21-
22-
// Indicates whether the coverage information should be collected while executing the test
4+
roots: ["./src"],
5+
testMatch: ["**/*.{test,spec}.{ts,tsx}"],
6+
testEnvironment: "node",
237
collectCoverage: true,
24-
25-
// An array of glob patterns indicating a set of files for which coverage information should be collected
26-
collectCoverageFrom: ["lib/**/*.js", "!**/*.test.js"],
27-
28-
// The directory where Jest should output its coverage files
8+
collectCoverageFrom: ["./src/**/*.{ts,tsx}", "!./src/**/*.{test,spec}.{ts,tsx}"],
299
coverageDirectory: "coverage",
30-
31-
// An array of regexp pattern strings used to skip coverage collection
32-
// coveragePathIgnorePatterns: [
33-
// "/node_modules/"
34-
// ],
35-
36-
// A list of reporter names that Jest uses when writing coverage reports
37-
// coverageReporters: [
38-
// "json",
39-
// "text",
40-
// "lcov",
41-
// "clover"
42-
// ],
43-
44-
// An object that configures minimum threshold enforcement for coverage results
45-
// coverageThreshold: null,
46-
47-
// A path to a custom dependency extractor
48-
// dependencyExtractor: null,
49-
50-
// Make calling deprecated APIs throw helpful error messages
51-
// errorOnDeprecated: false,
52-
53-
// Force coverage collection from ignored files using an array of glob patterns
54-
// forceCoverageMatch: [],
55-
56-
// A path to a module which exports an async function that is triggered once before all test suites
57-
// globalSetup: null,
58-
59-
// A path to a module which exports an async function that is triggered once after all test suites
60-
// globalTeardown: null,
61-
62-
// A set of global variables that need to be available in all test environments
63-
// globals: {},
64-
65-
// An array of directory names to be searched recursively up from the requiring module's location
66-
// moduleDirectories: [
67-
// "node_modules"
68-
// ],
69-
70-
// An array of file extensions your modules use
71-
// moduleFileExtensions: [
72-
// "js",
73-
// "json",
74-
// "jsx",
75-
// "ts",
76-
// "tsx",
77-
// "node"
78-
// ],
79-
80-
// A map from regular expressions to module names that allow to stub out resources with a single module
81-
// moduleNameMapper: {},
82-
83-
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
84-
// modulePathIgnorePatterns: [],
85-
86-
// Activates notifications for test results
87-
// notify: false,
88-
89-
// An enum that specifies notification mode. Requires { notify: true }
90-
// notifyMode: "failure-change",
91-
92-
// A preset that is used as a base for Jest's configuration
93-
// preset: null,
94-
95-
// Run tests from one or more projects
96-
// projects: null,
97-
98-
// Use this configuration option to add custom reporters to Jest
99-
// reporters: undefined,
100-
101-
// Automatically reset mock state between every test
102-
// resetMocks: false,
103-
104-
// Reset the module registry before running each individual test
105-
// resetModules: false,
106-
107-
// A path to a custom resolver
108-
// resolver: null,
109-
110-
// Automatically restore mock state between every test
111-
// restoreMocks: false,
112-
113-
// The root directory that Jest should scan for tests and modules within
114-
// rootDir: null,
115-
116-
// A list of paths to directories that Jest should use to search for files in
117-
// roots: [
118-
// "<rootDir>"
119-
// ],
120-
121-
// Allows you to use a custom runner instead of Jest's default test runner
122-
// runner: "jest-runner",
123-
124-
// The paths to modules that run some code to configure or set up the testing environment before each test
125-
// setupFiles: [],
126-
127-
// A list of paths to modules that run some code to configure or set up the testing framework before each test
128-
// setupFilesAfterEnv: [],
129-
130-
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
131-
// snapshotSerializers: [],
132-
133-
// The test environment that will be used for testing
134-
testEnvironment: "node",
135-
136-
// Options that will be passed to the testEnvironment
137-
// testEnvironmentOptions: {},
138-
139-
// Adds a location field to test results
140-
// testLocationInResults: false,
141-
142-
// The glob patterns Jest uses to detect test files
143-
// testMatch: [
144-
// "**/__tests__/**/*.[jt]s?(x)",
145-
// "**/?(*.)+(spec|test).[tj]s?(x)"
146-
// ],
147-
148-
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
149-
// testPathIgnorePatterns: [
150-
// "/node_modules/"
151-
// ],
152-
153-
// The regexp pattern or array of patterns that Jest uses to detect test files
154-
// testRegex: [],
155-
156-
// This option allows the use of a custom results processor
157-
// testResultsProcessor: null,
158-
159-
// This option allows use of a custom test runner
160-
// testRunner: "jasmine2",
161-
162-
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
163-
// testURL: "http://localhost",
164-
165-
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
166-
// timers: "real",
167-
168-
// A map from regular expressions to paths to transformers
169-
// transform: null,
170-
171-
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
172-
// transformIgnorePatterns: [
173-
// "/node_modules/"
174-
// ],
175-
176-
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
177-
// unmockedModulePathPatterns: undefined,
178-
179-
// Indicates whether each individual test should be reported during the run
180-
// verbose: null,
181-
182-
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
183-
// watchPathIgnorePatterns: [],
184-
185-
// Whether to use watchman for file crawling
186-
// watchman: true,
10+
globals: {
11+
"ts-jest": {
12+
tsconfig: "./tsconfig.test.json",
13+
},
14+
},
15+
transform: {
16+
"\\.tsx?$": "ts-jest",
17+
},
18718
};

lib/__tests__/gen.test.js

-80
This file was deleted.

0 commit comments

Comments
 (0)