From b553718aee6de71af6937ba6678ece6baf3e158e Mon Sep 17 00:00:00 2001 From: James Long Date: Mon, 9 Jan 2017 23:44:12 -0500 Subject: [PATCH] Fix up atom package --- editors/prettier-atom/lib/prettier.js | 31 ++++++++++++++++----------- editors/prettier-atom/package.json | 10 ++++----- package.json | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/editors/prettier-atom/lib/prettier.js b/editors/prettier-atom/lib/prettier.js index 8a358fdc..36eb64e8 100644 --- a/editors/prettier-atom/lib/prettier.js +++ b/editors/prettier-atom/lib/prettier.js @@ -71,8 +71,12 @@ module.exports = { if (!editor.getBuffer().isModified()) return; - // var formatOnSave = atom.config.get('prettier.formatOnSave', {scope: editor.getRootScopeDescriptor()}) - // if (!formatOnSave) return + var formatOnSave = atom.config.get("prettier-atom.formatOnSave", { + scope: editor.getRootScopeDescriptor() + }); + if (!formatOnSave) + return; + // Set the relative path based on the file's nearest package.json. // If no package.json is found, use path verbatim. var relativePath; @@ -88,17 +92,18 @@ module.exports = { } }.bind(this) ); - - if (editor.editorElement) { - window.addEventListener("resize", e => { - const { width } = window.document.body.getBoundingClientRect(); - const columns = width / - editor.editorElement.getDefaultCharacterWidth() | - 0; - console.log(width, columns); - this.format({ selection: false, printWidth: columns }); - }); - } + // Uncomment this to format on resize. Not ready yet. :) + // + // if (editor.editorElement) { + // window.addEventListener("resize", e => { + // const { width } = window.document.body.getBoundingClientRect(); + // const columns = width / + // editor.editorElement.getDefaultCharacterWidth() | + // 0; + // console.log(width, columns); + // this.format({ selection: false, printWidth: columns }); + // }); + // } }, config: { formatOnSave: { type: "boolean", default: false } } }; diff --git a/editors/prettier-atom/package.json b/editors/prettier-atom/package.json index 7fefde28..f514196d 100644 --- a/editors/prettier-atom/package.json +++ b/editors/prettier-atom/package.json @@ -1,21 +1,21 @@ { - "name": "jscodefmt-atom", - "main": "./lib/jscodefmt.js", + "name": "prettier-atom", + "main": "./lib/prettier.js", "version": "0.0.1", - "description": "Format file contents using jscodefmt", + "description": "Format file contents using prettier", "keywords": [ "javascript", "formatter" ], "activationCommands": [], - "repository": "https://github.com/stephenkubovic/atom-standard-formatter", + "repository": "https://github.com/jlongster/prettier", "license": "MIT", "engines": { "atom": ">=0.174.0 <2.0.0" }, "dependencies": { "find-root": "^0.1.1", - "jscodefmt": "^0.0.1" + "prettier": "0.0.2" }, "devDependencies": {} } diff --git a/package.json b/package.json index ec0f1d4b..3f2485b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prettier", - "version": "0.0.1", + "version": "0.0.2", "bin": { "prettier": "./bin/prettier" },