Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 21:22
    ljharb commented #9259
  • 21:18
    anikethsaha commented #9259
  • 20:43
    anikethsaha commented #13107
  • 20:27
    ljharb commented #9259
  • 20:27
    kaicataldo labeled #13115
  • 20:27
    kaicataldo labeled #13115
  • 20:27
    kaicataldo unlabeled #13115
  • 20:27
    kaicataldo labeled #13115
  • 20:26
    kaicataldo commented #13119
  • 20:19
    kaicataldo commented #13062
  • 20:19
    kaicataldo unlabeled #13062
  • 20:18
    kaicataldo commented #12222
  • 20:18
    kaicataldo unlabeled #12222
  • 20:16
    kaicataldo commented #13107
  • 20:09
    kaicataldo closed #13118
  • 20:09
    kaicataldo commented #13118
  • 20:09
    kaicataldo labeled #13118
  • 20:09
    kaicataldo unlabeled #13118
  • 20:09
    kaicataldo unlabeled #13118
  • 20:09
    kaicataldo commented #13118
Hafez
@AbdelrahmanHafez
Is there a rule to enforce consistent spacing after if statement parens without curly braces?

if (something) doStuff();
if (something)doStuff();

Can't find a rule regarding that

Jordan Harband
@ljharb
you should be forcing curly braces on that condition body
Hafez
@AbdelrahmanHafez
I don't want to enforce curly braces, but when someone chooses not to use curly braces, I want the spacing to be consistent
Jordan Harband
@ljharb
you definitely do want that; lacking the curly braces has caused major bugs, like that massive openssl security bug a few years back
there's no good reason to omit them.
Kevin Partington
@platinumazure
@AbdelrahmanHafez I can't think of anything off the top of my head. There's space-in-parens for the inside of parentheses. If the next statement starts with a keyword, we have keyword-spacing. I can't think of a rule that enforces spaces between close parenthesis and the next non-keyword token, but I could definitely be forgetting something.
Hafez
@AbdelrahmanHafez
@ljharb I find that it improves readability when omitting the curly braces when there is only one statement in the condition block. Can it cause bugs even when with consistent semicolons?
Kevin Partington
@platinumazure
And I'll note that ljharb is undoubtedly trying to help by recommending a style that is less likely to cause errors on refactoring, but he is not making any sort of statement on behalf of ESLint. ESLint generally doesn't try to favor one style over any other style
Hafez
@AbdelrahmanHafez
@platinumazure Should I open an issue with a feature request on the GitHub repo?
Kevin Partington
@platinumazure
@AbdelrahmanHafez Couldn't hurt
Jordan Harband
@ljharb
yes that's what i'm doing :-)
Hafez
@AbdelrahmanHafez
Ah, I am sure he has nothing but good intentions recommending what he thinks is best. Thank you both for your efforts
Jordan Harband
@ljharb
@abdelrahmanHafez the likely bug is that someone will add another statement meant to go in the block, and fail to add the curlies
that's what broke the entire internet a few years ago in openssl
(in highly reviewed code that had been there for a decade or more)
readability is about maintainability, not about aesthetics :-)
Hafez
@AbdelrahmanHafez
oh boy, such a nasty bug, I'll keep that in mind. Thank you!
Jordan Harband
@ljharb
iow, in general, i find things to be less readable when you have to count something in order to decide the style
eg, if you can't always omit the curlies, it's better to always include them, because that's one less thing you have to get right
fluentwind
@fluentwind
@platinumazure I want to lint whether an i18n key is defined and unused in another file in a webpack project. So I just need to write a node script to lint manually or make a webpack plugin to trigger the lint? In another side, I d like to lint when I am coding using IDE s plugin which means it must depend on Eslint to trigger. Since eslint couldn’t do multiple file lint, automatically triggered by IDE will not be reachable.
Kevin Partington
@platinumazure
@fluentwind Well, it will be pretty difficult to figure out what files are pulling in the i18n file and check all of them for usage. But maybe there are plugins out there which have already done similar and soved the related issues? I'm not sure.
fluentwind
@fluentwind
@platinumazure Yes it’s a hard job, especially finding out a key mixed with constant and variable. Em... I have no idea. Well actually I have found some plugin to work with vue-i18n, but not suitable for me. Anyway, thanks guy.
Macarse, Christian Ryan R.
@crrmacarse
image.png
Shouldn't npm install resove this?
Roy Sutton
@webOS101
Not if you haven’t installed that package locally.
Kevin Partington
@platinumazure
@crrmacarse Do you have eslint-config-airbnb listed in package.json as a devDependency?
Rodrigo Coelho
@rodrigomcoelho
Hi everyone, I am new here I would like you guys help me to identity what is going on to my project

I am getting this error:

[Info - 6:37:33 PM] ESLint library loaded from: /home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/api.js (node:4066) UnhandledPromiseRejectionWarning: Error: Failed to load config "airbnb" to extend from. Referenced from: /home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/.eslintrc.js at configMissingError (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:265:9) at ConfigArrayFactory._loadExtendedShareableConfig (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:826:23) at ConfigArrayFactory._loadExtends (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:731:25) at ConfigArrayFactory._normalizeObjectConfigDataBody (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:660:25) at _normalizeObjectConfigDataBody.next (<anonymous>) at ConfigArrayFactory._normalizeObjectConfigData (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:596:20) at _normalizeObjectConfigData.next (<anonymous>) at createConfigArray (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:340:25) at ConfigArrayFactory.loadInDirectory (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/config-array-factory.js:433:16) at CascadingConfigArrayFactory._loadConfigInAncestors (/home/rcoelho/Documents/courses/rocketseat/gostack/desafios/fastfeet/fastfeetMobile/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:328:46)

Roy Sutton
@webOS101
You’re missing eslint-config-airbnb.
Did you add it as a dev dependency of your project? (see comment directly above yours in the chat)
Rodrigo Coelho
@rodrigomcoelho

It exists in my package.json

``

{ "name": "fastfeetMobile", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": { "@react-native-community/async-storage": "^1.8.1", "@react-native-community/masked-view": "^0.1.7", "@react-navigation/bottom-tabs": "^5.2.4", "@react-navigation/native": "^5.1.3", "@react-navigation/stack": "^5.2.6", "axios": "^0.19.2", "date-fns": "^2.0.0-beta.5", "immer": "^6.0.2", "prop-types": "^15.7.2", "react": "16.9.0", "react-native": "0.61.5", "react-native-camera": "^3.21.0", "react-native-dotenv": "^0.2.0", "react-native-gesture-handler": "^1.6.1", "react-native-reanimated": "^1.7.0", "react-native-safe-area-context": "^0.7.3", "react-native-screens": "^2.4.0", "react-native-svg": "^12.0.3", "react-native-vector-icons": "^6.6.0", "react-redux": "^7.2.0", "reactotron-react-native": "^4.0.3", "reactotron-redux": "^3.1.2", "reactotron-redux-saga": "^4.2.3", "redux": "^4.0.5", "redux-persist": "^6.0.0", "redux-saga": "^1.1.3", "styled-components": "^5.0.1" }, "devDependencies": { "@babel/core": "^7.9.0", "@babel/runtime": "^7.9.2", "@react-native-community/eslint-config": "^0.0.7", "babel-eslint": "^10.1.0", "babel-jest": "^25.1.0", "babel-plugin-root-import": "^6.5.0", "eslint": "^6.8.0", "eslint-config-airbnb": "^18.1.0", "eslint-config-prettier": "^6.10.1", "eslint-import-resolver-babel-plugin-root-import": "^1.1.1", "eslint-plugin-import": "^2.20.1", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.19.0", "eslint-plugin-react-hooks": "^2.5.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.59.0", "prettier": "^2.0.2", "react-native-svg-transformer": "^0.14.3", "react-test-renderer": "16.9.0" }, "jest": { "preset": "react-native" } }
❯ yarn yarn install v1.22.4 [1/4] Resolving packages... success Already up-to-date. Done in 0.79s.
Roy Sutton
@webOS101
What does yarn ls eslint-config-airbnb say?
oh...
how are you running eslint?
Rodrigo Coelho
@rodrigomcoelho
yarn eslint --init
and select a popular guide.. arbnb
module.exports = {
  env: {
    es6: true,
  },
  extends: [
    'airbnb',
    'prettier',
    'prettier/react',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
    __DEV__: true,
  },
  parser: 'babel-eslint',
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  plugins: [
    'react',
    'prettier',
    'react-hooks',
    'import',
    'jsx-a11y',
  ],
  rules: {
    'prettier/prettier': 'error',
    'react/jsx-filename-extension': ['warn', { extensions: ['.jsx', '.js'] }],
    'import/prefer-default-export': 'off',
    'no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
    'react/jsx-one-expression-per-line': 'off',
    'global-require': 'off',
    'react-native/no-raw-text': 'off',
    'no-console': ['error', { allow: ['tron', 'info'] }],
    'no-param-reassign': 'off',
    'no-underscore-dangle': 'off',
    camelcase: 'off',
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'warn',
    'react/jsx-props-no-spreading': 'off',
  },
  settings: {
    'import/resolver': {
      'babel-plugin-root-import': {
        rootPathSuffix: 'src'
      },
    },
  },
};
Rodrigo Coelho
@rodrigomcoelho
yarn list v1.22.4
warning Filtering by arguments is deprecated. Please use the pattern option instead.
└─ eslint-config-airbnb@18.1.0
Done in 0.83s.
Rodrigo Coelho
@rodrigomcoelho
Should I report an issue on github or it's something I am doing corrently?
Roy Sutton
@webOS101
It’s not an issue you should report.
—init isn’t how you run the linter. How are you starting eslint to lint your code?
Jordan Harband
@ljharb
the problem is "ESLint library loaded from: "
you're not running eslint on the command line, you're probably invoking it via your editor, and it's possibly loading the wrong one
i see node modules inside fastfeet/fastfeetMobile but your eslint config is in fastfeet/
your node_modules and package.json and "where you run eslint" should all be in the same directory.
iow, either move the config down, or move node_modules up
@rodrigomcoelho