Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint codebase using standard #290

Merged
merged 9 commits into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ before_install:
install:
- npm install
script:
- "./node_modules/grunt-cli/bin/grunt test"
- npm test
notifications:
email: false
before_deploy:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ guidelines:

## Indentation and whitespace

Your JavaScript code should pass [linting](https://github.com/alphagov/govuk_prototype_kit/blob/0d9835b7ad8d7bc06aa288204eb3ce9a07116be2/docs/linting.md).
2-space, soft-tabs only. No trailing whitespace.

## Versioning
Expand Down
61 changes: 30 additions & 31 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = function (grunt) {

grunt.initConfig({

// Builds Sass
Expand All @@ -14,7 +13,7 @@ module.exports = function (grunt) {
'public/stylesheets/elements-page-ie6.css': 'public/sass/elements-page-ie6.scss',
'public/stylesheets/elements-page-ie7.css': 'public/sass/elements-page-ie7.scss',
'public/stylesheets/elements-page-ie8.css': 'public/sass/elements-page-ie8.scss',
'public/stylesheets/prism.css': 'public/sass/prism.scss',
'public/stylesheets/prism.css': 'public/sass/prism.scss'
},
options: {
includePaths: [
Expand All @@ -29,7 +28,7 @@ module.exports = function (grunt) {

// Empty encoded snippets folder
clean: {
contents: ['app/views/snippets/encoded/*'],
contents: ['app/views/snippets/encoded/*']
},

// Copies templates and assets from external modules and dirs
Expand Down Expand Up @@ -59,19 +58,19 @@ module.exports = function (grunt) {
govuk_template_jinja: {
files: [{
expand: true,
cwd: 'govuk_modules/govuk_template/views/layouts/',
src: '**',
dest: 'lib/'
}]
},
cwd: 'govuk_modules/govuk_template/views/layouts/',
src: '**',
dest: 'lib/'
}]
}
},

// Encode HTML snippets
htmlentities: {
files: {
src: ['app/views/snippets/*.html'],
dest: 'app/views/snippets/encoded/'
},
}
},

// workaround for libsass
Expand Down Expand Up @@ -124,9 +123,9 @@ module.exports = function (grunt) {
}
}

});
})

[
;[
'grunt-contrib-clean',
'grunt-contrib-copy',
'grunt-contrib-watch',
Expand All @@ -136,16 +135,16 @@ module.exports = function (grunt) {
'grunt-shell',
'grunt-htmlentities'
].forEach(function (task) {
grunt.loadNpmTasks(task);
});
grunt.loadNpmTasks(task)
})

grunt.registerTask('default', [
'clean',
'copy',
'encode_snippets',
'sass',
'concurrent:target'
]);
])

grunt.registerTask(
'test_default',
Expand All @@ -154,45 +153,45 @@ module.exports = function (grunt) {
'copy',
'sass'
]
);
)

grunt.registerTask(
'encode_snippets',
'Encode HTML snippets',
function() {
grunt.task.run('htmlentities');
function () {
grunt.task.run('htmlentities')
}
);
)

grunt.registerTask(
'lint',
'Use govuk-scss-lint to lint the sass files',
function() {
grunt.task.run('shell', 'lint_message');
function () {
grunt.task.run('shell', 'lint_message')
}
);
)

grunt.registerTask(
'lint_message',
'Output a message once linting is complete',
function() {
grunt.log.write("scss lint is complete, without errors.");
function () {
grunt.log.write('scss lint is complete, without errors.')
}
);
)

grunt.registerTask(
'test',
'Lint the Sass files, then check the app runs',
function() {
grunt.task.run('lint', 'test_default', 'test_message');
function () {
grunt.task.run('lint', 'test_default', 'test_message')
}
);
)

grunt.registerTask(
'test_message',
'Output a message once the tests are complete',
function() {
grunt.log.write("scss lint is complete and the app runs, without errors.");
function () {
grunt.log.write('scss lint is complete and the app runs, without errors.')
}
);
};
)
}
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ Run the app
Go to [localhost:3000](http://localhost:3000) in your browser.


## Linting

### GOV.UK lint
[GOV.UK elements uses govuk-lint](https://github.com/alphagov/govuk-lint#sass), which uses [scss-lint](https://github.com/brigade/scss-lint) as its scss linter.

### Standard JavaScript
GOV.UK elements uses [standardjs](http://standardjs.com/), an opinionated JavaScript linter. All JavaScript files follow its conventions.

Both linters run on CI to ensure that new pull requests are in line with them.

## Linting

To check the whole codebase, run:

npm test

## Running Wraith to compare changes

GOV.UK elements uses Wraith so that regressions can be easily spotted.
Expand Down
2 changes: 1 addition & 1 deletion app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ module.exports = {
// Cookie warning
cookieText: 'GOV.UK uses cookies to make the site simpler. <a href="https://www.gov.uk/help/cookies" title="Find out more about cookies">Find out more about cookies</a>'

};
}
Loading