microsoft/tslint-microsoft-contrib

Question/Ask for documentation : No backbone get set outside model

VincentLanglet opened this issue ยท 12 comments

Is it possible to document the rule no-backbone-get-set-outside-model ?

I don't know how to fix the errors I received from this rules.
For example, with the code

const response = await fetch(url);
const contentType = response.headers.get('content-type');

How to get rid of the get call ?

๐Ÿ‘‹ @VincentLanglet - agreed the rule's docs aren't enough! Accepting a PR to add to them.

In the meantime, this SO answer linked to #123 provides some more context. Is that what you were looking for?

@JoshuaKGoldberg Thanks for your quick answer

I saw the answer on stackoverflow but I didn't understand enough to solve my case. That's why I was thinking that many examples and how to fix them could be great on the wiki.
For what I understood, I should have something like this.get('content-type') and response.headers.getContentType(), but I don't know how to get there.

Moreover, since the rule talk about backbone and models, I'm not sure I'm concern about this one since I don't use http://backbonejs.org/ and I was wondering why it's catching errors, it could be clearer if the rule catch only error for backbone models.

Oh, yes - if you don't use Backbone you should disable that rule.

What about removing this rule of the recommended ruleset and adding it in the paragraph

/**
 * Controversial/Configurable rules.
 */
'no-backbone-get-set-outside-model': false, // only enable this if you have backbone.js

It's seems weird to me to set a rule by default if it's designed for a specific library

Great idea! Filed #716 to track that as a breaking change in 7.0.

@JoshuaKGoldberg no-backbone-get-set-outside-model is still active in the recommended ruleset.

I advised you here to create a all ruleset with the recommended and the latest one. This way, until the 7.0, you can turn off the rule in the latest config.

Are you still agree with this ?

@JoshuaKGoldberg Since #716 is closed but #672 is not ; what is the status of this issue ?

Hi @JoshuaKGoldberg, I get this error for JavaScript's map.set() function.

var mapSet = new Map();
mapSet.set('base', {     
            id: 'base',
            label: 'label',
            type: 'type'
        }); // Error shown here: Backbone set() called outside of owning model: mapSet.set('base'...) (no-backbone-get-set-outside-model)

I have raised a question in StackOverflow. We are trying to get Microsoft visual certificate and it says that we can't override any rule. Is there any possible way to solve this issue?

@Karthickbg oof... this is a false positive in the rule... but PowerBI says you should not override rules.

I suggest you just add an ignore statement to the line

// tslint:disable-next-line:no-backbone-get-set-outside-model

Yep, that's false positive in rule, that can be removed from configuration only with major version bump.

We are trying to get Microsoft visual certificate and it says that we can't override any rule.

@HamletDRC do you know anything better to change requirements from almost deprecated TSLint to ESLint than raising issue for docs page?

I suggest you just add an ignore statement to the line

I hope that they don't check for disable comments ๐Ÿ˜„

PowerBI will audit your code... so the suppression is totally fine because they will see that Backbone is not being used.

I reached out to the PowerBI team via an issue raised on their docs page. I'll send an internal email as well.

โ˜ ๏ธ It's time! โ˜ ๏ธ

Per #876, this repository is no longer accepting feature pull requests. TSLint is being deprecated and we recommend you switch to https://typescript-eslint.io.

Thanks for open sourcing with us, everyone!