Commit 20607b61 authored by Eric Eastwood's avatar Eric Eastwood

Add Prettier automatic formatting (linting)

parent 8dc3369c
......@@ -7,28 +7,16 @@
"ecmaVersion": 2017,
"sourceType": "script"
},
"plugins": [
"node"
],
"extends": "eslint:recommended",
"plugins": ["node"],
"extends": ["eslint:recommended", "prettier"],
"rules": {
"indent": "off",
"comma-dangle": "off",
"quotes": "off",
"eqeqeq": [
"warn",
"allow-null"
],
"strict": [
"error",
"safe"
],
"no-unused-vars": [
"warn"
],
"no-extra-boolean-cast": [
"warn"
],
"eqeqeq": ["warn", "allow-null"],
"strict": ["error", "safe"],
"no-unused-vars": ["warn"],
"no-extra-boolean-cast": ["warn"],
"complexity": [
"error",
{
......@@ -48,25 +36,14 @@
"no-useless-call": "error",
"no-spaced-func": "error",
"no-useless-escape": "warn",
"max-statements": [
"warn",
30
],
"max-depth": [
"error",
4
],
"no-throw-literal": [
"error"
],
"max-statements": ["warn", 30],
"max-depth": ["error", 4],
"no-throw-literal": ["error"],
"no-sequences": "error",
"no-warning-comments": [
"warn",
{
"terms": [
"fixme",
"xxx"
],
"terms": ["fixme", "xxx"],
"location": "anywhere"
}
],
......@@ -75,14 +52,8 @@
"no-nested-ternary": "warn",
"no-whitespace-before-property": "error",
"no-trailing-spaces": ["error"],
"space-in-parens": [
"warn",
"never"
],
"max-nested-callbacks": [
"error",
6
],
"space-in-parens": ["warn", "never"],
"max-nested-callbacks": ["error", 6],
"eol-last": "warn",
"no-mixed-spaces-and-tabs": "error",
"no-negated-condition": "warn",
......
......@@ -27,6 +27,10 @@ validate:
script:
- "echo 'TODO: Skip validation for now because we have new eslint failures'"
- make validate
# TODO: This should be part of `make validate` -> `gulpfile-linter`
# but the prettier API doesn't easily allow glob checking and I want
# to re-use the scripts that GitLab has, https://gitlab.com/gitlab-org/gitlab-ce/issues/57010
- npm run prettier -- --check "**/*.js"
test:
......
{
"printWidth": 100,
"singleQuote": true
}
......@@ -3,6 +3,10 @@
- Update `@gitterhq/translations@1.8.2` dependency for Chinese(`zh`) translation update
- Thanks to [@imba-tjd](https://gitlab.com/imba-tjd) for the contribution, https://gitlab.com/gitlab-org/gitter/gitter-translations/merge_requests/66
Developer facing:
- Add Prettier automatic formatting for simple lint compliance, https://gitlab.com/gitlab-org/gitter/webapp/merge_requests/1292
# 19.34.0 - 2018-1-25
......
......@@ -12,6 +12,8 @@ var github = require('gulp-github');
var eslintFilter = require('./eslint-filter');
var del = require('del');
const JS_GLOBS = ['**/*.js','!node_modules/**', '!node_modules_linux/**', '!public/repo/**'];
function guessBaseBranch() {
var branch = process.env.CI_COMMIT_REF_NAME || process.env.GIT_BRANCH;
if (!branch) return 'develop';
......@@ -31,7 +33,7 @@ gulp.task('linter:validate:config', function() {
// Full eslint
gulp.task('linter:validate:eslint', function() {
mkdirp.sync('output/eslint/');
return gulp.src(['**/*.js','!node_modules/**', '!node_modules_linux/**', '!public/repo/**'])
return gulp.src(JS_GLOBS)
.pipe(eslint({
quiet: argv.quiet,
fix: argv.fix,
......@@ -50,7 +52,7 @@ gulp.task('linter:validate:eslint-diff', function() {
var baseBranch = process.env.BASE_BRANCH || guessBaseBranch();
gutil.log('Performing eslint comparison to', baseBranch);
var eslintPipe = gulp.src(['**/*.js','!node_modules/**', '!node_modules_linux/**', '!public/repo/**'], { read: false })
var eslintPipe = gulp.src(JS_GLOBS, { read: false })
.pipe(eslintFilter.filterFiles(baseBranch))
.pipe(eslint({
quiet: argv.quiet
......@@ -73,8 +75,11 @@ gulp.task('linter:validate:eslint-diff', function() {
/**
* Hook into the validate phase
*/
gulp.task('linter:validate', ['linter:validate:config', 'linter:validate:eslint'/*, 'linter:validate:eslint-diff'*/]);
gulp.task('linter:validate', [
'linter:validate:config',
'linter:validate:eslint',
// 'linter:validate:eslint-diff',
]);
gulp.task('linter:clean', function (cb) {
del([
......
......@@ -6287,6 +6287,23 @@
}
}
},
"eslint-config-prettier": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-3.6.0.tgz",
"integrity": "sha512-ixJ4U3uTLXwJts4rmSVW/lMXjlGwCijhBJHk8iVqKKSifeI0qgFEfWl8L63isfc8Od7EiBALF6BX3jKLluf/jQ==",
"dev": true,
"requires": {
"get-stdin": "^6.0.0"
},
"dependencies": {
"get-stdin": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
"integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
"dev": true
}
}
},
"eslint-plugin-es": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-1.4.0.tgz",
......@@ -6337,6 +6354,15 @@
}
}
},
"eslint-plugin-prettier": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.1.tgz",
"integrity": "sha512-/PMttrarPAY78PLvV3xfWibMOdMDl57hmlQ2XqFeA37wd+CJ7WSxV7txqjVPHi/AAFKd2lX0ZqfsOc/i5yFCSQ==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0"
}
},
"eslint-scope": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz",
......@@ -6697,6 +6723,12 @@
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ="
},
"fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"fast-json-stable-stringify": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
......@@ -22446,6 +22478,21 @@
"integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=",
"dev": true
},
"prettier": {
"version": "1.16.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.16.1.tgz",
"integrity": "sha512-XXUITwIkGb3CPJ2hforHah/zTINRyie5006Jd2HKy2qz7snEJXl0KLfsJZW/wst9g6R2rFvqba3VpNYdu1hDcA==",
"dev": true
},
"prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"requires": {
"fast-diff": "^1.1.2"
}
},
"pretty-bytes": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-3.0.1.tgz",
......
......@@ -192,9 +192,11 @@
"del": "^3.0.0",
"dragula": "^3.7.1",
"eslint": "^5.9.0",
"eslint-config-prettier": "^3.6.0",
"eslint-plugin-jquery": "^1.3.2",
"eslint-plugin-mocha": "^5.2.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.1",
"fastclick": "^1.0.6",
"fastdom": "^1.0.1",
"faye": "^1.1.2",
......@@ -240,6 +242,7 @@
"path-parse": "^1.0.5",
"postcss": "^4.0.0",
"postcss-loader": "^1.3.3",
"prettier": "^1.16.1",
"progress-bar-webpack-plugin": "^1.2.0",
"proxyquire": "0.4.0",
"pump": "^1.0.1",
......@@ -270,7 +273,6 @@
"main": "web.js",
"scripts": {
"gulp": "gulp",
"task-validate-diff": "gulp validate-eslint-diff",
"start": "gulp watch",
"dev": "gulp watch",
"dev-template": "concurrently --raw \"npm run start -- --watch server --watch shared --watch modules --watch public --ignore public/**/!(*.hbs)\" \"gulp watch\"",
......@@ -279,8 +281,10 @@
"nyc": "nyc",
"nodeselektor": "ns",
"node-gyp": "node-gyp",
"prettier": "prettier",
"task-css": "gulp css:compile",
"task-fasttest": "gulp test:test --test-fast",
"task-validate-diff": "gulp validate-eslint-diff",
"precommit-checks": "eslint --cache --quiet --format unix --ext .js . && gulp linter:validate:config test:test --test-fast --test-critical-only",
"task-validate": "gulp validate",
"task-watch": "gulp watch",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment