import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

🐞: [import/newline-after-import] Cannot recoginize the last require when use import and require in the same file #3059

Closed justYu2001 closed 2 months ago

justYu2001 commented 2 months ago

Example

import moment from "moment";
import utils from "@/utils" // ESLint say I should have a newline after this line
const dataJson = require("./data.json");

// code...

My ESLint Setting

{
  "import/order":[
    "error",
    {
      "newlines-between":"never",
      "alphabetize":{
        "order":"asc",
        "caseInsensitive":true
      }
    }
  ],
  "import/newline-after-import":"error"
}

Package version

Screenshot

ζˆͺεœ– 2024-09-11 δΈ‹εˆ5 26 55 ζˆͺεœ– 2024-09-11 δΈ‹εˆ5 28 10
ljharb commented 2 months ago

You can't require and import in the same file.

ljharb commented 2 months ago

Also, eslint 6 is very out of date; you should be on eslint 8.

justYu2001 commented 2 months ago

Yeah, you are right. I should replace require() with import. Thanks for your help. πŸ‘