question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider turning on exception ignoreEOLComments for no-multi-spaces rule

See original GitHub issue

When you have a longer chain in your code, like an observable chain, or promise one, or lodash flow one, we sometimes comment the chain to make it more understandable what happens and why each step is there. To make it easier to read, we align the comments, but the current rule settings give errors on this.

So why is the ignoreEOLComments turned off? Is there a special reason for this? Imho, it should be turned on, to make it possible to align comments like:

myObservable
  .pipe(
    map(inACertainWayFunction),              // Step explanation
    filter(byPropBFunction),                 // Step explanation
    distinctUntilChanged(comparisonFunction) // Step explanation
  );

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
dietergeertscommented, Jun 6, 2018

@ljharb, It’s actually the ‘why’ they explain. In very long difficult chains, we’ll always explain the functional part behind the steps, so we know ‘why’ they are there, that’s what I mean with step explanation. Off course it’s bad to explain what the code does, that should be clear by the line of code itself.

Some real code of the current project to better show what I mean:

/**
 * Switch to single getter to enable single source of truth.
 *
 * @param {ModelStore<*>} store
 * @returns {function(Observable<OBJ>): Observable<OBJ>}
 * @template OBJ
 */
export function switchGet(store) {

  return source => source
    .do(setModelCache(store.readModel)) // Set reader cache for individual model,
    .do(nextOn(store.modelUpdated))     // And throw event, as may be already subscribed...
    .map(get('id'))                     // Get the id from the model to use in the get.
    .switchMap(store.getModel)          // Then use get to enable single source of truth.
    .distinctUntilChanged(isEqual);     // Because of internal (re-)subscription, we got multiple updates...
}
0reactions
horntacommented, Jun 5, 2018

Can you try and write it like this? Does that help the readability?

myObservable
  .pipe(
    map(inACertainWayFunction), //              Step explanation
    filter(byPropBFunction), //                 Step explanation
    distinctUntilChanged(comparisonFunction) // Step explanation
  );
Read more comments on GitHub >

github_iconTop Results From Across the Web

no-multi-spaces - ESLint - Pluggable JavaScript Linter
This rule's configuration consists of an object with the following properties: "ignoreEOLComments": true (defaults to false ) ignores multiple spaces before ...
Read more >
parsing error: 'const declarations' require an initialization ...
Const declarations require an initialization value javascript typescript 16,204 Solution 1 Try to put ts-loader before js rule in webpack config { test:...
Read more >
Diff - 9a34b2cc2d..78de17c053 - chromium/src - Git at Google
The option + // |ignoreEOLComments| is not supported yet in the bundled eslint. + 'no-multi-spaces': 0, + + // TODO(shik): temporarily disable the...
Read more >
How to add exception to a eslint rule? - Stack Overflow
This rule ( no-multi-spaces ) has an option exceptions that you can configure to ignore all variable declarations.
Read more >
218.58.62.115:18081/gitlab/edgegw_cs/source/-/comm...
+ // Ignore default rules for ternary expressions. ... They haven't been added to a specific release yet, but we'll consider them for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found