diff options
author | Rubén Rincón Blanco <ruben@rinconblanco.es> | 2020-08-04 22:39:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-04 16:39:02 -0400 |
commit | ccff4b9ee5a37c13f0973b52e8f90a8be8359fea (patch) | |
tree | 0022c9364824c5b4e4f5818c4abbf654aa99f2e8 /lib/compilers/nim.js | |
parent | 7126b39a6bdeabffc312c8a117ec7af072ef6a1c (diff) | |
download | compiler-explorer-ccff4b9ee5a37c13f0973b52e8f90a8be8359fea.tar.gz compiler-explorer-ccff4b9ee5a37c13f0973b52e8f90a8be8359fea.zip |
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 <austinpmorton@gmail.com>
Diffstat (limited to 'lib/compilers/nim.js')
-rw-r--r-- | lib/compilers/nim.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/compilers/nim.js b/lib/compilers/nim.js index de920d9d7..26a7ff482 100644 --- a/lib/compilers/nim.js +++ b/lib/compilers/nim.js @@ -25,15 +25,15 @@ const BaseCompiler = require('../base-compiler'), _ = require('underscore'), path = require('path'), - argumentParsers = require("./argument-parsers"), + argumentParsers = require('./argument-parsers'), fs = require('fs-extra'); const NimCommands = [ - "compile", "compileToC", "c", - "compileToCpp", "cpp", "cc", - "compileToOC", "objc", - "js", - "check" + 'compile', 'compileToC', 'c', + 'compileToCpp', 'cpp', 'cc', + 'compileToOC', 'objc', + 'js', + 'check', ]; class NimCompiler extends BaseCompiler { @@ -48,25 +48,25 @@ class NimCompiler extends BaseCompiler { optionsForFilter(filters, outputFilename) { return [ - "-o:" + outputFilename, //output file, only for js mode - "--nolinking", //disable linking, only compile to nimcache - "--nimcache:" + this.cacheDir(outputFilename) //output folder for the nimcache + '-o:' + outputFilename, //output file, only for js mode + '--nolinking', //disable linking, only compile to nimcache + '--nimcache:' + this.cacheDir(outputFilename), //output folder for the nimcache ]; } filterUserOptions(userOptions) { //If none of the allowed commands is present in userOptions add 'compile' command if (_.intersection(userOptions, NimCommands).length === 0) { - userOptions.unshift("compile"); + userOptions.unshift('compile'); } return userOptions.filter(option => !['--run', '-r'].includes(option)); } expectedExtensionFromCommand(command) { - const isC = ["compile", "compileToC", "c"], - isCpp = ["compileToCpp", "cpp", "cc"], - isObjC = ["compileToOC", "objc"]; + const isC = ['compile', 'compileToC', 'c'], + isCpp = ['compileToCpp', 'cpp', 'cc'], + isObjC = ['compileToOC', 'objc']; if (isC.includes(command)) return '.c.o'; @@ -80,7 +80,7 @@ class NimCompiler extends BaseCompiler { getCacheFile(options, inputFilename, cacheDir) { const commandsInOptions = _.intersection(options, NimCommands); - if (!commandsInOptions.length) + if (commandsInOptions.length === 0) return null; const command = commandsInOptions[0]; const extension = this.expectedExtensionFromCommand(command); @@ -95,7 +95,7 @@ class NimCompiler extends BaseCompiler { const options = result.compilationOptions; const cacheDir = this.cacheDir(outputFilename); try { - if (_.intersection(options, ["js", "check"]).length) + if (_.intersection(options, ['js', 'check']).length > 0) filters.binary = false; else { filters.binary = true; |