Using the '.eslintignore' config file for excluding the temporary,

vendor specific, and templates files, instead of writing our own logic
to do so.

Patch by: Anthony & Joao
Reviewed by: Khushboo
This commit is contained in:
Anthony Emengo 2018-05-17 11:33:29 +05:30 committed by Ashesh Vashi
parent bd356ff9fa
commit a7ee85619d
3 changed files with 6 additions and 45 deletions

5
web/.eslintignore Normal file
View File

@ -0,0 +1,5 @@
generated
node_modules
vendor
templates/
templates\

View File

@ -91,7 +91,7 @@
"webcabin-docker": "git+https://github.com/EnterpriseDB/wcDocker"
},
"scripts": {
"linter": "node pga_eslint.js",
"linter": "yarn eslint --no-eslintrc -c .eslintrc.js --ext .js --ext .jsx .",
"webpacker": "yarn run webpack --config webpack.config.js --progress",
"webpacker:watch": "yarn run webpack --config webpack.config.js --progress --watch",
"bundle:watch": "yarn run linter && yarn run webpacker:watch",

View File

@ -1,44 +0,0 @@
#!/usr/bin/env node
/* eslint no-console:off */
/* eslint no-undef:off */
'use strict';
const debug = (process.argv.indexOf('--debug') > -1),
file_argv = process.argv.indexOf('--file');
var argv = process.argv;
if (file_argv > -1) {
argv.splice(file_argv, 1);
} else {
argv = argv.concat(['--ignore-pattern', __filename]);
}
// must do this initialization *before* other requires in order to work
if (debug) {
require('debug').enable('eslint:*,-eslint:code-path');
}
const fs = require('fs');
const path = require('path');
const read = (dir) =>
fs.readdirSync(dir)
.reduce((files, file) =>
fs.statSync(path.join(dir, file)).isDirectory() ?
files.concat(read(path.join(dir, file))) :
((file, files) => (
file.indexOf(path.sep + 'generated' + path.sep) === -1 &&
file.indexOf(path.sep + 'vendor' + path.sep) === -1 &&
file.indexOf(path.sep + 'static' + path.sep) > -1 &&
(file.endsWith('.js') || file.endsWith('.jsx')) &&
files.concat(file) || files
))(path.join(dir, file), files), []),
eslint_cli = require('eslint/lib/cli');
process.exitCode = eslint_cli.execute(
file_argv > -1 ? argv : argv.concat(
read(path.join(__dirname, 'pgadmin'))
).concat(
['regression/javascript/**/*.jsx','regression/javascript/**/*.js','*.js']
)
);