Solvedjavascript Provide alternate solution for no-underscore-dangle

I don't want to argue whether no-underscore-dangle is good or not (#1089 and #1024 have that covered), but as since I'm quite new to this whole ES6 thing, I'd appreciate it if the readme provided some guidance on how to handle private variables.

20 Answers

✔️Accepted Answer

@ranneyd See the docs: you can specify allow: ['_id']

Other Answers:

Our backend is giving us data from mongodb, which saves its primary keys as _id. Every time we get _id from these objects, eslint yells at us :'(

The current guidance is to architect such that you don't need them.

When the language gets actual private fields (and airbnb’s supported browsers support them or their transpiled version), the guide will be amended to suggest using those instead.

This seems fully answered.

Related Issues:

391
javascript How to configure React Native (Expo) project to use AirBnB's React rules via ESLint?
This is what I do in React and React Native: Step 1 Step 2 Backup your eslintrc file in case you wan...
139
javascript Using 'ForInStatement' is not allowed (no-restricted-syntax)
@francoisromain Object.assign(options opts) Since version 8 there is this error on for in loops What...
95
javascript Why no setState in componentDidMount?
As the docs state that they belong in componentDidMount: If you want to integrate with other JavaScr...
71
javascript .jsx extension cannot be used with React Native
@borisyankov what's common isn't the primary motivator for this guide it's what we use at Airbnb We ...
63
javascript What is the benefit of prefer-default-export?
https://blog.neufund.org/why-we-have-banned-default-exports-and-you-should-do-the-same-d51fdc2cf2ad?...
49
javascript What is the point of the no-continue rule?
@MegaArman Loops are still useful in 2018 in many non trivial cases and will stay useful even in 211...
48
javascript Option to disable a11y plugin?
For everyone who wondering how to use mentioned workaround: We love the airbnb style guide including...
45
javascript react/jsx-no-bind: how to pass args from callbacks?
Right - at that point you might as well disable the rule. I have a question about react/jsx-no-bind ...
43
javascript no-param-reassign with props, again
This is a rule we use at Airbnb - in the reducer case if the body of your reducer is return Object.a...
39
javascript Provide alternate solution for no-underscore-dangle
@ranneyd See the docs: you can specify allow: ['_id'] I don't want to argue whether no-underscore-da...
30
javascript Failed to load plugin 'jsx-a11y' declared '/.eslintrc » eslint-config-airbnb
@kacperborkowski - did you try installing eslint and its dependencies at the top level of the projec...
21
javascript react/jsx-wrap-multilines arrow rule breaking eslint.
( export PKG=eslint-config-airbnb; npm info $PKG@latest peerDependencies --json | command sed 's/[\{...
21
javascript function-paren-newline error vs. max-len error
This seems like it's actually a bug in the function-paren-newline rule (or an unavoidable conflict w...
18
javascript jsx-a11y/anchor-has-content throws error
With version 3.0.0 eslint-plugin-jsx-a11y updated their schema to accept objects (changelog) ...
17
javascript Why use prefer-destructuring on arrays?
Here's an example why forcing destructuring on arrays of n length is quite silly: Of course this exa...
17
javascript consider removing stylistic rules that can't be automatically fixed from eslint-config-airbnb
Hi @jedwards1211 thanks for checking out the guide We always appreciate feedback from the community ...
13
javascript Failed to load config "airbnb-base" to extend from.
I had similar issue on a react app and this fixed it! I think Will fix it for you too ...
12
javascript Definition for rule 'jsx-a11y/img-has-alt' was not found
The problem is still here eslint-config-airbnb@15.0.1 has peer dependency eslint-plugin-jsx-a11y@^5....
11
javascript jsx-a11y/href-no-hash removal
@TrejGun that's because we aren't compatible with v6 of eslint-plugin-jsx-a11y - if you run npm ls y...
811
webpack Cannot assign to read only property 'exports' of object '#<Object>' (mix require and export)
The code above is ok You can mix require and export You can't mix import and module.exports. ...
727
webpack How to exclude node_modules but one
@borm: a solution: Subj as example I create some module in another folder ( /projects/MY_MODULE ) MY...
499
babel ReferenceError regeneratorRuntime is not defined
I had this issue using rollup with babel I just used this babel config to resolve it : ...
488
webpack nodejs 17: digital envelope routines::unsupported
workaround: Bug report What is the current behavior? Other relevant information: webpack version: 5....
473
webpack TypeError: Data must be a string or a buffer
Here is a workaround to help you to find the wrong import Using the latest 2.2.0 release although th...
296
webpack webpack 4: access the mode flag from webpack.config.js file
This seems to work correctly with --mode production -p and <no flag> Do you want to request a featur...
284
webpack Webpack gives $ is not defined or jQuery is not defined error in console
Just use like this or add to webpack Do you want to request a feature or report a bug? What is the c...
279
babel Support for the experimental syntax 'classProperties' isn't currently enabled
@xtuc Actually I tried to erase bable preset & plugins code in package.json and webpack.config.js an...
233
webpack Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
I got this same error reinstalled it locally and ran it with package scripts and it worked npm remov...
224
core js 3.0.0-beta.3 - Can't resolve 'core-js/es7/reflect'
I have the Angular 7 CLI working fine with core-js 3 I'm using @angular/cli I upgraded to the 3.0.0-...
216
webpack "Uncaught SyntaxError: Unexpected token <" error happened sometimes
I have a same problem fix with added <base href=/ /> into the <head> of my index.html ...
206
babel No "exports" main resolved in @babel/helper-compilation-targets/package.json
I fixed this issue by removing the node_modules directory and package-lock.json file then run npm in...
187
babel Module build failed (from ./node_modules/babel-loader/lib/index.js):
The issue might be because babel-loader@8 depends on babel@7? If you want to use babel-loader@8 try ...
180
webpack [BUG?] npm link causes Webpack to look for babel-plugin in linked package node_modules.
try to add resolve: { symlinks: false } to your webpack.config I've linked a package that is outside...
177
webpack Parsing of import() fails in 4.29.0 (Compilation issue, related to dynamic import)
Running these commands fixes the problem in your repro @Dbuggerx It seem to be a npm problem ...
166
webpack webpack watch mode not working....
Try this workaround: Add this to your webpack configuration file: General Information: webpack versi...
155
babel "regeneratorRuntime is not defined" error with async and "useBuiltIns": "usage"
The solution from this issue thread worked for me Importing the following: for my dependencies and h...
122
webpack webpack broken by ajv@6.9.0, "custom keyword definition is invalid: data.errors should be boolean"
If you use yarn add below to package.json then run yarn install if you use npm ...
113
babel Plugin/Preset files are not allowed to export objects, only functions.
Just like env is now @babel/env react should be @babel/react and you'll need to install @babel/prese...
106
webpack Webpack 2.0 doesn't support custom command line arguments?
Yes this is intended Custom argumens can be passed via --env prefix i e --env.compress ...
103
webpack error:'output.filename' is required, either in config file or as --output-filename"
exports not export,that is the reason. Do you want to request a feature or report a bug? bug What is...
94
webpack DefinePlugin does not inject variable
Hmm I was just having this issue and it was trolling me process.env was showing as an empty object ...
83
webpack Webpack moment.js integration
To the next person trying to get one of the above configurations to work (which they did not for me)...
82
webpack Strange warning stating that export does not exist when it does
Maybe this is not a bug Bug report What is the current behavior? Not sure if this is a problem with ...
71
babel Requires Babel “7.0.0-0” but was loaded with “6.26.3”
@rayj10 I think you need to add babel-core: ^7.0.0-bridge.0 Try this: Bug Report Current Behavior Ke...
69
webpack multiple usage of the CommonsChunkPlugin, only first works
The CommonsChunkPlugin selects only entry chunks Do you want to request a feature or report a bug? I...
67
webpack Using dynamic require on node targets WITHOUT resolve or bundle the target module
const server = __non_webpack_require__(entryPath) Do you want to request a feature or report a bug? ...
64
webpack Webpack 4 chunking different runtime behaviour compared to Webpack 3
I stumbled upon such a configuration after trying many many variations Conceptually I'm not 100% sur...
63
webpack Error when trying to build bundle after upgrading to 4.20.0
Please read CHANGELOG https://github.com/webpack/webpack/releases/tag/v4.20.0 Update internal struct...
60
webpack Using webpack 4 on a large project (or, how to avoid "JavaScript heap out of memory" with production mode)
For those looking to increase the memory used by webpack Do you want to request a feature or report ...
60
webpack Webpack 4.0 file-loader json issue
I was able to copy my .json config file to the build folder using this: Do you want to request a fea...