NEW: Run JS/CSS linting in Travis.

The ‘npm run lint’ command will be used to run listing on Travis, which
can also be used on local dev environments. These can also be used with
editor plugins to highlight errors immediately.

The intention is that this can be used in place of codeclimate. The
benefits are that we use a single toolchain in both CI and local dev,
which is not entirely the case at the moment.

Note the sass-lint is provided by “sudo gem install scss_lint”. It’s
possible that we can move to a node-based sass-lint; I can’t recall
what the motivation for using the scss_lint gem was - I think it was
mainly that we had the AirBNB styleguide already implemented as a linter
config.
This commit is contained in:
Sam Minnee 2016-09-15 18:12:55 +12:00
parent 6f28ac5365
commit f700d86557
4 changed files with 5 additions and 22 deletions

View File

@ -1,19 +0,0 @@
engines:
eslint:
enabled: true
scss-lint:
enabled: true
duplication:
enabled: true
config:
languages:
javascript:
mass_threshold: 100
ratings:
paths:
- client/src/**
- admin/client/src/**
exclude_paths:
- "**/*"
- "!client/src/**"
- "!admin/client/src/**"

View File

@ -48,8 +48,7 @@ before_script:
- "if [ \"$DB\" = \"PGSQL\" ]; then composer require silverstripe/postgresql:2.0.x-dev --prefer-dist; fi"
- "if [ \"$DB\" = \"SQLITE\" ]; then composer require silverstripe/sqlite3:2.0.x-dev --prefer-dist; fi"
- "if [ \"$CMS_TEST\" = \"1\" ]; then COMPOSER_ROOT_VERSION=4.0.x-dev composer require silverstripe/cms:4.0.x-dev silverstripe/siteconfig:4.0.x-dev silverstripe/reports:4.0.x-dev --prefer-dist; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then nvm install $TRAVIS_NODE_VERSION && npm install; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then nvm install $TRAVIS_NODE_VERSION && npm install && gem install scss_lint; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then sh -e /etc/init.d/xvfb start; sleep 3; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/selenium-server-standalone > selenium.log 2>&1 &); fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ]; then (vendor/bin/serve --bootstrap-file tests/behat/serve-bootstrap.php &> serve.log &); fi"
@ -59,6 +58,7 @@ script:
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"\" ]; then vendor/bin/behat --config tests/behat/config.yml .; fi"
- "if [ \"$BEHAT_TEST\" = \"1\" ] && [ \"$CMS_TEST\" = \"1\" ]; then vendor/bin/behat @cms --config cms/tests/behat/behat.yml; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then npm run test; fi"
- "if [ \"$NPM_TEST\" = \"1\" ]; then npm run lint; fi"
after_failure:
- php ~/travis-support/travis_upload_artifacts.php --if-env BEHAT_TEST,ARTIFACTS_BUCKET,ARTIFACTS_KEY,ARTIFACTS_SECRET --target-path $TRAVIS_REPO_SLUG/$TRAVIS_BUILD_ID/$TRAVIS_JOB_ID --artifacts-base-url https://s3.amazonaws.com/$ARTIFACTS_BUCKET/

View File

@ -54,9 +54,11 @@ h1 {
background: $table-bg-hover;
}
// scss-lint:disable SelectorDepth
tr:first-child td {
border-top: $table-border-width solid $border-color-light;
}
// scss-lint:enable SelectorDepth
}
tfoot {

View File

@ -15,7 +15,7 @@
"lock": "npm-shrinkwrap --dev",
"test": "NODE_PATH=\"./client/src:./admin/client/src\" jest",
"coverage": "NODE_PATH=\"./client/src:./admin/client/src\" jest --coverage",
"lint": "eslint client/src & eslint admin/client/src"
"lint": "eslint client/src & eslint admin/client/src & scss-lint -c .scss-lint.yml"
},
"repository": {
"type": "git",