chore: ignore spec/node_modules from linting (#14717)

This commit is contained in:
Samuel Attard 2018-09-20 15:41:01 +10:00 committed by GitHub
parent 54ef906832
commit 82a5a9f455
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
const { GitProcess } = require('dugite')
const childProcess = require('child_process')
const fs = require('fs')
const klaw = require('klaw')
const minimist = require('minimist')
const path = require('path')
@ -77,6 +78,7 @@ const LINTERS = [ {
}, {
key: 'javascript',
roots: ['lib', 'spec', 'script', 'default_app'],
ignoreRoots: ['spec/node_modules'],
test: filename => filename.endsWith('.js'),
run: (opts, filenames) => {
const cmd = path.join(SOURCE_ROOT, 'node_modules', '.bin', 'eslint')
@ -142,6 +144,14 @@ async function findFiles (args, linter) {
filenames.push(...files)
}
for (const ignoreRoot of (linter.ignoreRoots) || []) {
const ignorePath = path.join(SOURCE_ROOT, ignoreRoot)
if (!fs.existsSync(ignorePath)) continue
const ignoreFiles = new Set(await findMatchingFiles(ignorePath, linter.test))
filenames = filenames.filter(fileName => !ignoreFiles.has(fileName))
}
// remove blacklisted files
filenames = filenames.filter(x => !BLACKLIST.has(x))
@ -173,5 +183,8 @@ async function main () {
}
if (process.mainModule === module) {
main()
main().catch((error) => {
console.error(error)
process.exit(1)
})
}