Task/checkfile length (#7959)

* add hygiene task to test file length

* check for the filename length instead of the path

* formatted the error message

* added check for entire path including directories

* error messaged fixed

* check relative length for 150 as agreed upon

* error message to include 150

* added file length filter

* check the file length seperately

* ffsdfsdf

* remove the test file

* move it to last

* restore the filtered files for further checks

* removed comment

* test

* test

* remove the test file

* test commit

* remove the test file

* restore fileLengthFilter

* test

* remove the testfile

* revert

* xfgdgdfg

* huh

* test file

* revert.

* add all to the filter
This commit is contained in:
Maddy
2019-10-25 14:30:43 -07:00
committed by GitHub
parent d1a0ae43c8
commit d79423c728

View File

@@ -249,6 +249,12 @@ const tslintHygieneFilter = [
...tslintBaseFilter
];
const fileLengthFilter = filter([
'**',
'!extensions/import/*.docx',
'!extensions/admin-tool-ext-win/license/**'
], {restore: true});
const copyrightHeaderLines = [
'/*---------------------------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
@@ -387,6 +393,23 @@ function hygiene(some) {
});
});
const filelength = es.through(function (file) {
const fileName = path.basename(file.relative);
const fileDir = path.dirname(file.relative);
//check the filename is < 50 characters (basename gets the filename with extension).
if (fileName.length > 50) {
console.error(`File name '${fileName}' under ${fileDir} is too long. Rename file to have less than 50 characters.`);
errorCount++;
}
if (file.relative.length > 150) {
console.error(`File path ${file.relative} exceeds acceptable file-length. Rename the path to have less than 150 characters.`);
errorCount++;
}
this.emit('data', file);
});
const tslintConfiguration = tslint.Configuration.findConfiguration('tslint.json', '.');
const tslintOptions = { fix: false, formatter: 'json' };
const tsLinter = new tslint.Linter(tslintOptions);
@@ -418,6 +441,9 @@ function hygiene(some) {
const productJsonFilter = filter('product.json', { restore: true });
const result = input
.pipe(fileLengthFilter)
.pipe(filelength)
.pipe(fileLengthFilter.restore)
.pipe(filter(f => !f.stat.isDirectory()))
.pipe(productJsonFilter)
.pipe(process.env['BUILD_SOURCEVERSION'] ? es.through() : productJson)