From a7ee85619dfd4cf42a43919beeb1cd1680f46d53 Mon Sep 17 00:00:00 2001 From: Anthony Emengo Date: Thu, 17 May 2018 11:33:29 +0530 Subject: [PATCH] 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 --- web/.eslintignore | 5 +++++ web/package.json | 2 +- web/pga_eslint.js | 44 -------------------------------------------- 3 files changed, 6 insertions(+), 45 deletions(-) create mode 100644 web/.eslintignore delete mode 100644 web/pga_eslint.js diff --git a/web/.eslintignore b/web/.eslintignore new file mode 100644 index 000000000..7468ecb85 --- /dev/null +++ b/web/.eslintignore @@ -0,0 +1,5 @@ +generated +node_modules +vendor +templates/ +templates\ diff --git a/web/package.json b/web/package.json index 93bf4e452..b9953b642 100644 --- a/web/package.json +++ b/web/package.json @@ -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", diff --git a/web/pga_eslint.js b/web/pga_eslint.js deleted file mode 100644 index 11511d67e..000000000 --- a/web/pga_eslint.js +++ /dev/null @@ -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'] - ) -);