Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 8bcf546

Browse files
author
Matt Goo
committed
feat(infrastructure): add tsconfig, tslint, and build setup (#4241)
1 parent 017ecb6 commit 8bcf546

23 files changed

+4194
-3220
lines changed

.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rules:
1515
quotes: [error, single, {"avoidEscape": true}]
1616
no-var: error
1717
curly: error
18+
eol-last: [error, "always"]
1819
no-floating-decimal: error
1920
no-unused-vars:
2021
- error

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ out
88
.idea
99
*.sw*
1010
.closure-tmp
11+
.vscode
12+
.typescript-tmp

.travis.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ branches:
1212
# This prevents excessive resource usage and CI slowness.
1313
only:
1414
- master
15+
- feat/typescript
1516

1617
before_install:
1718
# Source the scripts to export their env vars. See https://superuser.com/a/176788/62792
@@ -48,17 +49,10 @@ matrix:
4849
addons:
4950
sauce_connect: true
5051
script:
51-
- if has_testable_files; then npm run test:unit && npm run posttest; else log_untestable_files; fi
52+
- if has_testable_files; then npm run test:unit; else log_untestable_files; fi
5253
after_success:
5354
- codecov
5455

55-
- node_js: 8
56-
env:
57-
- TEST_SUITE=closure
58-
- CLOSURE=1
59-
script:
60-
- if has_testable_files; then npm run test:closure; else log_untestable_files; fi
61-
6256
- node_js: 8
6357
env:
6458
- TEST_SUITE=site-generator

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ npm run fix # Runs both of the above commands in parallel
9999
100100
npm run test:watch # Runs karma on Chrome, re-running when source files change
101101
102-
npm test # Lints all files, runs karma, runs closure tests, and then runs coverage enforcement checks.
102+
npm test # Lints all files, runs karma, runs typescript tests, and then runs coverage enforcement checks.
103103
npm run test:unit # Only runs the karma tests
104-
npm run test:closure # Runs closure build tests against all closurized files
105104
```
106105

107106
#### Running Tests across browsers

closure_externs.js

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

docs/closure-compiler.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,13 +762,6 @@ would override what's been assigned in `initialize()`.
762762
763763
While this may seem very foreign coming from outside of closure, it is a [common idiom used by closure code](https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#typedefs).
764764
765-
## Handling third-party code
766-
767-
Some of our components rely on third-party modules. These modules must be typed as **externs**
768-
within `closure_externs.js`. In most cases, you will not need to worry about doing this, as a core
769-
team member will most likely assist you with it. However, the details of typing these modules can
770-
be found within that file.
771-
772765
## Where to go for more help
773766
774767
If you're working on an issue for MDC Web and find yourself wrestling with closure, please don't

karma.conf.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ const SAUCE_LAUNCHERS = {
5050

5151
const customLaunchers = Object.assign({}, USING_SL ? SAUCE_LAUNCHERS : {}, HEADLESS_LAUNCHERS);
5252
const browsers = USING_TRAVISCI ? Object.keys(customLaunchers) : ['Chrome'];
53+
const istanbulInstrumenterLoader = {
54+
use: [{
55+
loader: 'istanbul-instrumenter-loader',
56+
options: {esModules: true},
57+
}],
58+
exclude: [
59+
/node_modules/,
60+
/adapter.[jt]s$/,
61+
/constants.[jt]s$/,
62+
],
63+
include: path.resolve('./packages'),
64+
};
5365

5466
module.exports = function(config) {
5567
config.set({
@@ -61,7 +73,7 @@ module.exports = function(config) {
6173
preprocessors: {
6274
'test/unit/index.js': ['webpack', 'sourcemap'],
6375
},
64-
reporters: ['dots', 'coverage'],
76+
reporters: ['dots', 'coverage-istanbul'],
6577
port: 9876,
6678
colors: true,
6779
logLevel: config.LOG_INFO,
@@ -72,13 +84,21 @@ module.exports = function(config) {
7284
concurrency: USING_SL ? 4 : Infinity,
7385
customLaunchers: customLaunchers,
7486

75-
coverageReporter: {
76-
dir: 'coverage',
77-
reporters: [
78-
{type: 'lcovonly', subdir: '.'},
79-
{type: 'json', subdir: '.', file: 'coverage.json'},
80-
{type: 'html'},
81-
],
87+
coverageIstanbulReporter: {
88+
'dir': 'coverage',
89+
'reports': ['html', 'lcovonly', 'json'],
90+
'report-config': {
91+
lcovonly: {subdir: '.'},
92+
json: {subdir: '.', file: 'coverage.json'},
93+
},
94+
// 'emitWarning' causes the tests to fail if the thresholds are not met
95+
'emitWarning': false,
96+
'thresholds': {
97+
statements: 95,
98+
branches: 95,
99+
lines: 95,
100+
functions: 95,
101+
},
82102
},
83103

84104
client: {
@@ -93,20 +113,15 @@ module.exports = function(config) {
93113
},
94114

95115
webpack: Object.assign({}, webpackConfig, {
96-
devtool: 'inline-source-map',
97116
module: Object.assign({}, webpackConfig.module, {
98117
// Cover source files when not debugging tests. Otherwise, omit coverage instrumenting to get
99118
// uncluttered source maps.
100-
rules: webpackConfig.module.rules.concat([config.singleRun ? {
119+
rules: webpackConfig.module.rules.concat(config.singleRun ? [Object.assign({
120+
enforce: 'post',
121+
test: /\.ts$/,
122+
}, istanbulInstrumenterLoader), Object.assign({
101123
test: /\.js$/,
102-
include: path.resolve('./packages'),
103-
exclude: [
104-
/node_modules/,
105-
/adapter.js/,
106-
],
107-
loader: 'istanbul-instrumenter-loader',
108-
query: {esModules: true},
109-
} : undefined]).filter(Boolean),
124+
}, istanbulInstrumenterLoader)] : []),
110125
}),
111126
}),
112127

0 commit comments

Comments
 (0)