eslint / eslint-transforms

Codemods for the ESLint ecosystem
Other
23 stars 8 forks source link

feat: add transform for v9 migration #29

Closed snitin315 closed 4 months ago

snitin315 commented 4 months ago

Fix https://github.com/eslint/eslint-transforms/issues/25

snitin315 commented 4 months ago

@nzakas I've addressed your feedback. PTAL

aladdin-add commented 4 months ago

I've tried running it to eslint-plugin-n v15.0.0, but got the error:

node ../eslint-transforms/bin/eslint-transforms.js v9-rule-migration ./lib
Processing 67 files... 
Spawning 7 workers...
Sending 10 files to free worker...
Sending 10 files to free worker...
Sending 10 files to free worker...
Sending 10 files to free worker...
Sending 10 files to free worker...
Sending 10 files to free worker...
Sending 7 files to free worker...
 ERR lib/util/check-unsupported-builtins.js Transformation error (Cannot read properties of null (reading 'node'))
TypeError: Cannot read properties of null (reading 'node')
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:76:27)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:226:44)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/rules/no-path-concat.js Transformation error (Cannot read properties of undefined (reading 'name'))
TypeError: Cannot read properties of undefined (reading 'name')
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:228:56)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/util/visit-require.js Transformation error (Cannot read properties of undefined (reading 'name'))
TypeError: Cannot read properties of undefined (reading 'name')
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:228:56)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/rules/no-deprecated-api.js Transformation error (Cannot read properties of undefined (reading 'name'))
TypeError: Cannot read properties of undefined (reading 'name')
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:228:56)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/util/check-prefer-global.js Transformation error (Cannot read properties of null (reading 'node'))
TypeError: Cannot read properties of null (reading 'node')
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:76:27)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:226:44)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/rules/no-unsupported-features/es-syntax.js Transformation error (Cannot read properties of null (reading 'node'))
TypeError: Cannot read properties of null (reading 'node')
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:76:27)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at getParentObjectMethod (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:81:12)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:226:44)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/rules/prefer-promises/fs.js Transformation error (Cannot read properties of undefined (reading 'name'))
TypeError: Cannot read properties of undefined (reading 'name')
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:228:56)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
 ERR lib/rules/prefer-promises/dns.js Transformation error (Cannot read properties of undefined (reading 'name'))
TypeError: Cannot read properties of undefined (reading 'name')
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:228:56)
    at NodePath.<anonymous> (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:142:47)
    at /Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:75:36
    at Array.forEach (<anonymous>)
    at Collection.forEach (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:74:18)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/collections/Node.js:140:17)
    at Collection.replaceWith (/Users/weiran/repo/github/eslint-transforms/node_modules/jscodeshift/src/Collection.js:413:43)
    at module.exports (/Users/weiran/repo/github/eslint-transforms/lib/v9-rule-migration/v9-rule-migration.js:203:8)
All done. 
Results: 
8 errors
41 unmodified
0 skipped
18 ok
Time elapsed: 2.956seconds
snitin315 commented 4 months ago

I've tried running it to eslint-plugin-n v15.0.0, but got the error:

Looking into it.

snitin315 commented 4 months ago

I've tried running it to eslint-plugin-n v15.0.0, but got the error:

@aladdin-add Fixed 👍🏻, it was failing when the methods were in some helper utils instead of being directly under the create() method.

Screenshot 2024-06-06 at 6 49 04 AM