WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#27567 closed defect (bug) (fixed)

grunt jshint task for individual files does not work

Reported by: netweb Owned by: wonderboymusic
Milestone: 4.0 Priority: low
Severity: minor Version:
Component: Build/Test Tools Keywords: has-patch commit
Focuses: docs Cc:

Description

Based on the inline docs in Gruntfile.js we should be able to run the grunt task jshint on a single file using eg grunt jshint:core --file=Gruntfile.js

~/develop.wp.nw [trunk ~2 ?2]> grunt jshint:core --file=Gruntfile.js
Running "jshint:core" (jshint) task
>> 0 files linted. Please check your ignored files.

Done, without errors.
~/develop.wp.nw [trunk ~2 ?2]>

Expected result should be that file is checked and if no linting is required to return the results similar to that of running grunt jshint:grunt

~/develop.wp.nw [trunk ~2 ?2]> grunt jshint:grunt
Running "jshint:grunt" (jshint) task
>> 1 file lint free.

Done, without errors.
~/develop.wp.nw [trunk ~2 ?2]>

Attachments (3)

27567.diff (468 bytes) - added by jorbin 7 years ago.
27567.2.diff (489 bytes) - added by netweb 7 years ago.
27567.3.diff (504 bytes) - added by jorbin 7 years ago.

Download all attachments as: .zip

Change History (13)

@jorbin
7 years ago

#1 @jorbin
7 years ago

  • Keywords needs-docs has-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Priority changed from normal to low
  • Severity changed from normal to minor

Thanks Netweb,

I think this is a docs issue. Using filter on jshint:core only filters files that are found using the core task (which is non external files that live in the src directory). I've uploaded a simple patch to hopefully make this a little clearer.

The docs team may have a better idea for how to describe this.

#2 @DrewAPicture
7 years ago

  • Focuses docs added

How about:

// Limit JSHint's run to a specific core file.

#3 follow-up: @netweb
7 years ago

Awesome, understand now, and read the code ;)

For example plugin.js there are 7 files with this specific file name included via the jshint:core src: paths.

~/develop.wp.nw [trunk ~3 ?6]> grunt jshint:core --file=plugin.js
Running "jshint:core" (jshint) task
>> 7 files lint free.

Done, without errors.

Maybe // Limit JSHint's run to a specific core file name. as it will not always be a single file.

#4 in reply to: ↑ 3 ; follow-up: @DrewAPicture
7 years ago

  • Keywords needs-docs removed

Replying to netweb:

Maybe // Limit JSHint's run to a specific core file name. as it will not always be a single file.

Would you care to iterate on 27567.diff? Maybe something like:

// Limit JSHint's run to all core files with the specified file name.

@netweb
7 years ago

#5 in reply to: ↑ 4 @netweb
7 years ago

Replying to DrewAPicture:

// Limit JSHint's run to all core files with the specified file name.

Nice, Thanks, Done in 27567.2.diff​

#6 @DrewAPicture
7 years ago

  • Keywords commit added

#7 @azaozz
7 years ago

You can use this with a partial file path too:

grunt jshint:core --file=wpview/plugin.js

@jorbin
7 years ago

#8 @jorbin
7 years ago

Updated to include that you can also use parts of the file path and to include an an example of that.

#9 @jorbin
7 years ago

  • Milestone changed from Future Release to 4.0

This is an easy documentation fix. Let's do it for 4.0

#10 @wonderboymusic
7 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 28222:

More descriptive docs for grunt jshint:core.

Props netweb, jorbin.
Fixes #27567.

Note: See TracTickets for help on using tickets.