46 Commits

Author SHA1 Message Date
Dan Poltawski
6f601313f0 MDL-59761 eslint: support glob-based configuration
Since ESlint 4.1.0 [1], it's possible to support glob-based
configuration, this means we can move glob configuration out of grunt
and into the config file, which means tools will respect the glob rules
now too. :)

[1] http://eslint.org/blog/2017/06/eslint-v4.1.0-released
2017-09-06 08:53:50 +01:00
Dan Poltawski
09074c91d0 MDL-57945 stylelint: Upgrade 7.12.0
This stylelint is consolodating and focusing the project
so there are some rule deprecations without real alternatives yet.
2017-07-19 13:45:47 +01:00
Mark Nielsen
58923606e4 MDL-59091 behat: Properly propagate gherkinlint exit code 2017-06-02 09:27:48 -07:00
Rajesh Taneja
d44f7e4623
MDL-56519 behat: Add gherkin lint to watch and startup 2017-01-05 16:02:00 +08:00
Dan Poltawski
8b02e2d98c
MDL-56519 behat: Lint gherkin files 2017-01-03 09:12:54 +08:00
Dan Poltawski
36650f11d3 MDL-56423 stylelint: ignore custom.css files
The files have non-standard css syntax and with stylelint 7.4.1
it can no longer cope with it.
2016-10-13 10:01:31 +01:00
Dan Poltawski
d5dff6316a MDL-55168 grunt: Add plain css linting 2016-09-30 09:25:23 +01:00
Dan Poltawski
07482105c1 MDL-55165 less: use lowercase hex codes for colours
And use shorthand where possible.

Detected by
http://stylelint.io/user-guide/rules/color-hex-case/
http://stylelint.io/user-guide/rules/color-hex-length/

When reviewing this change, you can hide the case changes by
reviewing with:
GIT_EXTERNAL_DIFF='diff -ipu   #' git diff --ext-diff
2016-09-29 16:39:30 +01:00
Dan Poltawski
65f9a71fbd MDL-55165 less: ensure no units on 0 length things
Detected by http://stylelint.io/user-guide/rules/length-zero-no-unit/
2016-09-29 16:39:30 +01:00
Dan Poltawski
62ce522cde MDL-55165 less: fix various errors in less
Detected by stylelint rules:

http://stylelint.io/user-guide/rules/declaration-block-no-ignored-properties/
http://stylelint.io/user-guide/rules/declaration-block-no-duplicate-properties/
http://stylelint.io/user-guide/rules/declaration-block-no-shorthand-property-overrides/
http://stylelint.io/user-guide/rules/value-keyword-case/
http://stylelint.io/user-guide/rules/selector-type-no-unknown/
http://stylelint.io/user-guide/rules/selector-type-no-unknown/
2016-09-29 16:39:30 +01:00
Frédéric Massart
5142f56402 MDL-56063 theme_boost: Check and remove extraneous !important rules
Progress bar styling has been removed as they do not appear to
be used anywhere, though MDL-56095 has been created to style them
as (with or without the styles) they remain unstyled.

The file responsive.scss has been removed, it was not used.

Part of MDL-55071
2016-09-23 11:04:33 +01:00
Dan Poltawski
5cb8ca8610 MDL-55071 theme_boost: fixup bootswatch thirdpartylibs
Allow longhand colour codes for asthetics..
2016-09-23 10:57:54 +01:00
Dan Poltawski
46c1713c40 MDL-55071 theme_boost: fix stylelint detected issues in scss
Duplicate properties, star hacks
2016-09-23 10:57:36 +01:00
Dan Poltawski
841d25a984 MDL-55071 grunt: add stylelint:scss to default css task
Part of MDL-55071
2016-09-23 10:57:36 +01:00
Dan Poltawski
773e68b0f8 MDL-55071 stylelint: Config & grunt task for scss
Part of MDL-55071
2016-09-23 10:57:36 +01:00
Frederic Massart
d99949ab66 MDL-55377 theme_bootstrapbase: Adapt for RTL auto flipping
Part of MDL-55071
2016-09-23 10:53:08 +01:00
Dan Poltawski
d2c7175a34 MDL-55856 grunt: fail gracefully when node version too old
Unfortunately the engine requirement in packages.json is not a fatal
error, so you can get unhelpful errors with grunt if using an
unsupported version.
2016-09-15 15:32:32 +01:00
Dan Poltawski
70db37ba78 MDL-55465 grunt: ensure gruntfile is lint free
Not related to this patch, but fixed it while I was here..
2016-08-05 17:48:24 +01:00
Dan Poltawski
a26d36738a MDL-55465 grunt: Add .stylelintignore
Allow it to be generated by grunt ignorefiles
Make grunt use it rather than ignoring things manually
2016-08-05 17:48:24 +01:00
Dan Poltawski
b4fe4e25b2 MDL-55167 stylelint: disable some rules in grunt
These will be fixed in a later issue
2016-07-30 13:07:54 +01:00
Dan Poltawski
855fc5d853 MDL-55167 grunt: add stylelint css linting 2016-07-30 13:07:52 +01:00
Dan Poltawski
0e6e19179e MDL-55048 grunt: make uglify task behave as before
Don't output the status of uglifyied JS files, just the final result,
will still report what happens in detail in verbose mode
2016-07-11 15:53:10 +01:00
Dan Poltawski
ad3f8cd18c MDL-54944 eslint: make the .eslintrc default stricter
Instead of using the more rollup-tolerant config for all files, make the
configuration stricter by default but lower in grunt for yui modules.

This means that manual runs (prechecker) or editor integrations will
flag up the errors as well as grunt.

Also add ignore lines to the core files so that eslint isn't noisy when
not running with grunt.
2016-07-11 12:44:34 +01:00
Dan Poltawski
037de71996 MDL-54944 eslint: Add rules from Policy decision
Also bump eslint to v2.13.1 and make the version explicit in
package.json
2016-07-07 12:10:49 +01:00
Dan Poltawski
5f4d957c21 MDL-54889 jshint: stop using for everything but shifter
Now jshint has been replaced by eslint.
2016-06-30 09:14:57 +01:00
Dan Poltawski
a382101c6e MDL-55050 grunt: make eslint only build changed files on watch
Previously a watch change was causing eslint to be re-run on every file.
2016-06-28 18:21:29 +01:00
Dan Poltawski
f8731225f9 MDL-52127 grunt: add .eslingingore file, keep task
Eloy prefers we keep the ignorefiles grunt task
2016-06-15 15:52:34 +01:00
Dan Poltawski
b18478b935 MDL-52127 grunt: fix coding style issues in gruntfile 2016-06-14 00:37:29 +01:00
Dan Poltawski
30db70abdc MDL-52127 grunt: be aware of third party paths
1) Parse thirdpartylibs.xml and generate an array of third party
file paths to use in grunt tasks
2) In the lint tasks, we filter third party files from being linted
3) We add a new task to generate ignore files - currently for eslint,
but will be potentially useful for other things in the future
4) Remove .eslintignore from source control

Why have the ability to generate a .eslintignore file? For tooling
integration - by having the eslintignore file people can use other
eslint tools without having to just use grunt (e.g. editor
integrations).
2016-06-14 00:37:29 +01:00
Dan Poltawski
be4b3cc6c7 MDL-52127 js: switch to a more YUI tolerant eslint config
Instead of having the stricter configuration for all files, use
the less strict default config and switch to the stricter config
for building AMD modules.

This means that the eslint commandline/editor inspections will work
better for all files and not generate false positives when using editor
integrations. But since grunt is required to build AMD modules we still
get the stricter checking for those files on build.
2016-06-14 00:37:28 +01:00
Dan Poltawski
a1587268cb MDL-52127 js: check YUI modules with eslint
Because we don't have the entire YUI rollup, we can't apply some of the
rules safely, so we ignore some rules.

At this point I am not 100% certain this configuration is robust enough,
to deal with the lack fo rollup knowledge although its a good sign that
there are no errors on our entire yui codebase.
2016-06-11 10:14:35 +01:00
Dan Poltawski
3adb62b727 MDL-52127 js: check amd files with eslint grunt task
I have spent quite a lot of time working through the current list of
eslint options and configuring them for Moodle style and I think this is
a very good basis to start us at (as well as taking some of out jshint
options out with https://www.npmjs.com/package/polyjuice ). Thanks to
Andrew Nicols, Mark Johnson and Frédéric Massart for some refinements.

With this configuration the grunt build will fail if errors are present
in the js (though you can of course tell jshint to ignore some errors,
as I have done in admin/tool/lp/amd/src/competency_rule_points.js and
defining the Y global in lib/amd/src/yui.js ).

The grunt task will not report warnings by default, but a new
--show-lint-warnings flag will help achieve that. Editor
integrations/stanadalone eslint tool will surely be a better way of
getting eslint errors rather than using the grunt task.
2016-06-11 10:14:35 +01:00
Dan Poltawski
00cceb7fba MDL-50115 grunt: provide a --root option to set base path
Windows users are not able to run grunt on a subpath due to platform
restrictions. So we provide this option to provide a workaround for that.

Thanks to Ty Delean who proposed this idea.
2016-02-04 12:03:53 +00:00
Dan Poltawski
1aa454eda4 MDL-49817 grunt: handle multiple watched files changed at once
Includes multiple changes to the shifter task to simplify and
support this:
* Use grunt.file for shifter yui 'module' detection rather than our own
  70 line function
* Use grunt.util.spawn rather than our own exec for shifter
* Improve behaviour on various yui subdirectories

We have to add the 'async' depndency to npm because we are running
multiple async operations in the single task. We use async.eachSeries to
run each shifter job sequentally (else the output would be unreadable
when running async).

We also run shifter in non-recursive mode on the module directory so its
not building everything (thanks to Ryan for pointing this out!)
2016-01-28 08:30:04 +00:00
Dan Poltawski
0b777a069b MDL-49817 grunt: make shifter work watch on right place
We mess around with the cwd to find a shifter path, not ideal but avoids
having to refactor the shifter task.

Also fix jshint errors..

1) The gruntfile runs in a nodejs environment and not a browser
environment.

2) There was an uninitialised variable
2016-01-28 08:27:31 +00:00
Dan Poltawski
8efbb7b1a1 MDL-49817 grunt: add watch task
This allows files to be watched and automatically build when changed.

Thanks to David Monllaó for the initial basis for this patch.
2016-01-28 08:27:31 +00:00
Dan Poltawski
5cc5f31101 MDL-49817 grunt: Refactor the uglify task
This is in preperation for the watch task and doing a few things:

1) Switch away from 'grunt.file.expandMapping' to the declarative syntax
   for doing the same thing, as recommended in docs:
   http://gruntjs.com/api/grunt.file#grunt.file.expandmapping

2) Factor the renaming function into shared function so it can be used
   from the watch task too.

3) Shared the file glob'ing pattern for match AMD js files between
   jshint and uglify task (this removes the node_modules exception..
   we should add it to both if we need it).

4) Rename the task configuration - I am just doing this because it looks
   like 'dynamic_mappings' is some how magic config option when you
   look at the manual:
   http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

   But in fact, it's just a task confguration name.
2016-01-28 08:27:30 +00:00
Dan Poltawski
dbf6b40782 MDL-49817 grunt: jslint rename task config and make explict src
Two reasons for this change:
1) The configuration here is confusing, it seems like we are setting the
   'files' option, but in fact we are just generating a task configuration
    called 'files'. Lets try and avoid confusion.

2) It makes it possible for 'watch' to override the src
2016-01-21 15:13:45 +00:00
Andrew Nicols
dc8675fdad Merge branch 'master' of https://github.com/janeklb/moodle 2016-01-12 09:31:09 +00:00
Janek Lasocki-Biczysko
c9b6feea0e MDL-52504 grunt: fixed scope of jshint when in amd directory 2016-01-05 09:59:09 +00:00
Dan Poltawski
a07afffcce MDL-52591 grunt: make shifter task respect --no-color 2015-12-22 18:37:27 +00:00
Dan Poltawski
65d070aec8 MDL-51582 grunt: task improvements
* Introduce the 'css' task - this will give us flexibility to do things
  in future rather than relying on the inbuilt 'less' task (e.g. sourcemap
  generating task which doesn't run by default)

* Introduce 'amd' task which runs only amd tasks

* Introduce 'js' task which runs all JS (amd/shifter) tasks

* Tweak the ordering so that slow shifter always runs last (useful for
  people like me who forget to specif the task)
2015-12-04 10:37:09 +00:00
Dan Poltawski
a4a52e565e MDL-51582 grunt: add less complilation support
Previously we were using recess to build bootstrap base as it was what
was used by the original project. But recess is no longer maintained.

Now we use grunt for building js, it makes sense to use it for less too.

(If you really don't want to use grunt, you almost certainly can just
use lessc -x as it uses the same less.js on backend).
2015-12-04 10:36:45 +00:00
David Monllao
8f76bfb628 MDL-50766 grunt: Check that there are yui modules before running shifter 2015-09-11 15:11:48 +08:00
Damyon Wiese
e67585f8ca MDL-50001 grunt: Make grunt work on windows
Unfortunately, this is not perfect yet. It will build the entire
repository every time - which takes a while because it builds all the
yui modules (On linux it correctly only builds whats in the current dir).
2015-05-05 12:15:59 +08:00
Damyon Wiese
adeb96d28f MDL-49046 javascript: Add support for AMD modules and jquery.
Grunt is the build tool.
2015-02-23 16:23:10 +08:00