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

[WIP] Prettier plugin for eslint #703

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
16 changes: 14 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 19 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,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/**',
Expand Down Expand Up @@ -368,6 +369,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
}
Expand Down Expand Up @@ -397,13 +405,21 @@ module.exports = function (grunt) {
exec: {
localize: 'node scripts/properties2js',
'localize-dist': 'node scripts/properties2js dist',
'clean-nls': 'rm -fr src/nls && git checkout -- src/nls'
'clean-nls': 'rm -fr src/nls && git checkout -- src/nls',
'add-src': 'git add "src/*"'
},

swPrecache: {
dist: {
rootDir: 'dist'
}
},
githooks: {
all: {
startMarker: 'Starting prettier auto-format task',
'pre-commit': 'eslint:src-fix exec:add-src',
endMarker: 'Prettier auto-formatting finished',
}
}
};

Expand Down Expand Up @@ -520,7 +536,8 @@ module.exports = function (grunt) {
'npm-install', */
'cleanempty',
'exec:clean-nls',
'usemin'
'usemin',
'githooks'
Copy link

Choose a reason for hiding this comment

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

This seems wrong to me. We'd want this to run automatically, not just when you manually run build. That is, when I commit, or maybe even when I just stage changes, it should run. There should be no manual intervention required, or people will forget/not-know to do it.

Copy link
Author

@dsych dsych Apr 14, 2017

Choose a reason for hiding this comment

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

@humphd This is required to create githook scripts. The formatting does run automatically on before every commit. My comment above

Before building, I suggest running "grunt eslint:src-fix" because now we don't have --fix option in default eslint task.

Only refers to the first run of the build. Eslint does not have auto-fixing set, so styling will fail the build and you will never create githook scripts. So instead you need to format code manually once, and then it will run properly on every commit. After formatted code is committed to the master, there will be no need for manual intervention.

/* XXXBramble: we skip this, since we don't bother with its info, and copy it in copy:dist
'build-config' */
]);
Expand Down
146 changes: 75 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,77 @@
{
"name": "bramble",
"version": "1.9.0-0",
"apiVersion": "1.9.0",
"homepage": "https://mozillathimblelivepreview.net/bramble/staging/dist/hosted.html",
"issues": {
"url": "http://github.com/mozilla/brackets/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/mozilla/brackets.git",
"branch": "",
"SHA": ""
},
"dependencies": {
"anymatch": "1.3.0",
"aws-sdk": "^2.19.0",
"chokidar": "1.6.0",
"glob": "7.0.6",
"grunt": "0.4.5",
"grunt-cleanempty": "1.0.3",
"grunt-cli": "0.1.9",
"grunt-contrib-clean": "0.4.1",
"grunt-contrib-compress": "^1.4.1",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-cssmin": "0.6.0",
"grunt-contrib-htmlmin": "0.1.3",
"grunt-contrib-jasmine": "0.4.2",
"grunt-contrib-less": "1.4.0",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "^2.3.0",
"grunt-contrib-watch": "0.4.3",
"grunt-eslint": "18.1.0",
"grunt-exec": "^1.0.1",
"grunt-jasmine-node": "0.1.0",
"grunt-lib-phantomjs": "0.3.0",
"grunt-targethtml": "0.2.6",
"grunt-template-jasmine-requirejs": "0.1.0",
"grunt-usemin": "0.1.11",
"jasmine-node": "1.11.0",
"less-plugin-autoprefix": "^1.5.1",
"load-grunt-tasks": "3.5.0",
"lodash": "4.15.0",
"phantomjs": "1.9.18",
"q": "1.4.1",
"semver": "^4.1.0",
"xmldoc": "^0.1.2"
},
"devDependencies": {
"bluebird": "^3.4.7",
"gunzip-maybe": "^1.3.1",
"http-server": "^0.9.0",
"mkdirp": "0.5.1",
"nunjucks": "^2.4.3",
"properties-parser": "0.3.1",
"request": "^2.69.0",
"requirejs": "^2.3.3",
"sw-precache": "^5.0.0",
"tar-fs": "^1.15.1"
},
"scripts": {
"localize": "node scripts/properties2js",
"postinstall": "grunt install",
"build": "grunt build-browser",
"preproduction": "grunt build-browser-compressed && grunt unlocalize",
"production": "npm start",
"unlocalize": "grunt unlocalize",
"test": "grunt test && grunt build-browser-compressed",
"start": "http-server -p 8000 --cors"
},
"license": "MIT"
"name": "bramble",
Copy link

Choose a reason for hiding this comment

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

This file should be 4-space indented.

"version": "1.9.0-0",
"apiVersion": "1.9.0",
"homepage": "https://mozillathimblelivepreview.net/bramble/staging/dist/hosted.html",
"issues": {
"url": "http://github.com/mozilla/brackets/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/mozilla/brackets.git",
"branch": "",
"SHA": ""
},
"dependencies": {
"anymatch": "1.3.0",
"aws-sdk": "^2.19.0",
"chokidar": "1.6.0",
"glob": "7.0.6",
"grunt": "0.4.5",
"grunt-cleanempty": "1.0.3",
"grunt-cli": "0.1.9",
"grunt-contrib-clean": "0.4.1",
"grunt-contrib-compress": "^1.4.1",
"grunt-contrib-concat": "0.3.0",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-cssmin": "0.6.0",
"grunt-contrib-htmlmin": "0.1.3",
"grunt-contrib-jasmine": "0.4.2",
"grunt-contrib-less": "1.4.0",
"grunt-contrib-requirejs": "0.4.1",
"grunt-contrib-uglify": "^2.3.0",
"grunt-contrib-watch": "0.4.3",
"grunt-eslint": "19.0.0",
"grunt-exec": "^1.0.1",
"grunt-jasmine-node": "0.1.0",
"grunt-lib-phantomjs": "0.3.0",
"grunt-targethtml": "0.2.6",
"grunt-template-jasmine-requirejs": "0.1.0",
"grunt-usemin": "0.1.11",
"jasmine-node": "1.11.0",
"less-plugin-autoprefix": "^1.5.1",
"load-grunt-tasks": "3.5.0",
"lodash": "4.15.0",
"phantomjs": "1.9.18",
"q": "1.4.1",
"semver": "^4.1.0",
"xmldoc": "^0.1.2"
},
"devDependencies": {
"bluebird": "^3.4.7",
"eslint-config-prettier": "^1.6.0",
"eslint-plugin-prettier": "^2.0.1",
"grunt-githooks": "^0.6.0",
"gunzip-maybe": "^1.3.1",
"http-server": "^0.9.0",
"mkdirp": "0.5.1",
"nunjucks": "^2.4.3",
"prettier": "^0.22.0",
"properties-parser": "0.3.1",
"request": "^2.69.0",
"requirejs": "^2.3.3",
"sw-precache": "^5.0.0",
"tar-fs": "^1.15.1"
},
"scripts": {
"localize": "node scripts/properties2js",
"postinstall": "grunt install",
"build": "grunt build-browser",
"preproduction": "grunt build-browser-compressed && grunt unlocalize",
"production": "npm start",
"unlocalize": "grunt unlocalize",
"test": "grunt test && grunt build-browser-compressed",
"start": "http-server -p 8000 --cors"
},
"license": "MIT"
}