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

Introduce ESLint #10

Merged
merged 8 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
206 changes: 206 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"parserOptions": {
"sourceType": "module"
},
"globals": {
"estatico": true,
"Modernizr": false,
"open": true,
"name": true,
"Promise": false
},
"rules": {
"no-bitwise": 2,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation http://eslint.org/docs/rules/no-bitwise and even to previous versions of the documentation (https://github.com/eslint/eslint/blob/master/docs/rules/no-bitwise.md) "no-bitwise" should not admit a number as a value. Additionally, configuring "extends": "eslint:recommended" would also bring this by default as an error, and if ESLint changes the API for this rule we wouldn't need to worry about it in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orioltf, every rule takes a number, if I'm not mistaken: http://eslint.org/docs/user-guide/configuring#configuring-rules

"camelcase": [
2,
{
"properties": "never"
}
],
"curly": [
2,
"all"
],
"eqeqeq": 2,
"guard-for-in": 2,
"no-extend-native": 2,
"wrap-iife": 2,
"indent": [
2,
"tab",
{
"SwitchCase": 1,
"VariableDeclarator": 1
}
],
"no-use-before-define": [
2,
{
"functions": false
}
],
"new-cap": 2,
"no-caller": 2,
"no-empty": [
2,
{
"allowEmptyCatch": true
}
],
"no-irregular-whitespace": 2,
"no-new": 2,
"no-plusplus": 0,
"quotes": [
2,
"single"
],
"no-undef": 2,
"no-unused-vars": 2,
"strict": 0,
"max-params": [
2,
6
],
"max-depth": [
2,
3
],
"max-statements": 0,
"complexity": 0,
"max-len": 0,
"semi": [
2,
"always"
],
"no-cond-assign": 0,
"no-debugger": 0,
"no-eq-null": 0,
"no-eval": 0,
"no-unused-expressions": 0,
"block-scoped-var": 0,
"no-iterator": 0,
"linebreak-style": 0,
"comma-style": [
2,
"last"
],
"no-loop-func": 0,
"no-multi-str": 0,
"require-yield": 0,
"valid-typeof": 0,
"no-proto": 0,
"no-script-url": 0,
"no-shadow": 2,
"dot-notation": 2,
"no-new-func": 0,
"no-new-wrappers": 0,
"no-invalid-this": 0,
"brace-style": [
2,
"1tbs",
{
"allowSingleLine": true
}
],
"no-mixed-spaces-and-tabs": 2,
"no-multiple-empty-lines": 2,
"no-multi-spaces": 2,
"dot-location": [
2,
"property"
],
"operator-linebreak": [
2,
"after"
],
"key-spacing": [
2,
{
"beforeColon": false,
"afterColon": true
}
],
"space-unary-ops": [
2,
{
"words": false,
"nonwords": false
}
],
"space-before-function-paren": [
2,
{
"anonymous": "ignore",
"named": "never"
}
],
"no-spaced-func": 2,
"array-bracket-spacing": [
2,
"never",
{}
],
"space-in-parens": [
2,
"never"
],
"comma-dangle": [
2,
"never"
],
"no-trailing-spaces": 2,
"yoda": [
2,
"never"
],
"eol-last": 2,
"one-var": [
2,
"always"
],
"newline-after-var": [
2,
"always"
],
"lines-around-comment": [
2,
{
"beforeLineComment": true,
"allowBlockStart": true
}
],
"space-infix-ops": 2,
"keyword-spacing": [
2,
{
"overrides": {
"else": {
"before": true
},
"while": {
"before": true
},
"catch": {
"before": true
},
"in": {
"before": true
}
}
}
],
"spaced-comment": [
2,
"always"
],
"space-before-blocks": [
2,
"always"
]
}
}
30 changes: 12 additions & 18 deletions gulp/js/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ var gulp = require('gulp');
var taskName = 'js:lint',
taskConfig = {
src: [

// './gulp/**/*.js',
// './helpers/**/*.js',
// './test/**/*.js',
// '!./test/**/expected/**/*.js',
'./source/assets/js/**/*.js',
'./source/modules/**/*.js',
'./source/pages/**/*.js',
'./source/demo/modules/**/*.js',
/*'./source/demo/modules/!**!/!*.jsx',*/
'./source/demo/pages/**/*.js',
'!./source/modules/.scaffold/scaffold.js'
],
watch: [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flavaflo, if the task has its own watcher, we should probably remove it as a dependency of the js task: https://github.com/unic/estatico/blob/feature/ESTATICO-170-eslint/gulp/js/default.js#L150 (and add it to build, instead).
Otherwise, every change to a JS file will trigger the linting twice when using --skipWebpackWatch. Once directly and once as a dependency of the js task.

'./source/assets/js/**/*.js',
'./source/modules/**/*.js',
'./source/pages/**/*.js',
'./source/demo/modules/**/*.js',
'./source/demo/pages/**/*.js',
'!./source/modules/.scaffold/scaffold.js'
]
Expand All @@ -30,24 +32,16 @@ gulp.task(taskName, function() {
tap = require('gulp-tap'),
path = require('path'),
cached = require('gulp-cached'),
jshint = require('gulp-jshint'),
jscs = require('gulp-jscs');
eslint = require('gulp-eslint');

return gulp.src(taskConfig.src, {
dot: true
})
.pipe(cached('linting'))
.pipe(jshint({ linter: require('jshint-jsx').JSXHINT }))
.pipe(jscs({
configPath: '.jscsrc'

// Automatically fix invalid code (files would have to be saved back to disk below)
// fix: true
}))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jscs.reporter())
.pipe(eslint())
.pipe(eslint.formatEach())
.pipe(tap(function(file) {
if (!file.jshint.success || !file.jscs.success) {
if (file.eslint && file.eslint.errorCount > 0) {
helpers.errors({
task: taskName,
message: 'Linting error in file "' + path.relative('./source/', file.path) + '" (details above)'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@backflip we can now remove jshint-stylish also from the package.json

Expand Down