forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add tslint rule to verify rollup globals config
Adds a custom tslint rule that ensures that we've added all of the necessary external modules to the Rollup config. This is helpful, because forgetting to add a module will log a warning, but it won't break the build necessarily, which is why we occasionally need PRs like angular#5930.
- Loading branch information
Showing
6 changed files
with
118 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
"tslib": "tslib", | ||
|
||
"@angular/animations": "ng.animations", | ||
"@angular/core": "ng.core", | ||
"@angular/common": "ng.common", | ||
"@angular/forms": "ng.forms", | ||
"@angular/http": "ng.http", | ||
"@angular/router": "ng.router", | ||
"@angular/platform-browser": "ng.platformBrowser", | ||
"@angular/platform-server": "ng.platformServer", | ||
"@angular/platform-browser-dynamic": "ng.platformBrowserDynamic", | ||
"@angular/platform-browser/animations": "ng.platformBrowser.animations", | ||
"@angular/core/testing": "ng.core.testing", | ||
"@angular/common/testing": "ng.common.testing", | ||
"@angular/http/testing": "ng.http.testing", | ||
|
||
"@angular/material": "ng.material", | ||
"@angular/cdk/a11y": "ng.cdk.a11y", | ||
"@angular/cdk/bidi": "ng.cdk.bidi", | ||
"@angular/cdk/coercion": "ng.cdk.coercion", | ||
"@angular/cdk/keyboard": "ng.cdk.keyboard", | ||
"@angular/cdk/observe-content": "ng.cdk.observeContent", | ||
"@angular/cdk/platform": "ng.cdk.platform", | ||
"@angular/cdk/portal": "ng.cdk.portal", | ||
"@angular/cdk/rxjs": "ng.cdk.rxjs", | ||
"@angular/cdk/table": "ng.cdk.table", | ||
"@angular/cdk": "ng.cdk", | ||
"@angular/cdk/testing": "ng.cdk.testing", | ||
|
||
"@angular/material-examples": "ng.materialExamples", | ||
|
||
"rxjs/BehaviorSubject": "Rx", | ||
"rxjs/Observable": "Rx", | ||
"rxjs/Subject": "Rx", | ||
"rxjs/Subscription": "Rx", | ||
"rxjs/Observer": "Rx", | ||
"rxjs/Scheduler": "Rx", | ||
"rxjs/observable/combineLatest": "Rx.Observable", | ||
"rxjs/observable/forkJoin": "Rx.Observable", | ||
"rxjs/observable/fromEvent": "Rx.Observable", | ||
"rxjs/observable/merge": "Rx.Observable", | ||
"rxjs/observable/of": "Rx.Observable", | ||
"rxjs/observable/throw": "Rx.Observable", | ||
"rxjs/operator/auditTime": "Rx.Observable.prototype", | ||
"rxjs/operator/catch": "Rx.Observable.prototype", | ||
"rxjs/operator/debounceTime": "Rx.Observable.prototype", | ||
"rxjs/operator/do": "Rx.Observable.prototype", | ||
"rxjs/operator/filter": "Rx.Observable.prototype", | ||
"rxjs/operator/finally": "Rx.Observable.prototype", | ||
"rxjs/operator/first": "Rx.Observable.prototype", | ||
"rxjs/operator/let": "Rx.Observable.prototype", | ||
"rxjs/operator/map": "Rx.Observable.prototype", | ||
"rxjs/operator/share": "Rx.Observable.prototype", | ||
"rxjs/operator/startWith": "Rx.Observable.prototype", | ||
"rxjs/operator/switchMap": "Rx.Observable.prototype", | ||
"rxjs/operator/takeUntil": "Rx.Observable.prototype", | ||
"rxjs/operator/toPromise": "Rx.Observable.prototype", | ||
|
||
"rxjs/add/observable/merge": "Rx.Observable", | ||
"rxjs/add/observable/fromEvent": "Rx.Observable", | ||
"rxjs/add/observable/of": "Rx.Observable", | ||
"rxjs/add/observable/interval": "Rx.Observable", | ||
"rxjs/add/operator/startWith": "Rx.Observable.prototype", | ||
"rxjs/add/operator/map": "Rx.Observable.prototype", | ||
"rxjs/add/operator/debounceTime": "Rx.Observable.prototype", | ||
"rxjs/add/operator/distinctUntilChanged": "Rx.Observable.prototype", | ||
"rxjs/add/operator/first": "Rx.Observable.prototype", | ||
"rxjs/add/operator/catch": "Rx.Observable.prototype", | ||
"rxjs/add/operator/switchMap": "Rx.Observable.prototype" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const path = require('path'); | ||
const Lint = require('tslint'); | ||
|
||
/** | ||
* Rule that enforces that the specified external packages have been included in our Rollup config. | ||
* Usage: [true, './path/to/rollup/config.json'] | ||
*/ | ||
class Rule extends Lint.Rules.AbstractRule { | ||
apply(file) { | ||
return this.applyWithWalker(new Walker(file, this.getOptions())); | ||
} | ||
} | ||
|
||
class Walker extends Lint.RuleWalker { | ||
constructor(file, options) { | ||
super(...arguments); | ||
|
||
if (!options.ruleArguments.length) { | ||
throw Error('missing-rollup-globals: The Rollup config path has to be specified.'); | ||
} | ||
|
||
this._configPath = path.resolve(process.cwd(), options.ruleArguments[0]); | ||
this._config = require(this._configPath); | ||
} | ||
|
||
visitImportDeclaration(node) { | ||
// Parse out the module name. The first and last characters are the quote marks. | ||
const module = node.moduleSpecifier.getText().slice(1, -1); | ||
const isExternal = !module.startsWith('.') && !module.startsWith('/'); | ||
|
||
// Check whether the module is external and whether it's in our config. | ||
if (isExternal && !this._config[module]) { | ||
this.addFailureAtNode(node, `Module "${module}" is missing from file ${this._configPath}.`); | ||
} | ||
|
||
super.visitImportDeclaration(node); | ||
} | ||
} | ||
|
||
exports.Rule = Rule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters