Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint flag not working with projects generated by create-react-app #88

Closed
gbrlsnchs opened this issue Oct 7, 2019 · 6 comments

Comments

@gbrlsnchs
Copy link

commented Oct 7, 2019

I have checked some closed issues about linting but I really don't understand the flag's purpose. When I run npx prettier-standard --lint <my-file>.js, it formats the file and then outputs All matched files use Standard code style!, although there are unused variables inside such file.

Does it run standard? If so, it's not working, because running npx standard <my-file>.js does detect the unused variable.
So does it only check for formatting issues? If so, why? It should never fail since it formats the file just before checking.

Sorry if I missed anything here.

@sheerun

This comment has been minimized.

Copy link
Owner

commented Oct 7, 2019

Can you paste minimal example file to reproduce? Do you have .eslintrc or .eslintignore file?

It should check for all issues standard is checking for.

@gbrlsnchs

This comment has been minimized.

Copy link
Author

commented Oct 7, 2019

It happens in projects built using create-react-app. I have created a test project by running npx create-react-app prettier-standard-react-bug and then installed prettier-standard by running yarn add -D prettier-standard.

Then, I ran npx prettier-standard --lint src/index.js (src/index.js is generated by create-react-app) and it passed linting, which was expected and correct.

Then I added an unused variable to that same file and ran again npx prettier-standard --lint src/index.js, which passed again, this time erroneously.

Here's the package.json content:

{
  "name": "prettier-standard-react-bug",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.10.2",
    "react-dom": "^16.10.2",
    "react-scripts": "3.2.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "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": {
    "prettier-standard": "^15.0.1"
  }
}

Everything in it is generated by create-react-app expect for the devDependencies, which I added myself to test all of this.

I tested the same steps in a regular Node project with only prettier-standard and nothing else installed and it correctly detected the unused variable. Something tells me that eslintConfig is the culprit for React projects generated by create-react-app.

@gbrlsnchs gbrlsnchs changed the title What does --lint do? lint flag not working with projects generated by create-react-app Oct 7, 2019
@sheerun

This comment has been minimized.

Copy link
Owner

commented Oct 8, 2019

prettier-standard allows for overridding eslint configuration

Please remove eslintConfig from your package.json to have pure standard configuration

@gbrlsnchs

This comment has been minimized.

Copy link
Author

commented Oct 10, 2019

Does prettier-standard follow eslintConfig? If so, then I shall close this issue, since that's what I expect from this package.

@sheerun

This comment has been minimized.

Copy link
Owner

commented Oct 11, 2019

yes

@gbrlsnchs

This comment has been minimized.

Copy link
Author

commented Oct 11, 2019

Okay, thanks!

@gbrlsnchs gbrlsnchs closed this Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.