babel / babel-eslint

:tokyo_tower: A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)
https://github.com/babel/babel/tree/main/eslint/babel-eslint-parser
MIT License
2.96k stars 239 forks source link

Disabling eslint on file does not work #821

Closed ramako closed 4 years ago

ramako commented 4 years ago

Hello, using : "@babel/cli": "^7.8.4", "@babel/core": "^7.8.6", "@babel/polyfill": "^7.8.3", "@babel/preset-env": "^7.8.6", "babel-eslint": "^10.1.0", "babel-loader": "^8.0.0", "eslint": "6.8.0",

, I am getting this error: 6:25 error Parsing error: Identifier 'Platform' has already been declared.

I am basically doing this, using webpack preprocessor

/ eslint-disable no-redeclare / / #!if PLATFORM === 'test / import { test Platform } from './js/libs/platforms'; // #!elseif PLATFORM === 'test2' import { test2 as Platform } from './js/libs/platforms'; // #!elseif PLATFORM === 'test3' import { test3 as Platform } from './js/libs/platforms'; // #!else import { test4 as Platform } from './js/libs/platforms'; / #!endif / / eslint-enable no-redeclare /

This used to work in previous version (babel 6.X ). nothing has been modified in this file. This has happened as I updated babel to the newest version.

If I add the file to the eslintignore, it works. I am not sure what is going on, I have spent hours checking the web, but can't seem to find the solution.

kaicataldo commented 4 years ago

import identifiers have to be unique., so this is a syntax error. ESLint can only run rules after a successful parse, so ESLint isn't even running in the rule in this case.

kaicataldo commented 4 years ago

Thank you for the PR. Now that @babel/eslint-parser has been released, we are making this repository read-only. If this is a change you would still like to advocate for, please reopen this in the babel/babel monorepo.