Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

.eslintrc does not seem to be reloaded #42

Closed
janrop opened this issue May 4, 2020 · 5 comments
Closed

.eslintrc does not seem to be reloaded #42

janrop opened this issue May 4, 2020 · 5 comments
Assignees

Comments

@janrop
Copy link

janrop commented May 4, 2020

Hi,

for some reason I still get

propType "onChange" is not required, but has no corresponding defaultProps declaration react/require-default-props

after adding "react/require-default-props": 0 to the .eslintrc rules section.

Restarting the bundler does not help.

Is there any config of my ide that could be messing this up? I am using VS Code but already tried disabling their eslint plugin.

Something similarly annoying happens when 'import/no-unresolved' prevents the app from building, because it cannot find an index.js file that is clearly where it should be.

Any ideas how to debug this?

Thanks a lot.

@morewings morewings self-assigned this May 5, 2020
@morewings
Copy link
Owner

morewings commented May 5, 2020

I did check "react/require-default-props": 0 case just now. And "it works on my machine"™. But I'm using Webstorm.
Can you share full eslint config and yarn lint:js command output?

Something similarly annoying happens when 'import/no-unresolved' prevents the app from building, because it cannot find an index.js file that is clearly where it should be.

I had similar errors many times in different projects. Seems like it's webpack bug. Do you have watchman installed?

@janrop
Copy link
Author

janrop commented May 5, 2020

.eslintrc

{
  "extends": [
    "airbnb",
    "react-app",
    "prettier",
    "prettier/flowtype",
    "prettier/react"
  ],
  "rules": {
    // Allow jsx tags inside .js files.
    "react/jsx-filename-extension": [1, {"extensions": [".js", ".jsx"]}],
    "import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.ts", "**/*.test.tsx", "**/*.stories.js"]}],
    // Disable props spreading (<App {...props} />) warning.
    "react/jsx-props-no-spreading": 0,
    "react/forbid-prop-types": 0,
    // Throw warning instead of error when using array index as a key.
    "react/no-array-index-key": 1,
    // Allow modules with named exports only.
    "import/prefer-default-export": 0,
    // Force {foo: 'bar'} object literal syntax.
    "object-curly-spacing": ["error", "never"],
    // Throw warning instead of error. Feel free to choose your favorite option https://eslint.org/docs/rules/arrow-body-style
    "arrow-body-style": ["warn", "as-needed"],
    // Make prettier code formatting suggestions more verbose.
    "prettier/prettier": ["warn"],
    // Throw warning when <a href="#"> or <a href="javascript:void(0)"> are used. Use <button> instead.
    "jsx-a11y/anchor-is-valid": ["warn", {"aspects": ["invalidHref"]}],
    // Allow using (props) => <Component /> and ({propName}) => <Component /> syntax.
    "react/destructuring-assignment": "off",
    // Disable <Fragment> => <> replacement. Feel free to change
    "react/jsx-fragments": "off",
    // Below is the set of functional rules to warn developer about accidental mutations, which may cause error in reducers etc.
    // No delete operator.
    "fp/no-delete": "warn",
    // Warning when Object.assign(a, b) used, since it mutates first argument. Object.assign({}, a, b) is ok.
    "fp/no-mutating-assign": "warn",
    // Warning when mutating method (pop, push, reverse, shift, sort, splice, unshift, etc) is used. Ramda and lodash/fp are allowed (_.pop, R.push)
    "fp/no-mutating-methods": [
      "warn",
      {
        "allowedObjects": ["_", "R"]
      }
    ],
    // Warning when mutating operators (++, --, etc) are used, object = {} also. `Component.propTypes`, `Component.defaultProps`, common.js (`module.exports`) and `ref.current` are ok.
    "fp/no-mutation": [
      "warn",
      {
        "commonjs": true,
        "allowThis": true,
        "exceptions": [{"property": "propTypes"}, {"property": "defaultProps"}, {"property": "current"}]
      }
    ],
    "import/no-unresolved": "off",
    "react/require-default-props": 0
  },
  "plugins": ["prettier", "fp"],
  "settings": {
    "import/resolver": {
      "node": {
        "moduleDirectory": ["node_modules", "./src"]
      }
    }
  },
  "overrides": [
    {
      "files": [ "./*.js"],
      "rules": {
        "global-require": 0
      }
    },
    {
      "files": ["**/*.spec.js"],
      "rules": {
        "react/prop-types": "off"
      }
    }
  ]
}

yarn lint:js

yarn run v1.22.4
$ npx eslint ./src/

/Users/janropertz/projects/mediploy/backend-ui/src/screens/DrillScreen/DrillScreen.js
   2:16  warning  'useState' is defined but never used                  no-unused-vars
  12:9   warning  'drillCategories' is assigned a value but never used  no-unused-vars
  29:3   warning  Unexpected console statement                          no-console

✖ 3 problems (0 errors, 3 warnings)

✨  Done in 2.94s.

yarn start

Failed to compile.

./src/screens/DrillScreen/DrillForm.js
  Line 29:3:  propType "onChange" is not required, but has no corresponding defaultProps declaration  react/require-default-props

Search for the keywords to learn more about each error.

Do you have watchman installed?

I guess not. Should I try that?

@morewings
Copy link
Owner

morewings commented May 6, 2020

I guess not. Should I try that?

Yes. It may help.

@janrop
Copy link
Author

janrop commented May 6, 2020

Ok. I don't know if it was installing watchman or deleting node_modules and yarn, yarn starting again. But now it renders again 🤷‍♂️

Thanks für the suggestions.

@janrop janrop closed this as completed May 6, 2020
@morewings
Copy link
Owner

You are welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants