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

feat(infrastructure): add tsconfig, tslint, and build setup #4241

Merged
merged 34 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
be65412
WIP: added tslint and tsconfig/webpack updates. TODO: test with base
Jan 4, 2019
84c7798
feat: add component and foundation for base
Jan 4, 2019
ba117bc
feat: remove js files
Jan 5, 2019
50c3d91
fix: lint
Jan 5, 2019
0aa0577
WIP: understand closure tests
Jan 8, 2019
ed8e3a2
WIP: removed babylon package
Jan 8, 2019
fe47f1d
WIP: rewrite rewrite script
Jan 9, 2019
7a25c20
fix: imports
Jan 10, 2019
a0a58b9
fix: lint
Jan 10, 2019
2a9da2e
fix: closure tests on trvis
Jan 10, 2019
110d93c
fix: strict typings in foundation, eslint/tslint updates
Jan 15, 2019
24eab16
fix: karmaconfig to run over ts files
Jan 15, 2019
46a7c1f
WIP Add feat/typescript branch to .travis.yml
Jan 15, 2019
33a20d5
fix: remove typescriptWhitelist
Jan 15, 2019
af44094
Merge branch 'feat/tsconfig-webpack-setup' of github.com:material-com…
Jan 15, 2019
46237c8
fix: remove typescriptwhitlist
Jan 15, 2019
47f8cea
fix: istanbul coverage reporter
Jan 16, 2019
2fec705
fix: address PR comments
Jan 16, 2019
0854257
Update rewrite-declaration-statements-for-typescript.js
Jan 16, 2019
f3b25b0
fix: pr changes to karma and webpack
Jan 16, 2019
c3be470
fix: package-lock
Jan 16, 2019
08bea1d
fix: remove karma-coverage
Jan 16, 2019
2578a7e
WIP Minor cleanup
Jan 16, 2019
ed44ff3
fix: add back relative path
Jan 16, 2019
5fd5092
Merge branch 'feat/tsconfig-webpack-setup' of github.com:material-com…
Jan 16, 2019
8585d61
WIP More cleanup
Jan 16, 2019
cf7c1c2
fix: karmaconf to new karma-coverage-istanbul-reporter syntax
Jan 17, 2019
4f84473
Merge branch 'feat/tsconfig-webpack-setup' of github.com:material-com…
Jan 17, 2019
afb4860
fix: update karma
Jan 17, 2019
01c6044
fix: coverage reporting
Jan 18, 2019
bafff07
Update index.js
Jan 18, 2019
8f7b603
fix: PR changes
Jan 18, 2019
afae2ea
fix: change regex
Jan 18, 2019
c8cd149
fix: remove posttest
Jan 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rules:
quotes: [error, single, {"avoidEscape": true}]
no-var: error
curly: error
eol-last: [error, "always"]
no-floating-decimal: error
no-unused-vars:
- error
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ out
.idea
*.sw*
.closure-tmp
.vscode
.typescript-tmp
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ branches:
# This prevents excessive resource usage and CI slowness.
only:
- master
- feat/typescript

before_install:
# Source the scripts to export their env vars. See https://superuser.com/a/176788/62792
Expand Down Expand Up @@ -48,17 +49,10 @@ matrix:
addons:
sauce_connect: true
script:
- if has_testable_files; then npm run test:unit && npm run posttest; else log_untestable_files; fi
- if has_testable_files; then npm run test:unit; else log_untestable_files; fi
after_success:
- codecov

- node_js: 8
env:
- TEST_SUITE=closure
- CLOSURE=1
script:
- if has_testable_files; then npm run test:closure; else log_untestable_files; fi

- node_js: 8
env:
- TEST_SUITE=site-generator
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ npm run fix # Runs both of the above commands in parallel

npm run test:watch # Runs karma on Chrome, re-running when source files change

npm test # Lints all files, runs karma, runs closure tests, and then runs coverage enforcement checks.
npm test # Lints all files, runs karma, runs typescript tests, and then runs coverage enforcement checks.
npm run test:unit # Only runs the karma tests
npm run test:closure # Runs closure build tests against all closurized files
```

#### Running Tests across browsers
Expand Down
115 changes: 0 additions & 115 deletions closure_externs.js

This file was deleted.

7 changes: 0 additions & 7 deletions docs/closure-compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,6 @@ would override what's been assigned in `initialize()`.

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).

## Handling third-party code

Some of our components rely on third-party modules. These modules must be typed as **externs**
within `closure_externs.js`. In most cases, you will not need to worry about doing this, as a core
team member will most likely assist you with it. However, the details of typing these modules can
be found within that file.

## Where to go for more help

If you're working on an issue for MDC Web and find yourself wrestling with closure, please don't
Expand Down
51 changes: 33 additions & 18 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ const SAUCE_LAUNCHERS = {

const customLaunchers = Object.assign({}, USING_SL ? SAUCE_LAUNCHERS : {}, HEADLESS_LAUNCHERS);
const browsers = USING_TRAVISCI ? Object.keys(customLaunchers) : ['Chrome'];
const istanbulInstrumenterLoader = {
use: [{
loader: 'istanbul-instrumenter-loader',
options: {esModules: true},
}],
exclude: [
/node_modules/,
/adapter.[jt]s$/,
/constants.[jt]s$/,
],
include: path.resolve('./packages'),
};

module.exports = function(config) {
config.set({
Expand All @@ -61,7 +73,7 @@ module.exports = function(config) {
preprocessors: {
'test/unit/index.js': ['webpack', 'sourcemap'],
},
reporters: ['dots', 'coverage'],
reporters: ['dots', 'coverage-istanbul'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand All @@ -72,13 +84,21 @@ module.exports = function(config) {
concurrency: USING_SL ? 4 : Infinity,
customLaunchers: customLaunchers,

coverageReporter: {
dir: 'coverage',
reporters: [
{type: 'lcovonly', subdir: '.'},
{type: 'json', subdir: '.', file: 'coverage.json'},
{type: 'html'},
],
coverageIstanbulReporter: {
'dir': 'coverage',
'reports': ['html', 'lcovonly', 'json'],
'report-config': {
lcovonly: {subdir: '.'},
json: {subdir: '.', file: 'coverage.json'},
},
// 'emitWarning' causes the tests to fail if the thresholds are not met
'emitWarning': false,
'thresholds': {
statements: 95,
branches: 95,
lines: 95,
functions: 95,
},
},

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

webpack: Object.assign({}, webpackConfig, {
devtool: 'inline-source-map',
module: Object.assign({}, webpackConfig.module, {
// Cover source files when not debugging tests. Otherwise, omit coverage instrumenting to get
// uncluttered source maps.
rules: webpackConfig.module.rules.concat([config.singleRun ? {
rules: webpackConfig.module.rules.concat(config.singleRun ? [Object.assign({
enforce: 'post',
test: /\.ts$/,
}, istanbulInstrumenterLoader), Object.assign({
test: /\.js$/,
include: path.resolve('./packages'),
exclude: [
/node_modules/,
/adapter.js/,
],
loader: 'istanbul-instrumenter-loader',
query: {esModules: true},
} : undefined]).filter(Boolean),
}, istanbulInstrumenterLoader)] : []),
}),
}),

Expand Down
Loading