From 6cfbc2653a5ca7c9e2f5304903eda1b806ceee1b Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Fri, 7 Jan 2022 18:15:48 +0100 Subject: [PATCH] Use eslint-env "shared-node-browser" for shared handlebars code --- lib/.eslintrc.js | 6 ++++-- lib/handlebars/compiler/code-gen.js | 4 ++-- lib/handlebars/no-conflict.js | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/.eslintrc.js b/lib/.eslintrc.js index dd1334d4..812b8a27 100644 --- a/lib/.eslintrc.js +++ b/lib/.eslintrc.js @@ -1,6 +1,8 @@ module.exports = { env: { - // Handlebars should run natively in the browser - node: false + // Handlebars not use node or browser-specific apis + 'shared-node-browser': true, + node: false, + browser: false } }; diff --git a/lib/handlebars/compiler/code-gen.js b/lib/handlebars/compiler/code-gen.js index 9feb6109..0ac38990 100644 --- a/lib/handlebars/compiler/code-gen.js +++ b/lib/handlebars/compiler/code-gen.js @@ -1,4 +1,4 @@ -/* global define */ +/* global define, require */ import { isArray } from '../utils'; let SourceNode; @@ -8,7 +8,7 @@ try { if (typeof define !== 'function' || !define.amd) { // We don't support this in AMD environments. For these environments, we assume that // they are running on the browser and thus have no need for the source-map library. - let SourceMap = require('source-map'); // eslint-disable-line no-undef + let SourceMap = require('source-map'); SourceNode = SourceMap.SourceNode; } } catch (err) { diff --git a/lib/handlebars/no-conflict.js b/lib/handlebars/no-conflict.js index 5a6db3e9..f89e7aa9 100644 --- a/lib/handlebars/no-conflict.js +++ b/lib/handlebars/no-conflict.js @@ -1,6 +1,7 @@ +/* global global, window */ export default function(Handlebars) { /* istanbul ignore next */ - let root = typeof global !== 'undefined' ? global : window, // eslint-disable-line no-undef + let root = typeof global !== 'undefined' ? global : window, $Handlebars = root.Handlebars; /* istanbul ignore next */ Handlebars.noConflict = function() {