Skip to content

Commit

Permalink
Build Process: avoid Eslint spread operator error (prebid#7313)
Browse files Browse the repository at this point in the history
* Eslint: avoid spread operator error

* Lint config files

* Include all .js files with `gulp lint`
  • Loading branch information
osazos authored Aug 19, 2021
1 parent e9a6b69 commit a437b05
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 132 deletions.
65 changes: 34 additions & 31 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@

const allowedModules = require("./allowedModules");
const allowedModules = require('./allowedModules.js');

module.exports = {
"env": {
"browser": true,
"commonjs": true
env: {
browser: true,
commonjs: true
},
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": ["node_modules", "./"]
settings: {
'import/resolver': {
node: {
moduleDirectory: ['node_modules', './']
}
}
},
"extends": "standard",
"plugins": [
"prebid",
"import"
extends: 'standard',
plugins: [
'prebid',
'import'
],
"globals": {
"$$PREBID_GLOBAL$$": false
globals: {
'$$PREBID_GLOBAL$$': false,
'BROWSERSTACK_USERNAME': false,
'BROWSERSTACK_KEY': false
},
"parserOptions": {
"sourceType": "module"
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018,
},
"rules": {
"comma-dangle": "off",
"semi": "off",
"space-before-function-paren": "off",
"import/extensions": ["error", "ignorePackages"],
rules: {
'comma-dangle': 'off',
semi: 'off',
'space-before-function-paren': 'off',
'import/extensions': ['error', 'ignorePackages'],

// Exceptions below this line are temporary, so that eslint can be added into the CI process.
// Violations of these styles should be fixed, and the exceptions removed over time.
//
// See Issue #1111.
"eqeqeq": "off",
"no-return-assign": "off",
"no-throw-literal": "off",
"no-undef": 2,
"no-useless-escape": "off",
"no-console": "error"
eqeqeq: 'off',
'no-return-assign': 'off',
'no-throw-literal': 'off',
'no-undef': 2,
'no-useless-escape': 'off',
'no-console': 'error'
},
"overrides": Object.keys(allowedModules).map((key) => ({
"files": key + "/**/*.js",
"rules": {
"prebid/validate-imports": ["error", allowedModules[key]]
overrides: Object.keys(allowedModules).map((key) => ({
files: key + '/**/*.js',
rules: {
'prebid/validate-imports': ['error', allowedModules[key]]
}
}))
};
1 change: 0 additions & 1 deletion gulpHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = {
},

jsonifyHTML: function (str) {
console.log(arguments);
return str.replace(/\n/g, '')
.replace(/<\//g, '<\\/')
.replace(/\/>/g, '\\/>');
Expand Down
14 changes: 10 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ var webpackStream = require('webpack-stream');
var terser = require('gulp-terser');
var gulpClean = require('gulp-clean');
var KarmaServer = require('karma').Server;
var karmaConfMaker = require('./karma.conf.maker');
var karmaConfMaker = require('./karma.conf.maker.js');
var opens = require('opn');
var webpackConfig = require('./webpack.conf');
var helpers = require('./gulpHelpers');
var webpackConfig = require('./webpack.conf.js');
var helpers = require('./gulpHelpers.js');
var concat = require('gulp-concat');
var header = require('gulp-header');
var footer = require('gulp-footer');
Expand Down Expand Up @@ -71,7 +71,13 @@ function lint(done) {
const isFixed = function (file) {
return file.eslint != null && file.eslint.fixed;
}
return gulp.src(['src/**/*.js', 'modules/**/*.js', 'test/**/*.js'], { base: './' })
return gulp.src([
'src/**/*.js',
'modules/**/*.js',
'test/**/*.js',
'plugins/**/*.js',
'./*.js'
], { base: './' })
.pipe(gulpif(argv.nolintfix, eslint(), eslint({ fix: true })))
.pipe(eslint.format('stylish'))
.pipe(eslint.failAfterError())
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.maker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// For more information, see http://karma-runner.github.io/1.0/config/configuration-file.html

var _ = require('lodash');
var webpackConf = require('./webpack.conf');
var webpackConf = require('./webpack.conf.js');
var karmaConstants = require('karma').constants;

function newWebpackConfig(codeCoverage) {
Expand Down
63 changes: 31 additions & 32 deletions nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
module.exports = (function(settings) {
var browsers = require('./browsers.json');
delete browsers['bs_ie_9_windows_7'];

for(var browser in browsers) {
if(browsers[browser].browser === 'iphone') continue;
var browsers = require('./browsers.json');
delete browsers['bs_ie_9_windows_7'];

var desiredCapabilities = {
"browserName": browsers[browser].browser,
"version": browsers[browser].browser_version,
"platform": browsers[browser].os,
"os": browsers[browser].os,
"os_version": browsers[browser].os_version,
"browser": browsers[browser].browser,
"browser_version": browsers[browser].browser_version,
};
for (var browser in browsers) {
if (browsers[browser].browser === 'iphone') continue;

settings.test_settings[browser] = {
"silent": true,
"exclude":["custom-assertions","custom-commands","common","custom-reporter"],
"screenshots" : {
"enabled" : false,
"path" : ""
},
"javascriptEnabled": true,
"acceptSslCerts": true,
"browserstack.local": true,
"browserstack.debug": true,
"browserstack.selenium_version" : "2.53.0",
"browserstack.user": "${BROWSERSTACK_USERNAME}",
"browserstack.key": "${BROWSERSTACK_KEY}"
};
settings.test_settings[browser]['desiredCapabilities'] = desiredCapabilities;
}
return settings;
var desiredCapabilities = {
'browserName': browsers[browser].browser,
'version': browsers[browser].browser_version,
'platform': browsers[browser].os,
'os': browsers[browser].os,
'os_version': browsers[browser].os_version,
'browser': browsers[browser].browser,
'browser_version': browsers[browser].browser_version,
};

settings.test_settings[browser] = {
'silent': true,
'exclude': ['custom-assertions', 'custom-commands', 'common', 'custom-reporter'],
'screenshots': {
'enabled': false,
'path': ''
},
'javascriptEnabled': true,
'acceptSslCerts': true,
'browserstack.local': true,
'browserstack.debug': true,
'browserstack.selenium_version': '2.53.0',
'browserstack.user': `${BROWSERSTACK_USERNAME}`,
'browserstack.key': `${BROWSERSTACK_KEY}`
};
settings.test_settings[browser]['desiredCapabilities'] = desiredCapabilities;
}
return settings;
})(require('./nightwatch.browserstack.json'));
2 changes: 1 addition & 1 deletion plugins/eslint/validateImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = {
let importPath = node.source.value.trim();
flagErrors(context, node, importPath);
},
"ExportNamedDeclaration[source]"(node) {
'ExportNamedDeclaration[source]'(node) {
let importPath = node.source.value.trim();
flagErrors(context, node, importPath);
}
Expand Down
60 changes: 30 additions & 30 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
module.exports = {
"env": {
"browser": true,
"mocha": true
env: {
browser: true,
mocha: true
},
"extends": "standard",
"globals": {
"$$PREBID_GLOBAL$$": false
extends: 'standard',
globals: {
'$$PREBID_GLOBAL$$': false
},
"parserOptions": {
"sourceType": "module"
parserOptions: {
sourceType: 'module'
},
"rules": {
"comma-dangle": "off",
"semi": "off",
"space-before-function-paren": "off",
rules: {
'comma-dangle': 'off',
semi: 'off',
'space-before-function-paren': 'off',

// Exceptions below this line are temporary, so that eslint can be added into the CI process.
// Violations of these styles should be fixed, and the exceptions removed over time.
//
// See Issue #1111.
"camelcase": "off",
"eqeqeq": "off",
"no-mixed-spaces-and-tabs": "off",
"no-tabs": "off",
"no-unused-expressions": "off",
"import/no-duplicates": "off",
"import/extensions": "off",
"no-template-curly-in-string": "off",
"no-global-assign": "off",
"no-path-concat": "off",
"no-redeclare": "off",
"node/no-deprecated-api": "off",
"no-return-assign": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"no-useless-escape": "off",
"one-var": "off"
camelcase: 'off',
eqeqeq: 'off',
'no-mixed-spaces-and-tabs': 'off',
'no-tabs': 'off',
'no-unused-expressions': 'off',
'import/no-duplicates': 'off',
'import/extensions': 'off',
'no-template-curly-in-string': 'off',
'no-global-assign': 'off',
'no-path-concat': 'off',
'no-redeclare': 'off',
'node/no-deprecated-api': 'off',
'no-return-assign': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'no-useless-escape': 'off',
'one-var': 'off'
}
};
50 changes: 25 additions & 25 deletions wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ function getCapabilities() {
}

exports.config = {
specs: [
'./test/spec/e2e/**/*.spec.js'
],
services: [
['browserstack', {
browserstackLocal: true
}]
],
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
maxInstances: 5, // Do not increase this, since we have only 5 parallel tests in browserstack account
capabilities: getCapabilities(),
logLevel: 'silent', // put option here: info | trace | debug | warn| error | silent
bail: 0,
waitforTimeout: 60000, // Default timeout for all waitFor* commands.
connectionRetryTimeout: 60000, // Default timeout in milliseconds for request if Selenium Grid doesn't send response
connectionRetryCount: 3, // Default request retries count
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 60000,
compilers: ['js:babel-register'],
},
// if you see error, update this to spec reporter and logLevel above to get detailed report.
reporters: ['concise']
specs: [
'./test/spec/e2e/**/*.spec.js'
],
services: [
['browserstack', {
browserstackLocal: true
}]
],
user: process.env.BROWSERSTACK_USERNAME,
key: process.env.BROWSERSTACK_ACCESS_KEY,
maxInstances: 5, // Do not increase this, since we have only 5 parallel tests in browserstack account
capabilities: getCapabilities(),
logLevel: 'silent', // put option here: info | trace | debug | warn| error | silent
bail: 0,
waitforTimeout: 60000, // Default timeout for all waitFor* commands.
connectionRetryTimeout: 60000, // Default timeout in milliseconds for request if Selenium Grid doesn't send response
connectionRetryCount: 3, // Default request retries count
framework: 'mocha',
mochaOpts: {
ui: 'bdd',
timeout: 60000,
compilers: ['js:babel-register'],
},
// if you see error, update this to spec reporter and logLevel above to get detailed report.
reporters: ['concise']
}
16 changes: 9 additions & 7 deletions webpack.conf.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
var prebid = require('./package.json');
var path = require('path');
var webpack = require('webpack');
var helpers = require('./gulpHelpers');
var helpers = require('./gulpHelpers.js');
var RequireEnsureWithoutJsonp = require('./plugins/RequireEnsureWithoutJsonp.js');
var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
var argv = require('yargs').argv;
var allowedModules = require('./allowedModules');
var allowedModules = require('./allowedModules.js');

// list of module names to never include in the common bundle chunk
var neverBundle = [
Expand All @@ -23,18 +23,20 @@ if (argv.analyze) {
)
}

plugins.push( // this plugin must be last so it can be easily removed for karma unit tests
plugins.push( // this plugin must be last so it can be easily removed for karma unit tests
new webpack.optimize.CommonsChunkPlugin({
name: 'prebid',
filename: 'prebid-core.js',
minChunks: function(module) {
return (
return (
(
module.context && module.context.startsWith(path.resolve('./src')) &&
!(module.resource && neverBundle.some(name => module.resource.includes(name)))
) ||
module.resource && (allowedModules.src.concat(['core-js'])).some(
name => module.resource.includes(path.resolve('./node_modules/' + name))
(
module.resource && (allowedModules.src.concat(['core-js'])).some(
name => module.resource.includes(path.resolve('./node_modules/' + name))
)
)
);
}
Expand All @@ -50,7 +52,7 @@ module.exports = {
],
},
output: {
jsonpFunction: prebid.globalVarName + "Chunk"
jsonpFunction: prebid.globalVarName + 'Chunk'
},
module: {
rules: [
Expand Down

0 comments on commit a437b05

Please sign in to comment.