Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing "No Operand in Assignment" Usage #120

Merged
merged 10 commits into from
Jan 10, 2024
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ module.exports = {
}],
"prettier/prettier": "off",
"ember-suave/lines-between-object-propertiess": "off",
"no-empty": "off"
"no-empty": "off",
"no-unused-vars": [ "error", {
argsIgnorePattern: "^_"
}]
},
plugins: [],
globals: {
Expand Down
11 changes: 7 additions & 4 deletions src/apm-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ function getPythonVersion() {
const pythonExe = path.resolve(rootDir, 'Python27', 'python.exe');
if (fs.isFileSync(pythonExe)) { python = pythonExe; }
}

python ??= 'python';

const spawned = spawn(python, ['--version']);
const outputChunks = [];
spawned.stderr.on('data', chunk => outputChunks.push(chunk));
Expand Down Expand Up @@ -239,21 +239,24 @@ module.exports = {
if (args.version) {
return printVersions(args).then(errorHandler);
} else if (args.help) {
if ((Command = commands[options.command])) {
if (commands[options.command]) {
Command = commands[options.command];
showHelp(new Command().parseOptions?.(options.command));
} else {
showHelp(options);
}
return errorHandler();
} else if (command) {
if (command === 'help') {
if ((Command = commands[options.commandArgs])) {
if (commands[options.commandArgs]) {
Command = commands[options.commandArgs];
showHelp(new Command().parseOptions?.(options.commandArgs));
} else {
showHelp(options);
}
return errorHandler();
} else if ((Command = commands[command])) {
//Command = commands[command];
const command = new Command();
return command.run(options).then(errorHandler);
} else {
Expand Down
10 changes: 4 additions & 6 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ Run ppm -v after installing Git to see what version has been detected.\
// * packageVersion: The string version of the package.
isPackageInstalled(packageName, packageVersion) {
try {
let left;
const {version} = (left = CSON.readFileSync(CSON.resolve(path.join('node_modules', packageName, 'package')))) != null ? left : {};
const { version } = CSON.readFileSync(CSON.resolve(path.join('node_modules', packageName, 'package'))) ?? {};
return packageVersion === version;
} catch (error) {
return false;
Expand Down Expand Up @@ -399,10 +398,9 @@ Run ppm -v after installing Git to see what version has been detected.\
// Get all package dependency names and versions from the package.json file.
getPackageDependencies(cloneDir) {
try {
let left;
const fileName = path.join((cloneDir || '.'), 'package.json');
const metadata = fs.readFileSync(fileName, 'utf8');
const {packageDependencies, dependencies} = (left = JSON.parse(metadata)) != null ? left : {};
const { packageDependencies, dependencies } = JSON.parse(metadata) ?? {};

if (!packageDependencies) { return {}; }
if (!dependencies) { return packageDependencies; }
Expand Down Expand Up @@ -462,7 +460,7 @@ Run ppm -v after installing Git to see what version has been detected.\

fs.removeSync(path.resolve(__dirname, '..', 'native-module', 'build'));

return new Promise((resolve, reject) =>
return new Promise((resolve, reject) =>
void this.fork(this.atomNpmPath, buildArgs, buildOptions, (...args) =>
void this.logCommandResults(...args).then(resolve, reject)
)
Expand Down Expand Up @@ -679,7 +677,7 @@ Run ppm -v after installing Git to see what version has been detected.\
await this.installDependencies(options);
return;
}

// is registered package
let version;
const atIndex = name.indexOf('@');
Expand Down
4 changes: 2 additions & 2 deletions src/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ List all the installed packages and also the packages bundled with Atom.\
listPackages(directoryPath, options) {
const packages = [];
for (let child of Array.from(fs.list(directoryPath))) {
var manifestPath;
if (!fs.isDirectorySync(path.join(directoryPath, child))) { continue; }
if (child.match(/^\./)) { continue; }
if (!options.argv.links) {
if (fs.isSymbolicLinkSync(path.join(directoryPath, child))) { continue; }
}

let manifest = null;
confused-Techie marked this conversation as resolved.
Show resolved Hide resolved
if (manifestPath = CSON.resolve(path.join(directoryPath, child, 'package'))) {
let manifestPath = CSON.resolve(path.join(directoryPath, child, 'package'));
if (manifestPath) {
try {
manifest = CSON.readFileSync(manifestPath);
} catch (error) {}
Expand Down
3 changes: 2 additions & 1 deletion src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ have published it.\
}


if (currentBranch = repo.getShortHead()) {
currentBranch = repo.getShortHead();
if (currentBranch) {
remoteName = repo.getConfigValue(`branch.${currentBranch}.remote`);
}
if (remoteName == null) { remoteName = repo.getConfigValue('branch.master.remote'); }
Expand Down
6 changes: 3 additions & 3 deletions src/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ available updates.\
getInstalledPackages(options) {
let packages = [];
for (let name of fs.list(this.atomPackagesDirectory)) {
var pack;
if (pack = this.getIntalledPackage(name)) {
let pack = this.getIntalledPackage(name);
if (pack) {
packages.push(pack);
}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ available updates.\
git.addGitToEnv(process.env);
return new Promise((resolve, reject) => {
this.spawn(command, args, {cwd: repoPath}, (code, stderr, stdout) => {
stderr ??= '';
stderr ??= '';
stdout ??= '';
if (code !== 0) {
return void reject(new Error('Exit code: ' + code + ' - ' + stderr));
Expand Down