nuxt / eslint

Collection of ESLint-related packages for Nuxt
https://eslint.nuxt.com
MIT License
535 stars 65 forks source link

Specifying Globals is not working #90

Closed reginna-chao closed 6 months ago

reginna-chao commented 4 years ago

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

manniL commented 4 years ago
globals: {
        TweenMax: 'readonly',
        TimelineLite: 'readonly'
    }

PS: there is an NPM module for GSAP

reginna-chao commented 4 years ago

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.

KareemDa commented 2 years ago

Any updates on this issue?

antfu commented 6 months ago

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