Giter Site home page Giter Site logo

Comments (8)

brodybits avatar brodybits commented on May 12, 2024 1

@erisu I only wanted to give examples of some major changes that I know are wanted in an upcoming releases, and that I think should not be blocked by removing superspawn (#16). I suspect that #16 could be a major effort to implement and test on all of the various Cordova packages.

I hope this is clear now. Please feel free to ask if it is still not clear.

from cordova.

raphinesse avatar raphinesse commented on May 12, 2024

I've added a dependency graph to make it easier to determine the correct order of doing this.

from cordova.

raphinesse avatar raphinesse commented on May 12, 2024

Should anyone want to tackle this for some repo, here's some of the "tools" I've been using:

List of Q instance methods:

passByCopy
join
tap
thenResolve
thenReject
isPending
isFulfilled
isRejected
spread
dispatch
get
set
del
mapply
post
send
mcall
invoke
fapply
fcall
fbind
keys
any
allResolved
allSettled
fail
progress
fin
done
timeout
delay
nfapply
nfcall
nfbind
denodeify
nbind
nmapply
npost
nsend
nmcall
ninvoke
nodeify

bash scripts that read from above list and search for usage of these methods (uses ripgrep):

# List all matches
while read -u 10 m; do
    rg "\.${m}\(";
done 10< q-methods.txt

# Print statistics on the usage count of the different methods
while read -u 10 m; do
    printf "$m: ";
    (rg -c "\.${m}\(" || echo 'x:0') | cut -d: -f2 | paste -s -d+ | bc;
done 10< q-methods.txt | grep -v ' 0$'| sort -n -k2

Naturally this is nowhere near being an automatic process as RegExs aren't powerful enough to parse JS and the code probably has a lot of .join( that has nothing to do with Q 😉
But much is solvable by simple search and replace.

from cordova.

raphinesse avatar raphinesse commented on May 12, 2024

Too bad nobody wrote an automated code transformation based on jscodeshift for migrating from Q to native Promises.

from cordova.

brodybits avatar brodybits commented on May 12, 2024

Another thing is that I think we should get rid of superspawn as discussed in #16, rather than fixing superspawn to drop use of q. The rationale is that superspawn seems to return a non-standard Promise-like object that can also notify the listener of stdout and stderr data. I think it would be better to cleanly factor superspawn out of the Cordova packages, in a major release.

While it would be ideal to do this in the next major release, it would likely block some other desired changes such as dropping support for Node.js 6 and eventually Node.js 8.

from cordova.

erisu avatar erisu commented on May 12, 2024

@brodybits Can you elaborate on this?

it would likely block some other desired changes such as dropping support for Node.js 6 and eventually Node.js 8.

To drop Node.js 6 and 8 in the next major as planned, we only remove it from the CI testing configurations and bump the node engine in package.json. There shouldn't be much effort to this.

from cordova.

erisu avatar erisu commented on May 12, 2024

Thank you @brodybits that cleared up my confusion.

from cordova.

raphinesse avatar raphinesse commented on May 12, 2024

I wrote an ESLint config that should highlight all instances of Q-API usage:

const qInstanceMethodsConfig = `
    allResolved allSettled del delay denodeify dispatch done fail fapply fbind
    fcall fin invoke isFulfilled isPending isRejected mapply mcall nbind
    nfapply nfbind nfcall ninvoke nmapply nmcall nodeify npost nsend passByCopy
    post progress spread tap thenReject thenResolve timeout
`.trim().split(/\s+/).map(property => ({ property }));

const restrictedSyntaxConfig = [
    {
        selector: `
            CallExpression[arguments.length=1][arguments.0.value!=/^(,? ?|\\n)$/]
                > MemberExpression[property.name="join"][object.name!="path"][callee.object.type!="ArrayExpression"]
        `.replace(/\n/g, ''),
        message: 'possible usage of `Q.prototype.join`',
    },
    {
        selector: 'CallExpression[arguments.length=1] > MemberExpression[property.name="get"]',
        message: 'possible usage of `Q.prototype.get`',
    },
    {
        selector: 'CallExpression[arguments.length=2] > MemberExpression[property.name="set"]',
        message: 'possible usage of `Q.prototype.set`',
    },
    {
        selector: 'CallExpression > MemberExpression[property.name="any"][object.name!="jasmine"]',
        message: 'possible usage of `Q.prototype.any`',
    },
    {
        selector: 'CallExpression > MemberExpression[property.name="keys"][object.name!="Object"]',
        message: 'possible usage of `Q.prototype.keys`',
    },
    {
        selector: 'CallExpression[callee.property.name="send"]',
        message: 'possible usage of `Q.prototype.send`',
    },
]

module.exports = {
    rules: {
        'no-restricted-modules': ['error', 'q'],
        'no-restricted-properties': [
            'error', { object: 'Q' }, { object: 'q' }, ...qInstanceMethodsConfig
        ],
        'no-restricted-syntax': ['warn', ...restrictedSyntaxConfig],
    }
};

from cordova.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.