Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Imports should be sorted alphabetically error

Tags:

node.js

eslint

I have the following imports in my file:

import axios from "axios";
import lodash from "lodash";
import PropTypes from "prop-types";
import React from "react";
import renderInCustomHtmlTag from "react-render-custom-html-tag";

I am using v5.9.0 however for some reason I am getting an error for line 3 even though it appears to be alphabetical order.

My eslint is as follows:

{
  "env": {
    "browser": true,
    "commonjs": true,
    "es6" : true,
    "jquery": true,
    "node": true
  },
  "extends": [
    "eslint:all",
    "plugin:react/recommended"
  ],
  "globals": {
    "$cgx": true
  },
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "sourceType": "module"
  },
  "plugins": [
    "import",
    "jsx-a11y",
    "react"

  ],
  "rules": {
    "indent": ["error", 2],
    "max-len": [
      "error",
      {
        "code": 120
      }
    ]
  }
}
like image 493
jdfolino Avatar asked Oct 20 '25 08:10

jdfolino


1 Answers

The issue is probably the capital letters. It seems to be because they have a lower ASCII value A = 65, a = 97.

https://eslint.org/docs/latest/rules/sort-imports

like image 105
Silvio Guiso Avatar answered Oct 22 '25 00:10

Silvio Guiso