Giter Site home page Giter Site logo

snaerth / create-react-component-folder Goto Github PK

View Code? Open in Web Editor NEW
165.0 6.0 49.0 1.85 MB

Creates react component folder structure

License: MIT License

JavaScript 94.07% Handlebars 5.93%
react scaffold create-react-app create-react-native-app create-react-component react-component npm-package

create-react-component-folder's People

Contributors

aidurber avatar caseyg1204 avatar chandanrjit avatar chtompki avatar daveawb avatar dependabot[bot] avatar guytepper avatar iaurg avatar jay-a-mcbee avatar lepperm avatar loveforweb avatar niradler avatar pixelbandito avatar pqtran avatar sicknarlo avatar snaer-yolabs avatar snaerth avatar vacekj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

create-react-component-folder's Issues

"createIndex" flag throws error

The createIndex flag does not function properly.

No components are created if the folder structures requested don't exist. If the folder structures do exist and empty index file is created but no components are created.

TypeScript: TypeError: Cannot read property 'createElement' of undefined

{
  "compilerOptions": {
    "outDir": "build/dist",
    "module": "commonjs",
    "target": "es5",
    "lib": ["es6", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": false,
    "noImplicitAny": false,
    "strictNullChecks": false,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true
  },
  "include": [
    "src"
  ],
  "exclude": [
    "node_modules",
    "build",
    "scripts",
    "acceptance-tests",
    "webpack",
    "jest",
    "src/setupTests.ts",
    "config"
  ],
  "types": [
    "typePatches"
  ]
}

What do I need to support import React, { Component } from 'react'; ? I am using create-react-app with react-app-rewired.

Option for default folder

It's a bit annoying having to type src/components/${Component} every time... would be nice to put the option for the default folder

Make generated code ESLint and TSLint friendly

I've used your package for a while now and it works great on the whole. There are a few small linting problems with generated code that could be fixed, if you're happy with the points I make I can raise a PR.

The following problems were encountered using node 10.15.3 and yarn 1.13.0 running on Alpine Linux and also Ubuntu 18.04.

I haven't used other files generated (other than the ones listed) but I think they may have similar issues.

Storybook

  • No trailing semicolon after importing @storybook/react.
  • No trailing semicolon terminating storiesOf block.
  • 4 space trailing white-space at end of file, empty line would be better.

Index

  • No newline at end of file

Test

  • 4 space trailing white-space at end of file

Component

  • 4 space trailing white-space at end of file

Not working on 0.1.18

#10

screen shot 2018-05-28 at 12 14 12 pm

That happens when running any command, maybe there's a dependency conflicting with create-react-app for that project at that state I just had styled-components installed besides react-scripts

๐Ÿค”

The "path" argument must be of type string. Received undefined

Hello! Great project ๐Ÿ˜„

When I try to run

$ npx crcf --createindex

I get this error:

The "path" argument must be of type string. Received undefined
This happens either if I run the command in the root folder where components/ folder is or inside components/

I followed the instructions and I installed the package running:

$ npm install --save-dev create-react-component-folder 

Any thoughts? ๐Ÿ˜„

Thank you!

Nested folders not working in windows

Having the latest package installed, while trying to create Button component on Windows with the following syntax
crcf components/Button
the "Button" folder is created in root, and not in the "components" folder

"notest" causes no test file AND no css file

This is my package.json:

"crcf": [ "typescript", "cssmodules", "scss", "notest", { "output": "src/" } ]

As a result, only the index.ts and component .tsx files are created

Removing the "notest" flag causes both the test foile AND the scss module to appear.

Templates and other ideas (implemented in fork)

I had some requirements in a project recently that needed some finer control over the creation of the different components. I've got the working code in a fork https://github.com/Daveawb/create-react-component-folder.

I wondered if this would be of any use to you, it does add a dependency on handlebars to manage templates but abstracts a lot of logic away from the main index and creation scripts.

  • Added a configuration namedexports to remove default exports and export named variables only.

  • Added Typescript propTypes (removed {{name}}.propTypes) and added a TS type instead when typescript is in the configuration.

  • Added Typescript types to functional components

  • All options have default values that are passed in from cosmiconfig

  • Run time configuration values are merged with the defaults to provide a consistent config array throughout the script.

  • A minor configuration helper added to get items from a config store

  • Templates are rendered using handlebars rather than JS. This could potentially allow for the templates to be published into a project allowing for finer control over how components etc. are rendered.

  • Removed all the generation functions in favour of one createReactComponent function.

  • Fixed ESLint and TSLint problems with current template layouts.

Let me know if this is of any use to you and I'll clean it up and put in a PR.

Additional

  • Refactored config to use a global store with a frozen API that is available as a require in any script that needs it without passing it around in arguments.
    • Config is an object with two keys, flags and values, these are not directly accessible.
    • Config exposes a simple API to check, get and merge values.
  • Added --output <directory> | -o <directory> to options to allow configuring default output location
  • Cleaned up templates and fixed a few bugs with prop types

Feature Request: Auto Import CSS

It would be nice if the CSS module was already imported based on the assumption that if one does not use the --nocss flag then certainly they want CSS and thus would save time if it were already imported.

Thanks so much for the work on this! I love the tool.

--createindex issues

  • make default path to /,
    currently using crcf --createindex will crash
    throw new TypeError('Path must be a string. Received ' + inspect(path));

  • instead of
    export default {
    change to
    export {

Add options [name].module.css for CSS modules

Hi.
based on create-react-app docs, it can use css modules, but must create .module.css files to make it work. I hope there's an options to create file [component folder name].module.css files to make it easier.

thanks

Not creating sass file

I'm having an issue when running with the -s or --sass param that it's not creating a sass file for my component. The output in the terminal says that it does (pasted below), but no such file exists in the folder. If I remove the flag, it does create a css file as expected.

/path/to/my/components/shape
  โ””โ”€ index.js
  โ””โ”€ shape.js
  โ””โ”€ shape.test.js
  โ””โ”€ shape.sass

Option for JEST tests

I'd like the MyComponent.test.[tsx/js] file to look like this if using Jest option rather than Enzyme. This seems to be the default when using create-react-app.

import React from 'react';
import ReactDOM from 'react-dom';
import MyComponent from './MyComponent';

it('renders without crashing', () => {
  const div = document.createElement('div');
  ReactDOM.render(<MyComponent/>, div);
  ReactDOM.unmountComponentAtNode(div);
});

Feature Request: No Semi Colons flag

Thanks so freaking much for this tool! It is a huge time saver.

We use Standard for out linting. I understand not everyone loves that, but we do! And many do. Would be nice to not need to remove each semicolon manually after creating a component.

npx crcf components/foo --nosemi

The result would be that each file is created, but without semicolons.

Prettier options aren't used by createMultiIndex fn

๐Ÿ‘‹ Hey @snaerth - thanks for all the work creating this lib. It makes scaffolding out a React cmp super fast ๐Ÿš€ . I noticed a small omission when it comes to prettier options. When I use the createindex option, my import file paths are always created using double-quotes even though my .crcfrc file contains 'singlequote'.

The "prettier" options aren't pulled from the config and passed to the createMutiIndex fn - https://github.com/snaerth/create-react-component-folder/blob/master/lib/index.js#L206.

formatPrettier ends up being called without any passed prettier options - https://github.com/snaerth/create-react-component-folder/blob/master/lib/utils/createMultiIndex.js#L28.

The default prettier config is used - https://github.com/snaerth/create-react-component-folder/blob/master/lib/utils/format.js#L12

I'd be happy to put up a PR to add this to the createMultiIndex function.

Generated .stories file doesn't have newline after import

Getting an eslint error in MyComponent.stories.js. The linter error is "Expected 1 newline after import statement not followed by another import. (import/newline-after-import)"

This error doesn't appear in the main component file, just the story.

Current:

import React from 'react';
import { storiesOf } from '@storybook/react';
import MyComponent from './MyComponent';
storiesOf('MyComponent', module).add('MyComponent', () => (
  <div>
    <MyComponent />
  </div>
));

Desired:

import React from 'react';
import { storiesOf } from '@storybook/react';
import MyComponent from './MyComponent';

storiesOf('MyComponent', module).add('MyComponent', () => (
  <div>
    <MyComponent />
  </div>
));

Linting is failing

screen shot 2018-05-29 at 1 23 49 pm

Should we keep those files not being used? Maybe it would be good to delete them to clean up console real estate.

๐Ÿค”

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.