eslint icon indicating copy to clipboard operation
eslint copied to clipboard

Specifying Globals is not working

Open reginna-chao opened this issue 5 years ago • 3 comments

I want to set Specifying Globals in .eslintrc.js file, but it is not working. Specifying Globals - ESLint document: https://eslint.org/docs/user-guide/configuring#specifying-globals

This is my setting:

// .eslintrc.js
module.exports = {
	root: true,
	env: {
		browser: true,
		node: true
	},
	parserOptions: {
		parser: 'babel-eslint'
	},
	extends: [
		'@nuxtjs',
		'plugin:nuxt/recommended'
	],
	// add your custom rules here
	rules: {
		semi: [2, 'never'],
		'indent': [2, 'tab'],
		'no-tabs': 0,
		'no-console': 'off',
		'vue/max-attributes-per-line': 'off'
	},
	globals: {
		TweenMax: false,
		TimelineLite: false
	}
}

When I use them in .vue file, example:

console.log(TweenMax)

And always show error:

error  'TweenMax' is not defined  no-undef

How should I do?


Package version: nuxt: 2.11.0 @nuxtjs/eslint-config: 1.1.2 @nuxtjs/eslint-module: 1.1.0

reginna-chao avatar Apr 23 '20 04:04 reginna-chao

globals: {
		TweenMax: 'readonly',
		TimelineLite: 'readonly'
	}

PS: there is an NPM module for GSAP

TheAlexLichter avatar Apr 23 '20 15:04 TheAlexLichter

Yes, I know that. I want to use GSAP CDN, and I import it use global setting in nuxt.config.js head.script.

When I use plugin in every *.vue file, I use comment to resolve error, like this:

// eslint-disable-next-line no-undef
const tl1 = new TimelineLite()

// eslint-disable-next-line no-undef
TweenMax.to(...) 

It is not convenient.

reginna-chao avatar Apr 24 '20 03:04 reginna-chao

Any updates on this issue?

KareemDa avatar Feb 09 '22 14:02 KareemDa

I believe this is not an issue of Nuxt's config, but more like a ESLint config question - and solution is already answered in https://github.com/nuxt/eslint/issues/90#issuecomment-618463677

antfu avatar Mar 19 '24 13:03 antfu