meanjs / generator-meanjs

MEAN.JS Official Yeoman Generator
http://meanjs.org/
472 stars 178 forks source link

crud-module generator introduces lots of errors #220

Closed jedau closed 8 years ago

jedau commented 8 years ago

It seems that it's introducing lots of whitespaces to the generated code.

I ran:

/workspace/starterMEANProject/mean$ yo meanjs:crud-module customer
? What is the name of the module? customer
? Which client-side folders would you like your module to include? css, img, directives, filters
? Would you like to add the CRUD module links to a menu? Yes
? What is your menu identifier(Leave it empty and press ENTER for the default "topbar" menu)? topbar
   create modules/customers/client/config/customers.client.routes.js
   create modules/customers/client/controllers/customers.client.controller.js
   create modules/customers/client/controllers/list-customers.client.controller.js
   create modules/customers/client/services/customers.client.service.js
   create modules/customers/tests/client/customers.client.controller.tests.js
   create modules/customers/tests/client/customers.client.routes.tests.js
   create modules/customers/tests/client/list-customers.client.controller.tests.js
   create modules/customers/client/views/form-customer.client.view.html
   create modules/customers/client/views/view-customer.client.view.html
   create modules/customers/client/views/list-customers.client.view.html
   create modules/customers/client/config/customers.client.config.js
   create modules/customers/client/customers.client.module.js
   create modules/customers/tests/e2e/customers.e2e.tests.js
   create modules/customers/server/config/customers.server.config.js
   create modules/customers/server/controllers/customers.server.controller.js
   create modules/customers/server/models/customer.server.model.js
   create modules/customers/server/routes/customers.server.routes.js
   create modules/customers/server/policies/customers.server.policy.js
   create modules/customers/tests/server/customer.server.model.tests.js
   create modules/customers/tests/server/customer.server.routes.tests.js
/workspace/starterMEANProject/mean$ grunt

Even though I entered customer as the name of the module, the generated name is customers. Is that the correct behavior?

nodejs version: 5.11.0 generator-meanjs version: 0.4.4 yo version: 1.7.0 OS: Ubuntu 14.04.4

/workspace/starterMEANProject/mean/modules/customers/server/controllers/customers.server.controller.js
  39:121  error  Unnecessary use of boolean literals in conditional expression  no-unneeded-ternary
  48:31   error  Unexpected whitespace before semicolon                         semi-spacing
  50:32   error  There should be no space before ','                            comma-spacing
  67:31   error  Unexpected whitespace before semicolon                         semi-spacing
  83:36   error  Trailing spaces not allowed                                    no-trailing-spaces

/workspace/starterMEANProject/mean/modules/customers/client/customers.client.module.js
  1:1  error  Move the invocation into the parens that contain the function  wrap-iife

/workspace/starterMEANProject/mean/modules/customers/client/config/customers.client.config.js
  1:1  error  Move the invocation into the parens that contain the function  wrap-iife

/workspace/starterMEANProject/mean/modules/customers/client/config/customers.client.routes.js
   1:1   error  Move the invocation into the parens that contain the function  wrap-iife
  36:11  error  Extra space after key 'pageTitle'                              key-spacing
  60:14  error  Missing space before value for key 'data'                      key-spacing

/workspace/starterMEANProject/mean/modules/customers/client/controllers/customers.client.controller.js
   1:1   error    Move the invocation into the parens that contain the function  wrap-iife
  23:11  warning  Unexpected confirm                                             no-alert

/workspace/starterMEANProject/mean/modules/customers/client/controllers/list-customers.client.controller.js
  1:1  error  Move the invocation into the parens that contain the function  wrap-iife

/workspace/starterMEANProject/mean/modules/customers/client/services/customers.client.service.js
  1:1  error  Expected space or tab after '//' in comment                    spaced-comment
  2:1  error  Move the invocation into the parens that contain the function  wrap-iife

/workspace/starterMEANProject/mean/modules/customers/tests/server/customer.server.model.tests.js
  14:11  error  Expected variable declaration to be on a new line  one-var-declaration-per-line
  30:27  error  Trailing spaces not allowed                        no-trailing-spaces
  49:89  error  Trailing spaces not allowed                        no-trailing-spaces
  59:29  error  Trailing spaces not allowed                        no-trailing-spaces
  60:38  error  Missing space before opening brace                 space-before-blocks
  61:36  error  Missing space before opening brace                 space-before-blocks
  62:16  error  Trailing spaces not allowed                        no-trailing-spaces

/workspace/starterMEANProject/mean/modules/customers/tests/server/customer.server.routes.tests.js
  14:10  error  Expected variable declaration to be on a new line  one-var-declaration-per-line
  14:17  error  Expected variable declaration to be on a new line  one-var-declaration-per-line
  14:30  error  Expected variable declaration to be on a new line  one-var-declaration-per-line
  14:36  error  Expected variable declaration to be on a new line  one-var-declaration-per-line

/workspace/starterMEANProject/mean/modules/customers/tests/client/customers.client.controller.tests.js
    1:1  error  Move the invocation into the parens that contain the function  wrap-iife
   66:7  error  Expected space or tab after '//' in comment                    spaced-comment
  144:9  error  Expected space or tab after '//' in comment                    spaced-comment
  149:9  error  Expected space or tab after '//' in comment                    spaced-comment
  161:9  error  Expected space or tab after '//' in comment                    spaced-comment

/workspace/starterMEANProject/mean/modules/customers/tests/client/customers.client.routes.tests.js
    1:1   error  Move the invocation into the parens that contain the function  wrap-iife
    9:5   error  Expected space or tab after '//' in comment                    spaced-comment
   56:11  error  Expected space or tab after '//' in comment                    spaced-comment
  103:11  error  Expected space or tab after '//' in comment                    spaced-comment
  152:11  error  Expected space or tab after '//' in comment                    spaced-comment

/workspace/starterMEANProject/mean/modules/customers/tests/client/list-customers.client.controller.tests.js
   1:1  error  Move the invocation into the parens that contain the function  wrap-iife
  65:7  error  Expected space or tab after '//' in comment                    spaced-comment

I fixed them all one-by-one just to get grunt to execute properly.

EDIT: After all errors were fixed, all the pages were blank, even the index. Looking at the web inspector, it seems I encountered Error: [$injector:unpr] Unknown provider: MenusProvider <- Menus. I tried to change menuConfig.$inject in /modules/customers/client/config/customers.client.config.js to topbar, but it didn't do anything. I changed it back to menuService and it finally worked properly. I'm not quite sure what happened

teamhail commented 8 years ago

I'm having the same problem on OSX, same output. Specifically, running yo meanjs:crud-module derp kills a previously working generated install.

nodejs version: 5.11.0 generator-meanjs version: 0.4.4 yo version: 1.7.0

alexanderbluhm commented 8 years ago

I also have the same problem on OSX

jedau commented 8 years ago

@codydaig @ilanbiala any ideas what could be causing this?

axke commented 8 years ago

When you created your application using yo meanjs did you select master? I may be wrong, but it seems the generator is geared towards the 0.4.x branches of MEAN.JS.

Master is 0.5.0-beta. This would explain the issue with the menus. In 0.5.0-beta, they have renamed the service to menuService. Please read through #210, as this seems to be a duplicate.

As for the question asking if the generator should name customer to customers, I believe this is the expected behavior. The generator pluralizes module names.

jedau commented 8 years ago

@alexisio yeah, I'm on master. I just read through the other issue and it does indeed look similar. I didn't notice that because of the title while looking through the open issues. I'm closing this for now, and I'll continue to monitor the issue from the other one.

alexanderbluhm commented 8 years ago

@jedau But the bug with these errors isn't fixed, right? So something like this 39:121 error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary How can I prevent that? The bug in the other thread is about another problem, isn't it?

jedau commented 8 years ago

@IL4Miy error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary is also covered in that other issue. That's why I closed this one, so that we can all focus on that thread that was created first.

With regard to resolving that error, the way I fixed that was retool the line to look like this:

customer.isCurrentUserOwner = req.user && customer.user && customer.user._id.toString() === req.user._id.toString();

Try it out on your code. I hope that helps resolve that issue.

alexanderbluhm commented 8 years ago

@jedau This works for me but I also habe these 38 other errors. Someone hast to change the files and fork this.

jedau commented 8 years ago

@IL4Miy yeah, I guess that's why I created an Issue, so that they would notice and fix it. I fixed all of the errors one by one, so that resolved it for me. You could either do that or just wait for the fix.

I'm waiting for the fix as well, but I've since moved past this part. It would be nice to have a fix for this issue for when I create a new CRUD module for a different project.