Giter Club home page Giter Club logo

Comments (10)

Eugleo avatar Eugleo commented on May 27, 2024 1

Wow, that was fast. All works well with the latest update, thank you<. Just to be sure, when'd like to disable import/no-namespace, for example, in all files, I can simply have

module.exports = {
  extends: 'galex',
  rules: {
    'import/no-namespace': 0,
  },
};

Is that right? And the overrides are needed only when I'd like to cherrypick in which files the rule gets enforced.

from eslint-config-galex.

Eugleo avatar Eugleo commented on May 27, 2024 1

It didn't! The other errors had gone away.

from eslint-config-galex.

ljosberinn avatar ljosberinn commented on May 27, 2024

Hi, do you possibly have @typescript-eslint/eslint-plugin installed separately? eslint-config-galex tries to pull in 4.1.0 currently.

from eslint-config-galex.

Eugleo avatar Eugleo commented on May 27, 2024

I don't think so. But I created the app with create-react-app, so maybe they're pulling it? My package.json is:

{
  "name": "request2",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@bigheads/core": "file:bigheads/bigheads-core-v0.2.0.tgz",
    "@rpldy/chunked-uploady": "^0.4.1",
    "@rpldy/upload-button": "^0.4.1",
    "@rpldy/upload-drop-zone": "^0.4.1",
    "@rpldy/uploady": "^0.4.1",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "classnames": "^2.2.6",
    "feather-icons": "^4.28.0",
    "formik": "^2.1.5",
    "history": "^5.0.0",
    "jsonschema": "^1.2.6",
    "moment": "^2.27.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-epic-spinners": "^0.4.1",
    "react-feather": "^2.0.8",
    "react-is": "^16.13.1",
    "react-markdown": "^4.3.1",
    "react-router": "^6.0.0-beta.0",
    "react-router-dom": "^6.0.0-beta.0",
    "react-scripts": "3.4.1",
    "react-select": "^3.1.0",
    "react-tooltip": "^4.2.6"
  },
  "scripts": {
    "start": "npm run watch:css && BROWSER=none react-scripts start",
    "build": "npm run build:css && react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:css": "postcss src/styles/index.css -o src/styles/tailwind.css",
    "watch:css": "postcss src/styles/index.css -o src/styles/tailwind.css"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@testing-library/dom": "^7.21.4",
    "@types/classnames": "^2.2.10",
    "@types/jest": "^26.0.8",
    "@types/node": "^14.6.4",
    "@types/react": "^16.9.43",
    "@types/react-dom": "^16.9.8",
    "@types/react-select": "^3.0.15",
    "@types/webpack-env": "^1.15.2",
    "autoprefixer": "^9.7.6",
    "eslint-config-galex": "^2.2.2",
    "postcss-cli": "^7.1.1",
    "prettier": "^2.0.5",
    "tailwindcss": "^1.4.6",
    "typescript": "^3.9.7"
  }
}

from eslint-config-galex.

ljosberinn avatar ljosberinn commented on May 27, 2024

Ah, yes, create-react-app pulls in eslint-config-react-app which has outdated dependencies. Sorry for the convenience, I tested with CRA but not with the TS template. I'll fix this asap!

from eslint-config-galex.

Eugleo avatar Eugleo commented on May 27, 2024

Thanks! I was just about to comment that even removing the eslintConfig: "..." from package.json and reinstalling all packages didn't help. Glad it sorted itself out.

EDIT: Anything I can do on my end in the meantime?

from eslint-config-galex.

ljosberinn avatar ljosberinn commented on May 27, 2024

I've published a fix in v2.2.3 and written a custom override for your situation:

// .eslintrc.js

// createConfig will detect your projects dependencies
const { createConfig } = require("eslint-config-galex/src/createConfig");
// however, you need a custom override to access the typescript override sanely
// (the alternative way would rely on the order of overrides in the array which is a bad idea)
const {
  createTSOverride,
} = require("eslint-config-galex/src/overrides/typescript");
const packageJson = require("./package.json");

// since `createTSOverride` is entirely configurable, we need to inform it about its environment
const tsOverrideConfig = {
  react: {
    hasReact: true,
    isCreateReactApp: true,
  },
  rules: {
    "@typescript-eslint/ban-ts-comment": "off",
  },
  typescript: {
    hasTypeScript: true,
    // sync with package.json should you upgrade TS to e.g. 4.0.2
    version: packageJson.dependencies.typescript,
  },
};

// solely an override for TS
const tsOverride = createTSOverride(tsOverrideConfig);

// pass it into createConfig as array as it will be merged with the other overrides
module.exports = createConfig({ overrides: [tsOverride] });

Works for me locally, please let me know if it resolves the issue :)

Edit: as a sidenote: I understand this seems to be a lot of code to able to disable a single rule here now. However, it's required to allow adding/removing rules based on file name patterns. Without overrides, there wouldn't be a possibility to lint tests or TS files differently than plain JS files.

from eslint-config-galex.

Eugleo avatar Eugleo commented on May 27, 2024

One last thing, I'm getting some warnings about missing rules:

Definition for rule '@typescript-eslint/consistent-type-imports' was not found.eslint(@typescript-eslint/consistent-type-imports)

Definition for rule 'no-promise-executor-return' was not found.eslint(no-promise-executor-return)

Definition for rule 'no-useless-backreference' was not found.eslint(no-useless-backreference)

Definition for rule 'default-case-last' was not found.eslint(default-case-last)

I think that those might be caused by an outdated eslint (CRA's default seems to be v6.8.0) — is there anyting I can do about this? E.g. manually override CRA's eslint with a newer version?

from eslint-config-galex.

ljosberinn avatar ljosberinn commented on May 27, 2024

ah youre missing eslint as dev dependency as noted in the docs :) CRA here too is pulling in an (heavily) outdated version.

npm install --save-dev eslint
yarn add -D eslint

will fix that.

edit: @typescript-eslint/consistent-type-imports is an odd one though; I've found more than ban-ts-comment which aren't supported by CRA, but this one was not included. Please let me know if installing eslint solves that too.

re:

module.exports = {
  extends: 'galex',
  rules: {
    'import/no-namespace': 0,
  },
};

yes, global rules can be disabled that way. overrides that only apply to a subset of files need to be created manually.

beginning here, you can see a snapshot of all globally defined rules

from eslint-config-galex.

ljosberinn avatar ljosberinn commented on May 27, 2024

FYI @Eugleo I found out today that CRA with TypeScript sadly uses the internally installed version of @typescript-eslint/parser and @typescript-eslint/eslint-plugin. So if you want to use tuples, you'll have to install those separately.

I added a note for that to the readme too. Kinda annoying how massively outdated CRA is here...

from eslint-config-galex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.