bfncs / codemod-imports-sort Goto Github PK
View Code? Open in Web Editor NEWSort ES6 imports by type
Home Page: https://www.npmjs.com/package/codemod-imports-sort
Sort ES6 imports by type
Home Page: https://www.npmjs.com/package/codemod-imports-sort
Nice tool! One issue: I use flow, so there's a /* @flow */
comment in the 1st line of source files.
Before:
/* @flow */
import calcDropTargetClass from "../common/calcDropTargetClass";
import classNames from "classnames";
import dropSourceInTarget from "../StandardShow/dropSourceInTarget";
import { DropTarget } from "react-dnd";
import React from "react";
import SearchTypes from "../../constants/SearchTypes";
After:
import classNames from "classnames";
import React from "react";
import { DropTarget } from "react-dnd";
import SearchTypes from "../../constants/SearchTypes";
/* @flow */
import calcDropTargetClass from "../common/calcDropTargetClass";
import dropSourceInTarget from "../StandardShow/dropSourceInTarget";
Looks like it's keeping comments above their following import, but moving the comment messes things up. Maybe special-case and keep /* flow */
at top?
Would be amazing if this codemod could format code so it passes eslint's import order rule.
https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/order.md
"import/order": [
"error",
{
"newlines-between": "always",
"groups": [
"index",
"sibling",
"parent",
"internal",
"external",
"builtin"
]
}
]
โ project git:(sort-imports) codemod-imports-sort --version
module.js:471
throw err;
^
Error: Cannot find module '../utils/requirePackage'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.callback (/Users/fspiridonov/.nvm/versions/node/v6.10.0/lib/node_modules/codemod-imports-sort/bin/codemod-imports-sort:82:32)
at Object.ArgParser.setOption (/Users/fspiridonov/.nvm/versions/node/v6.10.0/lib/node_modules/codemod-imports-sort/node_modules/nomnom/nomnom.js:447:26)
at /Users/fspiridonov/.nvm/versions/node/v6.10.0/lib/node_modules/codemod-imports-sort/node_modules/nomnom/nomnom.js:274:14
at Array.reduce (native)
at Object.parse (/Users/fspiridonov/.nvm/versions/node/v6.10.0/lib/node_modules/codemod-imports-sort/node_modules/nomnom/nomnom.js:223:10)
at Object.<anonymous> (/Users/fspiridonov/.nvm/versions/node/v6.10.0/lib/node_modules/codemod-imports-sort/bin/codemod-imports-sort:93:4)
In here: https://github.com/bfncs/codemod-imports-sort/blob/master/bin/codemod-imports-sort#L82
Should it be
const requirePackage = require('jscodeshift/utils/requirePackage');
?
Hi,
First, when I installed it I had this error on running
ERROR Transform file /home/julien/Sites/theRepo/dist/index.js does not exist
I created the missing file, and when rerun ;
ERR app/components/Nav/components/LeftMenuList/LeftMenuList.js Transformation error
TypeError: transform is not a function
All done.
Results:
1 errors
0 unmodified
0 skipped
0 ok
Could you help me please on this issue ?
Thank you !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.