From 09bb3d23ae2b6fe681d8e05d5257276852d53754 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra Date: Thu, 17 Aug 2023 13:19:53 -0400 Subject: [PATCH] Lint JavaScript files only --- .github/eslint.config.js | 1 + bin/autobump | 38 +++++++++++++++++++------------------- bin/nw | 34 ++++++++++++++++++---------------- package.json | 4 ++-- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/.github/eslint.config.js b/.github/eslint.config.js index 9c7a343..7ed6047 100644 --- a/.github/eslint.config.js +++ b/.github/eslint.config.js @@ -5,6 +5,7 @@ module.exports = { env: { node: true, }, + ignorePatterns: ['node_modules', 'package.json', 'package-lock.json'], extends: ['eslint:recommended'], rules: { quotes: ['error', 'single'], diff --git a/bin/autobump b/bin/autobump index 30dc72a..cc1a446 100755 --- a/bin/autobump +++ b/bin/autobump @@ -1,25 +1,25 @@ #!/usr/bin/env node -var fs = require("fs"); -var path = require("path"); -var semver = require("semver"); -var request = require("request"); -var exec = require("child_process").exec; +var fs = require('fs'); +var path = require('path'); +var semver = require('semver'); +var request = require('request'); +var exec = require('child_process').exec; -var url = "https://raw.github.com/rogerwang/node-webkit/master/README.md"; -var pkgpath = path.join(__dirname, "..", "package.json"); +var url = 'https://raw.github.com/rogerwang/node-webkit/master/README.md'; +var pkgpath = path.join(__dirname, '..', 'package.json'); // Download README file var readme = request(url); -var data = ""; -readme.on("data", function (buf) { +var data = ''; +readme.on('data', function (buf) { data += buf; }); -readme.on("end", function () { +readme.on('end', function () { var version = semver.clean(/\[v([^\s]+)\s+release notes\]/i.exec(data)[1]); // Version invalid so quit if (!semver.valid(version)) { - console.error("INVALID VERSION: " + version); + console.error('INVALID VERSION: ' + version); process.exit(); } var pkg = require(pkgpath); @@ -29,27 +29,27 @@ readme.on("end", function () { pkg.version = version; fs.writeFileSync(pkgpath, JSON.stringify(pkg, null, 2)); - console.log("PUBLISHING NEW VERSION " + version); + console.log('PUBLISHING NEW VERSION ' + version); var cmd = [ - "git add package.json", + 'git add package.json', 'git commit -m "v' + version + '"', - "git push origin master", - "npm publish", - ].join(" && "); + 'git push origin master', + 'npm publish', + ].join(' && '); exec( cmd, - { cwd: path.resolve(__dirname, "..") }, + { cwd: path.resolve(__dirname, '..') }, function (err, stdout, stderr) { if (err || stderr) { // Revert package.json change and try again next time - console.error("FAILED"); + console.error('FAILED'); console.error(err || stderr); pkg.version = currentversion; fs.writeFileSync(pkgpath, JSON.stringify(pkg, null, 2)); // TODO: Should revert commit here as well } else { - console.log("SUCCESS"); + console.log('SUCCESS'); } }, ); diff --git a/bin/nw b/bin/nw index 9d6e22b..bb644fe 100755 --- a/bin/nw +++ b/bin/nw @@ -1,14 +1,14 @@ #!/usr/bin/env node -var fs = require("fs"); -var path = require("path"); -var spawn = require("child_process").spawn; -var bin = require("../lib/findpath.js")(); +var fs = require('fs'); +var path = require('path'); +var spawn = require('child_process').spawn; +var bin = require('../lib/findpath.js')(); function run() { // Rename nw.js's own package.json as workaround for https://github.com/nwjs/nw.js/issues/1503 - var packagejson = path.resolve(__dirname, "..", "package.json"); - var packagejsonBackup = path.resolve(__dirname, "..", "package_backup.json"); + var packagejson = path.resolve(__dirname, '..', 'package.json'); + var packagejsonBackup = path.resolve(__dirname, '..', 'package_backup.json'); if (!fs.existsSync(packagejsonBackup)) { try { fs.renameSync(packagejson, packagejsonBackup); @@ -16,20 +16,20 @@ function run() { } // copy over any asset files (icons, etc) specified via CLI args: - require("../lib/app_assets").copyAssets(process.platform, bin); + require('../lib/app_assets').copyAssets(process.platform, bin); // Normalize cli args var args = process.argv.slice(2); - var cwd = args.length < 1 ? "." : args[0]; + var cwd = args.length < 1 ? '.' : args[0]; if (!fs.existsSync(path.resolve(cwd))) { - args = ["."].concat(args); + args = ['.'].concat(args); } else { args = [cwd].concat(args.slice(1)); } // Spawn node-webkit - var nw = spawn(bin, args, { stdio: "inherit" }); - nw.on("close", function () { + var nw = spawn(bin, args, { stdio: 'inherit' }); + nw.on('close', function () { process.nextTick(function () { process.exit(0); }); @@ -41,20 +41,22 @@ function run() { if (fs.existsSync(packagejsonBackup)) { fs.renameSync(packagejsonBackup, packagejson); } - } catch (err) {} + } catch (err) { + console.error(err); + } }, 1000); } if (!fs.existsSync(bin)) { console.log( - "nw.js appears to have failed to download and extract. Attempting to download and extract again...", + 'nw.js appears to have failed to download and extract. Attempting to download and extract again...', ); var child = spawn( process.execPath, - [path.resolve(__dirname, "..", "scripts", "install.js")], - { stdio: "inherit" }, + [path.resolve(__dirname, '..', 'scripts', 'install.js')], + { stdio: 'inherit' }, ); - child.on("close", run); + child.on('close', run); } else { run(); } diff --git a/package.json b/package.json index 42415c2..531afe9 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ }, "scripts": { "postinstall": "node scripts/install.js", - "lint": "eslint --config=.github/eslint.config.js --fix .", - "lint:check": "eslint --config=.github/eslint.config.js .", + "lint": "eslint --config=.github/eslint.config.js --fix ./**/*.js", + "lint:check": "eslint --config=.github/eslint.config.js ./**/*.js", "test": "node --test-reporter=spec --test test/index.mjs" }, "files": [