diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 852cab8..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,262 +0,0 @@ -'use strict'; - -module.exports = { - root: true, - - // https://github.com/sindresorhus/globals/blob/master/globals.json - env: { - es6: true, - node: true, - }, - - rules: { - // Possible Errors (http://eslint.org/docs/rules/#possible-errors) - 'no-await-in-loop': 1, - 'no-cond-assign': 1, - 'no-console': 1, - 'no-constant-condition': [1, {checkLoops: false}], - 'no-control-regex': 0, - 'no-debugger': 1, - 'no-dupe-args': 1, - 'no-dupe-keys': 1, - 'no-duplicate-case': 1, - 'no-empty-character-class': 1, - 'no-empty': [1, {allowEmptyCatch: true}], - 'no-ex-assign': 1, - 'no-extra-boolean-cast': 1, - 'no-extra-parens': 0, - 'no-extra-semi': 1, - 'no-func-assign': 1, - 'no-inner-declarations': 1, - 'no-invalid-regexp': 1, - 'no-irregular-whitespace': 1, - 'no-obj-calls': 1, - 'no-prototype-builtins': 0, - 'no-regex-spaces': 1, - 'no-sparse-arrays': 1, - 'no-template-curly-in-string': 0, - 'no-unexpected-multiline': 1, - 'no-unreachable': 1, - 'no-unsafe-finally': 1, - 'no-unsafe-negation': 1, - 'use-isnan': 1, - 'valid-jsdoc': 0, - 'valid-typeof': 1, - - // Best Practices (http://eslint.org/docs/rules/#best-practices) - 'accessor-pairs': 1, - 'array-callback-return': 0, - 'block-scoped-var': 0, - 'class-methods-use-this': 0, - 'complexity': 0, - 'consistent-return': 0, - 'curly': 0, - 'default-case': 0, - 'dot-location': [1, 'property'], - 'dot-notation': 1, - 'eqeqeq': [1, 'allow-null'], - 'guard-for-in': 0, - 'no-alert': 1, - 'no-caller': 1, - 'no-case-declarations': 0, - 'no-div-regex': 1, - 'no-else-return': 0, - 'no-empty-function': 0, - 'no-empty-pattern': 1, - 'no-eq-null': 0, - 'no-eval': 1, - 'no-extend-native': 1, - 'no-extra-bind': 1, - 'no-extra-label': 1, - 'no-fallthrough': 1, - 'no-floating-decimal': 1, - 'no-global-assign': 1, - 'no-implicit-coercion': 0, - 'no-implicit-globals': 0, - 'no-implied-eval': 1, - 'no-invalid-this': 0, - 'no-iterator': 1, - 'no-labels': 1, - 'no-lone-blocks': 1, - 'no-loop-func': 0, - 'no-magic-numbers': 0, - 'no-multi-spaces': 1, - 'no-multi-str': 0, - 'no-new-func': 1, - 'no-new-wrappers': 1, - 'no-new': 1, - 'no-octal-escape': 1, - 'no-octal': 1, - 'no-param-reassign': 0, - 'no-proto': 1, - 'no-redeclare': [1, {builtinGlobals: true}], - 'no-restricted-properties': 0, - 'no-return-assign': 1, - 'no-return-await': 1, - 'no-script-url': 1, - 'no-self-assign': 1, - 'no-self-compare': 1, - 'no-sequences': 1, - 'no-throw-literal': 1, - 'no-unmodified-loop-condition': 0, - 'no-unused-expressions': 0, - 'no-unused-labels': 1, - 'no-useless-call': 1, - 'no-useless-concat': 1, - 'no-useless-escape': 0, - 'no-useless-return': 0, - 'no-void': 1, - 'no-warning-comments': 0, - 'no-with': 1, - 'radix': 1, - 'require-await': 0, - // 'require-await': 1, - 'vars-on-top': 0, - 'wrap-iife': [1, 'inside'], - 'yoda': 1, - - // Strict Mode (http://eslint.org/docs/rules/#strict-mode) - 'strict': 0, - - // Variables (http://eslint.org/docs/rules/#variables) - 'init-declarations': 0, - 'no-catch-shadow': 1, - 'no-delete-var': 1, - 'no-label-var': 1, - 'no-restricted-globals': 0, - 'no-shadow-restricted-names': 1, - 'no-shadow': 1, - 'no-undef-init': 0, - 'no-undef': 1, - 'no-undefined': 0, - 'no-unused-vars': [1, {args: 'none'}], - 'no-use-before-define': 0, - - // Node.js and CommonJS (http://eslint.org/docs/rules/#nodejs-and-commonjs) - 'callback-return': 0, - 'global-require': 0, - 'handle-callback-err': 1, - 'no-mixed-requires': 1, - 'no-new-require': 1, - 'no-path-concat': 1, - 'no-process-env': 0, - 'no-process-exit': 0, - 'no-restricted-modules': 0, - 'no-sync': 0, - - // Stylistic Issues (http://eslint.org/docs/rules/#stylistic-issues) - 'array-bracket-spacing': 1, - 'block-spacing': 1, - 'brace-style': [1, '1tbs', {allowSingleLine: true}], - 'camelcase': 0, - 'capitalized-comments': 0, - 'comma-dangle': [1, {arrays: 'always-multiline', objects: 'always-multiline', imports: 'always-multiline', exports: 'always-multiline'}], - 'comma-spacing': 1, - 'comma-style': 1, - 'computed-property-spacing': 1, - 'consistent-this': 0, - 'eol-last': 1, - 'func-call-spacing': 1, - 'func-name-matching': 0, - 'func-names': 0, - 'func-style': 0, - 'id-blacklist': 0, - 'id-length': 0, - 'id-match': 0, - 'indent': [1, 2, {SwitchCase: 1}], - 'jsx-quotes': [1, 'prefer-double'], - 'key-spacing': [1, {beforeColon: false, afterColon: true}], - 'keyword-spacing': 1, - 'line-comment-position': 0, - 'linebreak-style': 1, - 'lines-around-comment': 0, - 'lines-around-directive': 0, - 'max-depth': 0, - 'max-len': 0, - 'max-lines': 0, - 'max-nested-callbacks': 0, - 'max-params': 0, - 'max-statements-per-line': 0, - 'max-statements': 0, - 'multiline-ternary': 0, - 'new-cap': 0, - 'new-parens': 1, - 'newline-after-var': 0, - 'newline-before-return': 0, - 'newline-per-chained-call': 0, - 'no-array-constructor': 1, - 'no-bitwise': 0, - 'no-continue': 0, - 'no-inline-comments': 0, - 'no-lonely-if': 0, - 'no-mixed-operators': 0, - 'no-mixed-spaces-and-tabs': 1, - 'no-multiple-empty-lines': [1, {max: 2, maxBOF: 0, maxEOF: 1}], - 'no-negated-condition': 0, - 'no-nested-ternary': 0, - 'no-new-object': 1, - 'no-plusplus': 0, - 'no-restricted-syntax': 0, - 'no-tabs': 1, - 'no-ternary': 0, - 'no-trailing-spaces': 1, - 'no-underscore-dangle': 0, - 'no-unneeded-ternary': 0, - 'no-whitespace-before-property': 1, - 'object-curly-newline': 0, - 'object-curly-spacing': 1, - 'object-property-newline': 0, - 'one-var-declaration-per-line': 0, - 'one-var': [1, 'never'], - 'operator-assignment': 1, - 'operator-linebreak': 0, - 'padded-blocks': [1, {blocks: 'never', classes: 'never', switches: 'never'}], - 'quote-props': [1, 'consistent-as-needed'], - 'quotes': [1, 'single', 'avoid-escape'], - 'require-jsdoc': 0, - 'semi-spacing': 1, - 'semi': 1, - 'sort-keys': 0, - 'sort-vars': 0, - 'space-before-blocks': 1, - 'space-before-function-paren': [1, {anonymous: 'never', named: 'never', asyncArrow: 'always'}], - 'space-in-parens': [1, 'never'], - 'space-infix-ops': 1, - 'space-unary-ops': 1, - 'spaced-comment': 0, - 'unicode-bom': [1, 'never'], - 'wrap-regex': 0, - - // ECMAScript 6 (http://eslint.org/docs/rules/#ecmascript-6) - 'arrow-body-style': 0, - 'arrow-parens': [1, 'as-needed'], - 'arrow-spacing': 1, - 'constructor-super': 1, - 'generator-star-spacing': 1, - 'no-class-assign': 1, - 'no-confusing-arrow': [1, {allowParens: true}], - 'no-const-assign': 1, - 'no-dupe-class-members': 1, - 'no-duplicate-imports': 0, - 'no-new-symbol': 1, - 'no-restricted-imports': 0, - 'no-this-before-super': 1, - 'no-useless-computed-key': 1, - 'no-useless-constructor': 0, - 'no-useless-rename': 1, - 'no-var': 0, - 'object-shorthand': 0, - 'prefer-arrow-callback': [1, {allowNamedFunctions: true}], - 'prefer-const': 1, - 'prefer-numeric-literals': 0, - 'prefer-rest-params': 0, - 'prefer-spread': 1, - 'prefer-template': 0, - 'require-yield': 0, - 'rest-spread-spacing': 1, - 'sort-imports': 0, - 'symbol-description': 1, - 'template-curly-spacing': 1, - 'yield-star-spacing': 1, - }, -}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..88a36c3 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "root": true, + "parserOptions": { + "ecmaVersion": 6 + }, + "env": { + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "rules": { + "strict": "warn" + } +} diff --git a/bench/_measure.js b/bench/_measure.js index e38d582..7db2b76 100644 --- a/bench/_measure.js +++ b/bench/_measure.js @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ 'use strict'; module.exports = (name, withCache, callback) => { diff --git a/package.json b/package.json index 5c25538..19ab4e6 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dependencies": {}, "devDependencies": { "babel-core": "6.26.3", - "eslint": "^3.15.0", + "eslint": "^7.12.1", "flow-parser": "0.136.0", "rimraf": "^2.5.4", "rxjs": "6.6.3", diff --git a/test/slashEscape-test.js b/test/slashEscape-test.js index 644104a..46a2402 100644 --- a/test/slashEscape-test.js +++ b/test/slashEscape-test.js @@ -13,8 +13,7 @@ var escapes = { }; tap.test('escape', t => { - for (var key in escapes) { - if (!escapes.hasOwnProperty(key)) continue; + for (const key of Object.keys(escapes)) { t.equal( slashEscape(key), escapes[key] diff --git a/v8-compile-cache.js b/v8-compile-cache.js index 69f0536..4376b1b 100644 --- a/v8-compile-cache.js +++ b/v8-compile-cache.js @@ -86,8 +86,6 @@ class FileSystemBlobStore { try { fs.writeFileSync(this._blobFilename, blobToStore); fs.writeFileSync(this._mapFilename, mapToStore); - } catch (error) { - throw error; } finally { fs.unlinkSync(this._lockFilename); } @@ -301,7 +299,8 @@ function slashEscape(str) { '\x00': 'z0', 'z': 'zZ', }; - return str.replace(/[\\:\/\x00z]/g, match => (ESCAPE_LOOKUP[match])); + const ESCAPE_REGEX = /[\\:/\x00z]/g; // eslint-disable-line no-control-regex + return str.replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]); } function supportsCachedData() { @@ -348,7 +347,7 @@ if (!process.env.DISABLE_V8_COMPILE_CACHE && supportsCachedData()) { nativeCompileCache.setCacheStore(blobStore); nativeCompileCache.install(); - process.once('exit', code => { + process.once('exit', () => { if (blobStore.isDirty()) { blobStore.save(); }