Skip to content

Commit

Permalink
Chore: upgrade dependencies of browser test (#14127)
Browse files Browse the repository at this point in the history
* Chore: upgrade dependencies of browser test

* Chore: simplify Node.js modules polyfill

* Chore: remove unnecessary dependency

* Chore: simplify webpack config in Karma

* Chore: clean up entries in Karma config
  • Loading branch information
g-plane committed Mar 5, 2021
1 parent ebfb63a commit 459d821
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -55,6 +55,8 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Install Packages
run: npm install
- name: Test
Expand Down
12 changes: 10 additions & 2 deletions karma.conf.js
@@ -1,5 +1,6 @@
"use strict";
const os = require("os");
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

if (os.arch() === "arm64") {

Expand All @@ -20,12 +21,11 @@ module.exports = function(config) {
* frameworks to use
* available frameworks: https://npmjs.org/browse/keyword/karma-adapter
*/
frameworks: ["mocha"],
frameworks: ["mocha", "webpack"],


// list of files / patterns to load in the browser
files: [
"build/eslint.js",
"tests/lib/linter/linter.js"
],

Expand All @@ -44,6 +44,14 @@ module.exports = function(config) {
},
webpack: {
mode: "none",
plugins: [
new NodePolyfillPlugin()
],
resolve: {
alias: {
"../../../lib/linter$": "../../../build/eslint.js"
}
},
stats: "errors-only"
},
webpackMiddleware: {
Expand Down
13 changes: 7 additions & 6 deletions package.json
Expand Up @@ -108,18 +108,19 @@
"fs-teardown": "^0.1.0",
"glob": "^7.1.6",
"jsdoc": "^3.5.5",
"karma": "^4.0.1",
"karma": "^6.1.1",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-webpack": "^4.0.0-rc.6",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-webpack": "^5.0.0",
"lint-staged": "^10.1.2",
"load-perf": "^0.2.0",
"markdownlint": "^0.19.0",
"markdownlint-cli": "^0.22.0",
"memfs": "^3.0.1",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.23.0",
"node-polyfill-webpack-plugin": "^1.0.3",
"npm-license": "^0.3.3",
"nyc": "^15.0.1",
"proxyquire": "^2.0.1",
Expand All @@ -129,8 +130,8 @@
"shelljs": "^0.8.2",
"sinon": "^9.0.1",
"temp": "^0.9.0",
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5",
"webpack": "^5.23.0",
"webpack-cli": "^4.5.0",
"yorkie": "^2.0.0"
},
"keywords": [
Expand Down
23 changes: 1 addition & 22 deletions tests/lib/linter/linter.js
Expand Up @@ -5,27 +5,6 @@

"use strict";

//------------------------------------------------------------------------------
// Helper
//------------------------------------------------------------------------------

/**
* To make sure this works in both browsers and Node.js
* @param {string} name Name of the module to require
* @param {Object} windowName name of the window
* @returns {Object} Required object
* @private
*/
function compatRequire(name, windowName) {
if (typeof window === "object") { // eslint-disable-line no-undef
return window[windowName || name]; // eslint-disable-line no-undef
}
if (typeof require === "function") {
return require(name);
}
throw new Error(`Cannot find object '${name}'.`);
}

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
Expand All @@ -35,7 +14,7 @@ const assert = require("chai").assert,
esprima = require("esprima"),
testParsers = require("../../fixtures/parsers/linter-test-parsers");

const { Linter } = compatRequire("../../../lib/linter", "eslint");
const { Linter } = require("../../../lib/linter");

//------------------------------------------------------------------------------
// Constants
Expand Down
5 changes: 5 additions & 0 deletions webpack.config.js
@@ -1,5 +1,7 @@
"use strict";
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");

/** @type {import("webpack").Configuration} */
module.exports = {
mode: "none",
entry: {
Expand Down Expand Up @@ -42,6 +44,9 @@ module.exports = {
}
]
},
plugins: [
new NodePolyfillPlugin()
],
resolve: {
mainFields: ["browser", "main", "module"]
},
Expand Down

0 comments on commit 459d821

Please sign in to comment.