Skip to content

chore(ci): block import of entire rxjs library #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2016
Merged
Changes from all commits
Commits
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
23 changes: 13 additions & 10 deletions scripts/ci/forbidden-identifiers.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

'use strict';
/*
* This script analyzes the current commits of the CI.
Expand Down Expand Up @@ -27,7 +29,8 @@ const blocked_statements = [
'\\bfit\\(',
'\\bxdescribe\\(',
'\\bxit\\(',
'\\bdebugger;'
'\\bdebugger;',
'from \\\'rxjs/Rx\\\'',
];

const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');
Expand Down Expand Up @@ -62,10 +65,10 @@ function getCommitRange() {
*/
function findChangedFiles() {
return getCommitRange()
.then(function(range) {
.then(range => {
return exec(`git diff --name-status ${range} ./src ./e2e`);
})
.then(function(rawDiff) {
.then(rawDiff => {
// Ignore deleted files.
return rawDiff.split('\n')
.filter(function(line) {
Expand All @@ -85,13 +88,13 @@ function findChangedFiles() {

// Find all files, check for errors, and output every errors found.
findChangedFiles()
.then(function(fileList) {
.then(fileList => {
// Only match .js or .ts, and remove .d.ts files.
return fileList.filter(function(name) {
return name.match(/\.[jt]s$/) && !name.match(/\.d\.ts$/);
});
})
.then(function(fileList) {
.then(fileList => {
// Read every file and return a Promise that will contain an array of
// Object of the form { fileName, content }.
return Promise.all(fileList.map(function(fileName) {
Expand All @@ -101,10 +104,10 @@ findChangedFiles()
};
}));
})
.then(function(diffList) {
.then(diffList => {
// Reduce the diffList to an array of errors. The array will be empty if no errors
// were found.
return diffList.reduce(function(errors, diffEntry) {
return diffList.reduce((errors, diffEntry) => {
let fileName = diffEntry.fileName;
let content = diffEntry.content.split('\n');
let ln = 0;
Expand All @@ -126,17 +129,17 @@ findChangedFiles()
return errors;
}, []);
})
.then(function(errors) {
.then(errors => {
if (errors.length > 0) {
console.error('Error: You are using a statement in your commit, which is not allowed.');
errors.forEach(function(entry) {
errors.forEach(entry => {
console.error(` ${entry.fileName}@${entry.lineNumber}, Statement: ${entry.statement}.\n`);
});

process.exit(1);
}
})
.catch(function(err) {
.catch(err => {
// An error occured in this script. Output the error and the stack.
console.error('An error occured during execution:');
console.error(err);
Expand Down