From ccff4b9ee5a37c13f0973b52e8f90a8be8359fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Tue, 4 Aug 2020 22:39:02 +0200 Subject: Add new eslint rules (#2121) The largest changes here are: - enforcing single quotes for strings - enforcing trailing commas where possible In addition to those we have enabled several eslint plugins: - plugin:requirejs/recommended, to enforce some conventions in require statements - plugin:node/recommended, to enforce correct usage of various node.js APIs - plugin:unicorn/recommended, which contains a pretty mixed bag of useful rules This PR attempts to not change code behavior when possible. In cases where fixing existing code would change semantics, a linting exclusion has been placed in the code base to silence the error. You can find these by searching for `eslint-disable-next-line`. Co-authored-by: Austin Morton --- lib/compilers/golang.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/compilers/golang.js') diff --git a/lib/compilers/golang.js b/lib/compilers/golang.js index ea9bb6fc5..2f7bc85b7 100644 --- a/lib/compilers/golang.js +++ b/lib/compilers/golang.js @@ -23,7 +23,7 @@ // POSSIBILITY OF SUCH DAMAGE. const BaseCompiler = require('../base-compiler'), - argumentParsers = require("./argument-parsers"), + argumentParsers = require('./argument-parsers'), _ = require('underscore'), utils = require('../utils'); @@ -39,13 +39,13 @@ const jumpPrefixes = [ // s390x 'cmpb', - 'cmpub' + 'cmpub', ]; class GolangCompiler extends BaseCompiler { convertNewGoL(code) { - const re = /^\s+(0[xX]?[0-9A-Za-z]+)?\s?([0-9]+)\s*\(([^:]+):([0-9]+)\)\s*([A-Z]+)(.*)/; - const reUnknown = /^\s+(0[xX]?[0-9A-Za-z]+)?\s?([0-9]+)\s*\(\)\s*([A-Z]+)(.*)/; + const re = /^\s+(0[Xx]?[\dA-Za-z]+)?\s?(\d+)\s*\(([^:]+):(\d+)\)\s*([A-Z]+)(.*)/; + const reUnknown = /^\s+(0[Xx]?[\dA-Za-z]+)?\s?(\d+)\s*\(\)\s*([A-Z]+)(.*)/; const reFunc = /TEXT\s+[".]*(\S+)\(SB\)/; let prevLine = null; let file = null; @@ -83,7 +83,7 @@ class GolangCompiler extends BaseCompiler { match = line.match(reFunc); if (match) { // Normalize function name. - func = match[1].replace(/[.()*]+/g, "_"); + func = match[1].replace(/[()*.]+/g, '_'); // It's possible for normalized function names to collide. // Keep a count of collisions per function name. Labels get @@ -139,12 +139,12 @@ class GolangCompiler extends BaseCompiler { .compact() .filter(line => !unusedLabels[line]) .value() - .join("\n"); + .join('\n'); } replaceJump(func, collisions, ins, args, usedLabels) { // Check if last argument is a decimal number. - const re = /(\s+)([0-9]+)(\s?)$/; + const re = /(\s+)(\d+)(\s?)$/; const match = args.match(re); if (!match) { return args; @@ -156,7 +156,7 @@ class GolangCompiler extends BaseCompiler { if (collisions > 0) { label += `_${collisions}`; } - usedLabels[label + ":"] = true; // record label use for later filtering + usedLabels[label + ':'] = true; // record label use for later filtering return `${match[1]}${label}${match[3]}`; } @@ -180,7 +180,7 @@ class GolangCompiler extends BaseCompiler { result.asm = this.convertNewGoL(out); result.stderr = null; result.stdout = utils.parseOutput(logging, result.inputFilename); - return [result, ""]; + return [result, '']; } optionsForFilter(filters, outputFilename, userOptions) { -- cgit v1.2.3