Skip to content

Inspections can't detect jQuery usages if non-$ alias is used #18

Open
@alies-dev

Description

@alies-dev

Inspections can't detect jQuery usages if non-$ alias is used

Example of a code that can be omitted by jquery/no-ajax rule:

import jQuery from 'jquery';

jQuery
    .ajax({ url: url, method: 'POST' })
    .done(() => { });

That's because some rules contains the following code:

if (node.callee.object.name !== '$') return

the quick-fix solution is to check for jQuery/jquery also:

const jQueryAliases = ['$', 'jQuery', 'jquery'];
const calleeObjectName = node.callee.object.name;
if (! jQueryAliases.includes(calleeObjectName)) return

Ideally jQueryAliases should be a configurable option

PS: If you agree with this solution - I can create a PR 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions