JSRocksHQ / harmonic

The next static site generator
http://harmonicjs.com/
MIT License
282 stars 26 forks source link

Fix lint errors #162

Closed viniciusdacal closed 9 years ago

viniciusdacal commented 9 years ago

All tests are ok, but we need a close review here.

viniciusdacal commented 9 years ago

issue #160 @jaydson @UltCombo

UltCombo commented 9 years ago

Nice work! I've took a quick look and added some review comments, will do a more throughout review when I get home. This is looking very nice, excellent work. :smile:

viniciusdacal commented 9 years ago

I replaced let for const Thanks Man :smile:

UltCombo commented 9 years ago

Awesome! I'll do a full review and merge it tonight. This also reminds me that we should add the "prefer const over let" to our style guide. There are a few other code style nits in the current code base, but you don't have to worry about these minor things, I'll just fix them after merging this. :smile_cat:

UltCombo commented 9 years ago

Fantastic work! Merged, and fixed some code style nits -- no multiple declarations per const/let, space between ) { etc. I wonder if ESLint has rules for these.

jaydson commented 9 years ago

Great job guys!

jaydson commented 9 years ago

Hey guys, I still have ✖ 167 problems (167 errors, 0 warnings). What I missing here?

viniciusdacal commented 9 years ago

wow. That is more than I had before this merge. maybe could be your babel-eslint version. Here I have 3.1.23 Could you post the report here?

jaydson commented 9 years ago

I've tried with 3.1.23 and i still having those errors. Pretty odd. Maybe we're missing something.

@UltCombo any thought?

UltCombo commented 9 years ago

@jaydson did you update all the dependencies? Please try:

cd path/to/harmonic-repository
rm -rf node_modules
npm install

Then run npm test. If it still has errors, then post the log output here so we can further debug it. :smiley:

p.s. Right now, npm install will automatically run npm test, but this will change as soon as we pull es20xx's updates.

jaydson commented 9 years ago

npm run dev -> 167 errors npm test -> all good

UltCombo commented 9 years ago

@jaydson That's odd, both test and dev scripts use the same plugins with the same configs, as far as I know.

By any chance, do you have an .eslintrc file in your home directory, or somewhere in the directory hierarchy above the harmonic repository directory?

jaydson commented 9 years ago

Yep, that's pretty odd indeed. I don't have any other .eslintrc file.

Follows the log:

jaydson@jaydson:~/Workspace/harmonic$ npm run dev

> harmonic@0.5.0 dev /home/jaydson/Workspace/harmonic
> gulp

[16:00:19] Using gulpfile ~/Workspace/harmonic/gulpfile.js
[16:00:19] Starting 'clean'...
[16:00:19] Finished 'clean' after 2.66 ms
[16:00:19] Starting 'default'...
[16:00:20] Watching src/ directory for changes...
[16:00:24] 
/home/jaydson/Workspace/harmonic/src/test/main.js
    4:7   error  There should be no space after '{'   space-in-brackets
    4:21  error  There should be no space before '}'  space-in-brackets
    5:7   error  There should be no space after '{'   space-in-brackets
    5:14  error  There should be no space before '}'  space-in-brackets
    6:7   error  There should be no space after '{'   space-in-brackets
    6:49  error  There should be no space before '}'  space-in-brackets
    7:7   error  There should be no space after '{'   space-in-brackets
    7:28  error  There should be no space before '}'  space-in-brackets
    8:7   error  There should be no space after '{'   space-in-brackets
    8:28  error  There should be no space before '}'  space-in-brackets
   11:7   error  There should be no space after '{'   space-in-brackets
   11:55  error  There should be no space before '}'  space-in-brackets
   12:7   error  There should be no space after '{'   space-in-brackets
   12:19  error  There should be no space before '}'  space-in-brackets
  136:31  error  There should be no space after '{'   space-in-brackets
  136:52  error  There should be no space before '}'  space-in-brackets

/home/jaydson/Workspace/harmonic/src/bin/config.js
  1:7   error  There should be no space after '{'   space-in-brackets
  1:25  error  There should be no space before '}'  space-in-brackets
  5:7   error  There should be no space after '{'   space-in-brackets
  5:17  error  There should be no space before '}'  space-in-brackets

/home/jaydson/Workspace/harmonic/src/bin/core.js
   2:0   error  Line 2 exceeds the maximum line length of 100   max-len
   2:7   error  There should be no space after '{'              space-in-brackets
   2:85  error  There should be no space before '}'             space-in-brackets
   4:7   error  There should be no space after '{'              space-in-brackets
   4:18  error  There should be no space before '}'             space-in-brackets
   7:7   error  There should be no space after '{'              space-in-brackets
   7:15  error  There should be no space before '}'             space-in-brackets
   9:15  error  Unexpected space after *                        generator-star-spacing
  19:44  error  There should be no space after '{'              space-in-brackets
  19:59  error  There should be no space before '}'             space-in-brackets
  23:0   error  Line 23 exceeds the maximum line length of 100  max-len
  24:0   error  Line 24 exceeds the maximum line length of 100  max-len
  28:0   error  Line 28 exceeds the maximum line length of 100  max-len
  36:12  error  Missing trailing comma                          comma-dangle

/home/jaydson/Workspace/harmonic/src/bin/helpers.js
   1:7   error  There should be no space after '{'              space-in-brackets
   1:22  error  There should be no space before '}'             space-in-brackets
   2:7   error  There should be no space after '{'              space-in-brackets
   2:23  error  There should be no space before '}'             space-in-brackets
   5:7   error  There should be no space after '{'              space-in-brackets
   6:62  error  There should be no space before '}'             space-in-brackets
  14:33  error  Missing trailing comma                          comma-dangle
  45:0   error  Line 45 exceeds the maximum line length of 100  max-len
  67:0   error  Line 67 exceeds the maximum line length of 100  max-len

/home/jaydson/Workspace/harmonic/src/bin/parser.js
    3:7    error  There should be no space after '{'               space-in-brackets
    3:62   error  There should be no space before '}'              space-in-brackets
    8:7    error  There should be no space after '{'               space-in-brackets
    8:13   error  There should be no space before '}'              space-in-brackets
   12:7    error  There should be no space after '{'               space-in-brackets
   12:39   error  There should be no space before '}'              space-in-brackets
   13:7    error  There should be no space after '{'               space-in-brackets
   13:29   error  There should be no space before '}'              space-in-brackets
   41:5    error  Missing trailing comma                           comma-dangle
   52:27   error  Missing trailing comma                           comma-dangle
   61:68   error  There should be no space after '{'               space-in-brackets
   61:83   error  There should be no space before '}'              space-in-brackets
   64:10   error  Unexpected space after *                         generator-star-spacing
   66:62   error  There should be no space after '{'               space-in-brackets
   66:81   error  There should be no space before '}'              space-in-brackets
   69:10   error  Unexpected space after *                         generator-star-spacing
   81:72   error  There should be no space after '{'               space-in-brackets
   81:91   error  There should be no space before '}'              space-in-brackets
   82:61   error  There should be no space after '{'               space-in-brackets
   82:87   error  There should be no space before '}'              space-in-brackets
   95:72   error  There should be no space after '{'               space-in-brackets
   95:91   error  There should be no space before '}'              space-in-brackets
   99:0    error  Line 99 exceeds the maximum line length of 100   max-len
  107:13   error  Missing trailing comma                           comma-dangle
  117:10   error  Unexpected space after *                         generator-star-spacing
  118:99   error  There should be no space after '{'               space-in-brackets
  118:118  error  There should be no space before '}'              space-in-brackets
  118:0    error  Line 118 exceeds the maximum line length of 100  max-len
  126:10   error  Unexpected space after *                         generator-star-spacing
  127:0    error  Line 127 exceeds the maximum line length of 100  max-len
  145:33   error  Missing trailing comma                           comma-dangle
  148:0    error  Line 148 exceeds the maximum line length of 100  max-len
  156:10   error  Unexpected space after *                         generator-star-spacing
  157:0    error  Line 157 exceeds the maximum line length of 100  max-len
  166:36   error  Missing trailing comma                           comma-dangle
  169:0    error  Line 169 exceeds the maximum line length of 100  max-len
  176:10   error  Unexpected space after *                         generator-star-spacing
  177:105  error  There should be no space after '{'               space-in-brackets
  177:0    error  Line 177 exceeds the maximum line length of 100  max-len
  177:123  error  There should be no space before '}'              space-in-brackets
  181:10   error  Unexpected space after *                         generator-star-spacing
  184:78   error  There should be no space after '{'               space-in-brackets
  184:96   error  There should be no space before '}'              space-in-brackets
  188:10   error  Unexpected space after *                         generator-star-spacing
  198:66   error  Missing trailing comma                           comma-dangle
  211:35   error  Missing trailing comma                           comma-dangle
  234:37   error  Missing trailing comma                           comma-dangle
  238:38   error  Missing trailing comma                           comma-dangle
  242:41   error  Missing trailing comma                           comma-dangle
  246:37   error  Missing trailing comma                           comma-dangle
  247:17   error  Missing trailing comma                           comma-dangle
  247:18   error  Missing trailing comma                           comma-dangle
  268:34   error  Missing trailing comma                           comma-dangle
  274:34   error  Missing trailing comma                           comma-dangle
  290:0    error  Line 290 exceeds the maximum line length of 100  max-len
  299:10   error  Unexpected space after *                         generator-star-spacing
  304:66   error  Missing trailing comma                           comma-dangle
  328:41   error  Missing trailing comma                           comma-dangle
  332:37   error  Missing trailing comma                           comma-dangle
  333:17   error  Missing trailing comma                           comma-dangle
  333:18   error  Missing trailing comma                           comma-dangle
  345:34   error  Missing trailing comma                           comma-dangle
  350:30   error  Missing trailing comma                           comma-dangle
  375:10   error  Unexpected space after *                         generator-star-spacing
  386:10   error  Unexpected space after *                         generator-star-spacing
  398:10   error  Unexpected space after *                         generator-star-spacing
  399:0    error  Line 399 exceeds the maximum line length of 100  max-len
  399:94   error  There should be no space after '{'               space-in-brackets
  399:113  error  There should be no space before '}'              space-in-brackets
  402:0    error  Line 402 exceeds the maximum line length of 100  max-len
  402:72   error  There should be no spaces inside this paren      space-in-parens
  402:90   error  There should be no spaces inside this paren      space-in-parens
  415:30   error  Missing trailing comma                           comma-dangle
  419:36   error  Missing trailing comma                           comma-dangle

/home/jaydson/Workspace/harmonic/src/bin/theme.js
   1:7   error  There should be no space after '{'              space-in-brackets
   1:23  error  There should be no space before '}'             space-in-brackets
   2:7   error  There should be no space after '{'              space-in-brackets
   2:22  error  There should be no space before '}'             space-in-brackets
  19:60  error  There should be no space after '{'              space-in-brackets
  19:79  error  There should be no space before '}'             space-in-brackets
  23:0   error  Line 23 exceeds the maximum line length of 100  max-len

/home/jaydson/Workspace/harmonic/src/bin/cli/harmonic.js
  4:7   error  There should be no space after '{'   space-in-brackets
  4:17  error  There should be no space before '}'  space-in-brackets
  5:7   error  There should be no space after '{'   space-in-brackets
  5:18  error  There should be no space before '}'  space-in-brackets
  7:7   error  There should be no space after '{'   space-in-brackets
  7:36  error  There should be no space before '}'  space-in-brackets
  8:7   error  There should be no space after '{'   space-in-brackets
  8:15  error  There should be no space before '}'  space-in-brackets

/home/jaydson/Workspace/harmonic/src/bin/cli/logo.js
  1:7   error  There should be no space after '{'   space-in-brackets
  1:17  error  There should be no space before '}'  space-in-brackets
  2:7   error  There should be no space after '{'   space-in-brackets
  2:18  error  There should be no space before '}'  space-in-brackets

/home/jaydson/Workspace/harmonic/src/bin/cli/util.js
    3:7    error  There should be no space after '{'               space-in-brackets
    3:62   error  There should be no space before '}'              space-in-brackets
    9:7    error  There should be no space after '{'               space-in-brackets
    9:13   error  There should be no space before '}'              space-in-brackets
   11:7    error  There should be no space after '{'               space-in-brackets
   11:25   error  There should be no space before '}'              space-in-brackets
   13:7    error  There should be no space after '{'               space-in-brackets
   13:39   error  There should be no space before '}'              space-in-brackets
   14:0    error  Line 14 exceeds the maximum line length of 100   max-len
   14:123  error  There should be no space before '}'              space-in-brackets
   14:7    error  There should be no space after '{'               space-in-brackets
   15:7    error  There should be no space after '{'               space-in-brackets
   15:15   error  There should be no space before '}'              space-in-brackets
   22:7    error  There should be no space after '{'               space-in-brackets
   22:46   error  There should be no space before '}'              space-in-brackets
   45:19   error  Missing space before *                           generator-star-spacing
   68:46   error  Missing trailing comma                           comma-dangle
   69:17   error  Missing trailing comma                           comma-dangle
   93:44   error  Missing trailing comma                           comma-dangle
   99:0    error  Line 99 exceeds the maximum line length of 100   max-len
  110:15   error  Unexpected space after *                         generator-star-spacing
  114:43   error  There should be no space after '{'               space-in-brackets
  114:61   error  There should be no space before '}'              space-in-brackets
  126:0    error  Line 126 exceeds the maximum line length of 100  max-len
  180:15   error  Unexpected space after *                         generator-star-spacing
  205:21   error  Missing trailing comma                           comma-dangle
  206:17   error  Missing trailing comma                           comma-dangle
  209:26   error  Missing trailing comma                           comma-dangle
  215:19   error  Unexpected space after *                         generator-star-spacing
  232:19   error  Unexpected space after *                         generator-star-spacing
  244:0    error  Line 244 exceeds the maximum line length of 100  max-len
  249:21   error  Missing trailing comma                           comma-dangle
  261:11   error  There should be no space after '{'               space-in-brackets
  261:21   error  There should be no space before '}'              space-in-brackets

✖ 170 problems (170 errors, 0 warnings)

  CLI
    ✓ should display an error for unknown commands (1070ms)
    ✓ should init a new Harmonic site (2254ms)
    ✓ should build the Harmonic site (1166ms)
    ✓ should create and build a new post (2251ms)
    - should create and build a new page

  helpers
    ✓ .isHarmonicProject() should return whether the CWD is a Harmonic site
    ✓ .titleToFilename() should transform a post/page title into a filename

  API
    ✓ should merge the theme's config into the main config

  7 passing (7s)
  1 pending

[16:00:31] These files have linting issues:
/home/jaydson/Workspace/harmonic/src/test/main.js
/home/jaydson/Workspace/harmonic/src/bin/config.js
/home/jaydson/Workspace/harmonic/src/bin/core.js
/home/jaydson/Workspace/harmonic/src/bin/helpers.js
/home/jaydson/Workspace/harmonic/src/bin/parser.js
/home/jaydson/Workspace/harmonic/src/bin/theme.js
/home/jaydson/Workspace/harmonic/src/bin/cli/harmonic.js
/home/jaydson/Workspace/harmonic/src/bin/cli/logo.js
/home/jaydson/Workspace/harmonic/src/bin/cli/util.js
[16:00:31] Batch completed. Watching src/ directory for changes...
UltCombo commented 9 years ago

@jaydson Oh, we had temporarily commented out npm test's linting step, so that's why npm test is not displaying linting errors hah.

It looks like there's something affecting your ESLint settings, it is reporting errors on rules which are off by default and not enabled by our .eslintrc file.

Can you double-check whether there's any other .eslintrc up in the directory hierarchy? Here's a quick and dirty script to help with that:

cd path/to/harmonic
node -p "var sep = require('path').sep; process.cwd().split(sep).map(function(v, i, a) { return a.slice(0, i).concat(v).join(sep) + sep + '.eslintrc'; }).filter(require('fs').existsSync).join('\n');"

See if it doesn't return any extraneous .eslintrc files.

jaydson commented 9 years ago
jaydson@jaydson:~/Workspace/harmonic$ node -p "var sep = require('path').sep; process.cwd().split(sep).map(function(v, i, a) { return a.slice(0, i).concat(v).join(sep) + sep + '.eslintrc'; }).filter(require('fs').existsSync).join('\n');"
/home/jaydson/Workspace/.eslintrc
/home/jaydson/Workspace/harmonic/.eslintrc

You're totally right. So, ESLint any .eslintrc file will overwrite Harmonic's rc file? That's weird. But ok, now i have it working perfectly.

Thank you guys!

UltCombo commented 9 years ago

RC files usually work in a hierarchical manner, see ESLint - Configuration Cascading and Hierarchy. Basically, the configs are merged, and the rules in the closest .eslintrc file to the file being linted have the highest priority.

jaydson commented 9 years ago

Got it!