diff --git a/.eslintrc.json b/.eslintrc.json index 2a896ea5262..83e486c3f0a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,10 +1,16 @@ { + "extends": [ + "prettier" + ], + "plugins": [ + "prettier" + ], "rules": { "no-bitwise": 0, "curly": 2, "eqeqeq": 2, "guard-for-in": 0, - "wrap-iife": [2, "outside"], + "wrap-iife": [2, "inside"], "no-use-before-define": 0, "new-cap": [0, { "capIsNewExceptions": [ @@ -47,7 +53,13 @@ "no-trailing-spaces": 0, "eol-last": 0, - "max-len": [1, 120] + "max-len": [1, 120], + "prettier/prettier": [ + "error", + { + "tabWidth": 4 + } + ] }, "globals": { "brackets": false, diff --git a/Gruntfile.js b/Gruntfile.js index 80b0cb77cd5..79c45d8781e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -282,6 +282,7 @@ module.exports = function (grunt) { '!src/thirdparty/**', '!src/widgets/bootstrap-*.js', '!src/extensions/default/brackets-show-whitespace/**', + '!src/extensions/default/brackets-paste-and-indent/**', '!src/extensions/**/unittest-files/**/*.js', '!src/extensions/**/thirdparty/**/*.js', '!src/extensions/dev/**', @@ -378,6 +379,13 @@ module.exports = function (grunt) { grunt: '<%= meta.grunt %>', src: '<%= meta.src %>', test: '<%= meta.test %>', + 'src-fix': { + src: '<%= meta.src %>', + options: { + fix: true, + quiet: true + } + }, options: { quiet: true } @@ -414,6 +422,13 @@ module.exports = function (grunt) { dist: { rootDir: 'dist' } + }, + githooks: { + all: { + startMarker: 'Starting prettier auto-format task', + 'pre-commit': 'eslint:src-fix exec:add-src', + endMarker: 'Prettier auto-formatting finished', + } } }; @@ -538,6 +553,7 @@ module.exports = function (grunt) { 'cleanempty', 'exec:unlocalize', 'usemin' + 'githooks' /* XXXBramble: we skip this, since we don't bother with its info, and copy it in copy:dist 'build-config' */ ]); diff --git a/package.json b/package.json index d1c55d685c5..3d983d07e20 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "grunt-contrib-requirejs": "0.4.1", "grunt-contrib-uglify": "^2.3.0", "grunt-contrib-watch": "0.4.3", - "grunt-eslint": "18.1.0", + "grunt-eslint": "19.0.0", "grunt-exec": "^1.0.1", "grunt-jasmine-node": "0.1.0", "grunt-lib-phantomjs": "0.3.0", @@ -49,6 +49,10 @@ }, "devDependencies": { "bluebird": "^3.4.7", + "eslint-config-prettier": "^1.6.0", + "eslint-plugin-prettier": "^2.0.1", + "prettier": "^0.22.0", + "grunt-githooks": "^0.6.0", "gunzip-maybe": "^1.3.1", "http-server": "mozilla/http-server#gzip", "mkdirp": "0.5.1",