neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.94k stars 213 forks source link

npx @neutrinojs/create-project@next unsuccessfully. #1388

Closed Tassfighter closed 5 years ago

Tassfighter commented 5 years ago

npx @neutrinojs/create-project@next user npx: installed 354 in 7.918s | | () | ' \ / | | | || || '|| || ' \ / _ \ | | | || _/| || || | | | | || | | || () | || || _| _,| _||| |||| |_| ___/

Welcome to Neutrino! πŸ‘‹ To help you create your new project, I am going to ask you a few questions.

? πŸ€” First up, what would you like to create? Components ? πŸ€” Next, what kind of components would you like to create? React Components ? πŸ€” Would you like to add a test runner to your project? Jest ? πŸ€” Would you like to add linting to your project? Airbnb style rules

πŸ‘Œ Looks like I have all the info I need. Give me a moment while I create your project!

create user/package.json create user/.neutrinorc.js create user/.eslintrc.js create user/webpack.config.js create user/src/index.jsx create user/src/components/Example/index.jsx create user/jest.config.js create user/test/simple_test.js

⏳ Installing devDependencies: @neutrinojs/react-components@^9.0.0-rc.3, neutrino@^9.0.0-rc.3, prop-types@^15, react@^16, react-dom@^16, webpack@^4, webpack-cli@^3, webpack-dev-server@^3, @neutrinojs/jest@^9.0.0-rc.3, jest@^24, @neutrinojs/airbnb@^9.0.0-rc.3, eslint@^5 ⏳ Performing one-time lint βœ– The command "yarn lint --fix" exited unsuccessfully. βœ– Cleaning up the incomplete project directory. βœ– Try again with the --debug flag for more information and to skip cleanup.

Please try to answer the following questions:

create project works without Airbnb style rules:

? πŸ€” First up, what would you like to create? Components ? πŸ€” Next, what kind of components would you like to create? React Components ? πŸ€” Would you like to add a test runner to your project? Jest ? πŸ€” Would you like to add linting to your project? None

edmorley commented 5 years ago

Hi! What does the output show when using --debug (mentioned in the error message)?

Tassfighter commented 5 years ago

Intresting!

npx @neutrinojs/create-project@next user --debug

⏳  Performing one-time lint
yarn run v1.15.2
$ eslint --cache --format codeframe --ext mjs,jsx,js src test --fix
error: 'react' should be listed in the project's dependencies, not devDependencies (import/no-extraneous-dependencies) at src/components/Example/index.jsx:1:1:
> 1 | import React, { useState } from 'react';
    | ^
  2 | 
  3 | // From https://reactjs.org/docs/hooks-state.html
  4 | export default function Example() {

error: 'react' should be listed in the project's dependencies, not devDependencies (import/no-extraneous-dependencies) at src/index.jsx:1:1:
> 1 | import React from 'react';
    | ^
  2 | import { render } from 'react-dom';
  3 | import Example from './components/Example';
  4 | 

error: 'react-dom' should be listed in the project's dependencies, not devDependencies (import/no-extraneous-dependencies) at src/index.jsx:2:1:
  1 | import React from 'react';
> 2 | import { render } from 'react-dom';
    | ^
  3 | import Example from './components/Example';
  4 | 
  5 | render(<Example />, document.getElementById('root'));

3 errors found.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
βœ– The command "yarn lint --fix" exited unsuccessfully.
Tassfighter commented 5 years ago

without --debug flag: npx

@neutrinojs/create-project@next user

creates no project


with --debug flag:
npx

@neutrinojs/create-project@next user --debug

project is created anyways.

Tassfighter commented 5 years ago

The lint error remains (of course). My workaround is to turn off the rule import/no-extraneous-dependencies in .neutrionrc.js

const airbnb = require('@neutrinojs/airbnb');
const reactComponents = require('@neutrinojs/react-components');
const jest = require('@neutrinojs/jest');

module.exports = {
  options: {
    root: __dirname,
  },
  use: [
    airbnb({
      eslint: {
        baseConfig: {
          rules: {
            // solves: 'react' should be listed in the project's dependencies, not devDependencies
            'import/no-extraneous-dependencies': 'off',
          },
        },
      },
    }),
    reactComponents(),
    jest(),
  ],
};
edmorley commented 5 years ago

Thank you for filing this. It looks to be a regression from #949 in v9.0.0-rc.1.

I've opened #1413 to fix, and in the meantime you can use --debug to prevent the generated project from being deleted, then manually add react, react-dom and prop-types under peerDependencies in the project's package.json. You will then need to delete the .eslintcache file to ensure ESLint picks up the change (due to caching issues with eslint-plugin-import).