Skip to content

Commit 7419a12

Browse files
committed
chore: block import of entire rxjs library (#625)
1 parent f7f0b4a commit 7419a12

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

scripts/ci/forbidden-identifiers.js

100644100755
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env node
2+
13
'use strict';
24
/*
35
* This script analyzes the current commits of the CI.
@@ -27,7 +29,8 @@ const blocked_statements = [
2729
'\\bfit\\(',
2830
'\\bxdescribe\\(',
2931
'\\bxit\\(',
30-
'\\bdebugger;'
32+
'\\bdebugger;',
33+
'from \\\'rxjs/Rx\\\'',
3134
];
3235

3336
const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');
@@ -62,10 +65,10 @@ function getCommitRange() {
6265
*/
6366
function findChangedFiles() {
6467
return getCommitRange()
65-
.then(function(range) {
68+
.then(range => {
6669
return exec(`git diff --name-status ${range} ./src ./e2e`);
6770
})
68-
.then(function(rawDiff) {
71+
.then(rawDiff => {
6972
// Ignore deleted files.
7073
return rawDiff.split('\n')
7174
.filter(function(line) {
@@ -85,13 +88,13 @@ function findChangedFiles() {
8588

8689
// Find all files, check for errors, and output every errors found.
8790
findChangedFiles()
88-
.then(function(fileList) {
91+
.then(fileList => {
8992
// Only match .js or .ts, and remove .d.ts files.
9093
return fileList.filter(function(name) {
9194
return name.match(/\.[jt]s$/) && !name.match(/\.d\.ts$/);
9295
});
9396
})
94-
.then(function(fileList) {
97+
.then(fileList => {
9598
// Read every file and return a Promise that will contain an array of
9699
// Object of the form { fileName, content }.
97100
return Promise.all(fileList.map(function(fileName) {
@@ -101,10 +104,10 @@ findChangedFiles()
101104
};
102105
}));
103106
})
104-
.then(function(diffList) {
107+
.then(diffList => {
105108
// Reduce the diffList to an array of errors. The array will be empty if no errors
106109
// were found.
107-
return diffList.reduce(function(errors, diffEntry) {
110+
return diffList.reduce((errors, diffEntry) => {
108111
let fileName = diffEntry.fileName;
109112
let content = diffEntry.content.split('\n');
110113
let ln = 0;
@@ -126,17 +129,17 @@ findChangedFiles()
126129
return errors;
127130
}, []);
128131
})
129-
.then(function(errors) {
132+
.then(errors => {
130133
if (errors.length > 0) {
131134
console.error('Error: You are using a statement in your commit, which is not allowed.');
132-
errors.forEach(function(entry) {
135+
errors.forEach(entry => {
133136
console.error(` ${entry.fileName}@${entry.lineNumber}, Statement: ${entry.statement}.\n`);
134137
});
135138

136139
process.exit(1);
137140
}
138141
})
139-
.catch(function(err) {
142+
.catch(err => {
140143
// An error occured in this script. Output the error and the stack.
141144
console.error('An error occured during execution:');
142145
console.error(err);

0 commit comments

Comments
 (0)