Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 31779c6

Browse files
committed
chore: convert config files to TypeScript
1 parent 1e8da04 commit 31779c6

File tree

12 files changed

+182
-133
lines changed

12 files changed

+182
-133
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

karma.conf.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

karma.conf.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Config, ConfigOptions } from 'karma'
2+
import webpackConfig from './webpack.test.config'
3+
4+
export default (config: Config): void => {
5+
config.set({
6+
frameworks: ['mocha', 'chai', 'sinon'],
7+
8+
files: [
9+
{
10+
pattern: 'src/**/*.ts',
11+
watched: false,
12+
included: true,
13+
served: true,
14+
},
15+
{
16+
pattern: 'src/**/*.tsx',
17+
watched: false,
18+
included: true,
19+
served: true,
20+
},
21+
],
22+
preprocessors: {
23+
'src/**/*.ts?(x)': ['webpack', 'sourcemap'],
24+
},
25+
26+
// Ignore the npm package entry point
27+
exclude: ['src/index.ts'],
28+
29+
// karma-webpack doesn't change the file extensions so we just need to tell karma what these extensions mean.
30+
mime: {
31+
'text/x-typescript': ['ts', 'tsx'],
32+
},
33+
34+
webpack: webpackConfig,
35+
36+
webpackMiddleware: {
37+
stats: 'errors-only',
38+
bail: true,
39+
},
40+
41+
browsers: ['Chrome', 'Firefox'],
42+
customLaunchers: {
43+
ChromeHeadlessNoSandbox: {
44+
base: 'ChromeHeadless',
45+
// CI runs as root so we need to disable sandbox
46+
flags: ['--no-sandbox', '--disable-setuid-sandbox'],
47+
},
48+
},
49+
50+
reporters: ['progress', 'coverage-istanbul'],
51+
coverageIstanbulReporter: {
52+
reports: ['json'],
53+
fixWebpackSourcePaths: true,
54+
},
55+
} as ConfigOptions)
56+
}

package-lock.json

Lines changed: 63 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"commitmsg": "commitlint -e $GIT_PARAMS",
1111
"prettier": "prettier '**/{*.{js?(on),ts?(x),scss},.*.js?(on)}' --write --list-different",
1212
"tslint": "tslint -c tslint.json -p tsconfig.json 'src/*.ts?(x)'",
13-
"build": "tsc -p .",
14-
"watch": "tsc -p . -w",
15-
"test": "karma start",
16-
"pretest": "ts-node --project ./testdata/tsconfig.json ./testdata/generate.ts"
13+
"build": "tsc -p tsconfig.dist.json",
14+
"watch": "npm run build -- --watch",
15+
"test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' karma start",
16+
"pretest": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' ts-node ./testdata/generate.ts"
1717
},
1818
"commitlint": {
1919
"extends": [
@@ -43,6 +43,8 @@
4343
"@types/chai": "^4.1.4",
4444
"@types/fs-extra": "^5.0.3",
4545
"@types/highlight.js": "^9.12.3",
46+
"@types/karma": "^1.7.3",
47+
"@types/karma-webpack": "^2.0.4",
4648
"@types/lodash": "^4.14.110",
4749
"@types/marked": "^0.4.0",
4850
"@types/mocha": "^5.2.3",

src/testutils/dom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// import githubCode from '../../testdata/generated/github.html'
22
import sourcegraphCode from '../../testdata/generated/sourcegraph.html'
3-
import { TEST_DATA_REVSPEC } from '../../testdata/rev'
3+
import { TEST_DATA_REVSPEC } from './rev'
44

55
export const getTextNodes = (node: Node): Node[] => {
66
if (node.childNodes.length === 0 && node.TEXT_NODE === node.nodeType && node.nodeValue) {
File renamed without changes.

testdata/tsconfig.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

tsconfig.dist.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["src/**/*"],
4+
"exclude": ["src/**/*.test.ts", "src/testutils"]
5+
}

tsconfig.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"allowSyntheticDefaultImports": true,
1111
"esModuleInterop": true,
1212
"jsx": "react",
13-
"sourceRoot": "src",
14-
"lib": ["es2017", "dom", "dom.iterable"]
15-
},
16-
"include": ["src/**/*"]
13+
"lib": ["es2017", "dom", "dom.iterable"],
14+
"sourceRoot": "src"
15+
}
1716
}

0 commit comments

Comments
 (0)