From bbc7a0c0a3806cb7e4786216ba62014803c85db0 Mon Sep 17 00:00:00 2001 From: Rob Wise Date: Tue, 14 Apr 2020 14:13:26 -0600 Subject: [PATCH 1/5] chore(deps): bump eslint-config-airbnb-base --- decls/index.js | 1 + dist/atomInterface/index.js | 4 +- .../executePrettierOnBufferRange.js | 10 +- .../executePrettierOnBufferRange.test.js | 54 +++-------- dist/formatOnSave/index.test.js | 20 +--- dist/helpers/index.js | 2 +- package.json | 2 +- tests/mocks/textEditor.js | 63 ++++++------- yarn.lock | 93 ++++++++++++++++--- 9 files changed, 134 insertions(+), 115 deletions(-) diff --git a/decls/index.js b/decls/index.js index 3324ed0b..1bf1d060 100644 --- a/decls/index.js +++ b/decls/index.js @@ -41,6 +41,7 @@ declare type TextEditor = { }, }, backwardsScanInBufferRange: (regex: RegExp, Range: Range, iterator: Atom$Iterator) => void, + ... }; declare type TextBuffer = { characterIndexForPosition: (cursorPosition: Point) => number, diff --git a/dist/atomInterface/index.js b/dist/atomInterface/index.js index d4654161..eacf6765 100644 --- a/dist/atomInterface/index.js +++ b/dist/atomInterface/index.js @@ -58,9 +58,7 @@ const addWarningNotification = (message, options) => atom.notifications.addWarni const addErrorNotification = (message, options) => atom.notifications.addError(message, options); -const attemptWithErrorNotification = -/*#__PURE__*/ -function () { +const attemptWithErrorNotification = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2["default"])(function* (func, ...args) { try { yield func(...args); diff --git a/dist/executePrettier/executePrettierOnBufferRange.js b/dist/executePrettier/executePrettierOnBufferRange.js index 4afa5d24..9a8fda87 100644 --- a/dist/executePrettier/executePrettierOnBufferRange.js +++ b/dist/executePrettier/executePrettierOnBufferRange.js @@ -8,7 +8,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } const _ = require('lodash/fp'); @@ -70,9 +70,7 @@ const buildPrettierStylelintOptions = (editor, text) => ({ const executePrettierStylelint = (editor, text) => prettierStylelint.format(buildPrettierStylelintOptions(editor, text)); -const executePrettierOrIntegration = -/*#__PURE__*/ -function () { +const executePrettierOrIntegration = /*#__PURE__*/function () { var _ref = (0, _asyncToGenerator2["default"])(function* (editor, text, cursorOffset) { if (shouldUseStylelint() && isCurrentScopeStyleLintScope(editor)) { // TODO: add support for cursor position - https://github.com/hugomrdias/prettier-stylelint/issues/13 @@ -111,9 +109,7 @@ function () { }; }(); -const executePrettierOnBufferRange = -/*#__PURE__*/ -function () { +const executePrettierOnBufferRange = /*#__PURE__*/function () { var _ref2 = (0, _asyncToGenerator2["default"])(function* (editor, bufferRange, options) { // grab cursor position and file contents const currentBuffer = editor.getBuffer(); diff --git a/dist/executePrettier/executePrettierOnBufferRange.test.js b/dist/executePrettier/executePrettierOnBufferRange.test.js index 00ea7cbf..c2070c93 100644 --- a/dist/executePrettier/executePrettierOnBufferRange.test.js +++ b/dist/executePrettier/executePrettierOnBufferRange.test.js @@ -8,7 +8,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } jest.mock('@lewisl9029/prettier-eslint'); jest.mock('prettier-stylelint'); @@ -76,9 +76,7 @@ beforeEach(() => { getPrettierInstance.mockImplementation(() => prettier); prettier.resolveConfig.sync.mockImplementation(() => optionsFixture); }); -it('uses editor config', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('uses editor config', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { getCurrentFilePath.mockImplementation(() => 'foo.js'); shouldUseEditorConfig.mockImplementation(() => true); yield executePrettierOnBufferRange(editor, bufferRangeFixture); @@ -86,9 +84,7 @@ it('uses editor config', editorconfig: true }); })); -it('does not use editor config', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('does not use editor config', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { getCurrentFilePath.mockImplementation(() => 'foo.js'); shouldUseEditorConfig.mockImplementation(() => false); yield executePrettierOnBufferRange(editor, bufferRangeFixture); @@ -96,18 +92,14 @@ it('does not use editor config', editorconfig: false }); })); -it('sets the transformed text in the buffer range', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('sets the transformed text in the buffer range', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { yield executePrettierOnBufferRange(editor, bufferRangeFixture); expect(editor.setTextInBufferRange).toHaveBeenCalled(); // NOTE: there is currently a bug in prettier that causes formatWithCursor to // only return the formatted text when running in test environment, but works // as expected when in production. // expect(editor.setTextInBufferRange).toHaveBeenCalledWith(bufferRangeFixture, formattedFixture); })); -it('uses Prettier#formatWithCursor', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('uses Prettier#formatWithCursor', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const cursorOffset = 10; editor.getBuffer.mockImplementation(() => ({ getRange: () => ({ @@ -124,9 +116,7 @@ it('uses Prettier#formatWithCursor', cursorOffset }, optionsFixture)); })); -it('sets the transformed text via diff when the option is passed', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('sets the transformed text via diff when the option is passed', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const setTextViaDiffMock = jest.fn(); editor.getBuffer.mockImplementation(() => ({ getRange: () => ({ @@ -150,15 +140,11 @@ it('sets the transformed text via diff when the option is passed', // as expected when in production. // expect(setTextViaDiffMock).toHaveBeenCalledWith(formattedFixture); })); -it('runs linter:lint if available to refresh linter highlighting', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('runs linter:lint if available to refresh linter highlighting', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { yield executePrettierOnBufferRange(editor, bufferRangeFixture); expect(runLinter).toHaveBeenCalledWith(editor); })); -it('transforms the given buffer range using prettier-eslint if config enables it', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('transforms the given buffer range using prettier-eslint if config enables it', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { shouldUseEslint.mockImplementation(() => true); const prettierLast = true; getPrettierEslintOptions.mockImplementation(() => ({ @@ -172,9 +158,7 @@ it('transforms the given buffer range using prettier-eslint if config enables it text: sourceFixture }); })); -it('transforms the given buffer range using prettier-stylelint if scope is CSS and config enables it', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('transforms the given buffer range using prettier-stylelint if scope is CSS and config enables it', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { isCurrentScopeStyleLintScope.mockImplementation(() => true); shouldUseStylelint.mockImplementation(() => true); const filePath = 'foo.js'; @@ -189,9 +173,7 @@ describe('when text in buffer range is already pretty', () => { beforeEach(() => { editor.getTextInBufferRange.mockImplementation(() => formattedFixture); }); - it("does not change the text in the editor's buffer range", - /*#__PURE__*/ - (0, _asyncToGenerator2["default"])(function* () { + it("does not change the text in the editor's buffer range", /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const before = editor.getTextInBufferRange(bufferRangeFixture); yield executePrettierOnBufferRange(editor, bufferRangeFixture); const after = editor.getTextInBufferRange(bufferRangeFixture); @@ -201,9 +183,7 @@ describe('when text in buffer range is already pretty', () => { // this test. // expect(editor.setTextInBufferRange).not.toHaveBeenCalled(); })); - it("does not change the editor's cursor position", - /*#__PURE__*/ - (0, _asyncToGenerator2["default"])(function* () { + it("does not change the editor's cursor position", /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { yield executePrettierOnBufferRange(editor, bufferRangeFixture); expect(editor.setCursorScreenPosition).not.toHaveBeenCalled(); })); @@ -220,9 +200,7 @@ describe('when prettier throws an error', () => { throw error; }); }); - it('handles the error', - /*#__PURE__*/ - (0, _asyncToGenerator2["default"])(function* () { + it('handles the error', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { yield executePrettierOnBufferRange(editor, bufferRangeFixture); expect(handleError).toHaveBeenCalledWith({ editor, @@ -230,15 +208,11 @@ describe('when prettier throws an error', () => { bufferRange: bufferRangeFixture }); })); - it("does not change the text in the editor's buffer range", - /*#__PURE__*/ - (0, _asyncToGenerator2["default"])(function* () { + it("does not change the text in the editor's buffer range", /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { yield executePrettierOnBufferRange(editor, bufferRangeFixture); expect(editor.setTextInBufferRange).not.toHaveBeenCalled(); })); - it("does not change the editor's cursor position", - /*#__PURE__*/ - (0, _asyncToGenerator2["default"])(function* () { + it("does not change the editor's cursor position", /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { yield executePrettierOnBufferRange(editor, bufferRangeFixture); expect(editor.setCursorScreenPosition).not.toHaveBeenCalled(); })); diff --git a/dist/formatOnSave/index.test.js b/dist/formatOnSave/index.test.js index f5fdd4ca..cde3e0b3 100644 --- a/dist/formatOnSave/index.test.js +++ b/dist/formatOnSave/index.test.js @@ -27,23 +27,17 @@ const shouldFormatOnSave = require('./shouldFormatOnSave'); const formatOnSave = require('./index'); -it('returns a Promise', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('returns a Promise', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const editor = createMockTextEditor(); const result = formatOnSave(editor); expect(result).toBeInstanceOf(Promise); })); -it('clears linter errors before running', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('clears linter errors before running', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const editor = createMockTextEditor(); yield formatOnSave(editor); expect(clearLinterErrors).toHaveBeenCalledWith(editor); })); -it('executes prettier on the buffer range if appropriate and scope is not embedded', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('executes prettier on the buffer range if appropriate and scope is not embedded', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const editor = createMockTextEditor(); const mockRange = { start: [0, 0], @@ -56,18 +50,14 @@ it('executes prettier on the buffer range if appropriate and scope is not embedd setTextViaDiff: true }); })); -it('does nothing if it should not format on save', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('does nothing if it should not format on save', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const editor = createMockTextEditor(); shouldFormatOnSave.mockImplementation(() => false); yield formatOnSave(editor); expect(shouldFormatOnSave).toHaveBeenCalledWith(editor); expect(executePrettierOnBufferRange).not.toHaveBeenCalled(); })); -it('catches uncaught errors so that the user is not prevented from saving', -/*#__PURE__*/ -(0, _asyncToGenerator2["default"])(function* () { +it('catches uncaught errors so that the user is not prevented from saving', /*#__PURE__*/(0, _asyncToGenerator2["default"])(function* () { const originalConsoleError = console.error; // eslint-disable-line no-console console.error = jest.fn(); // eslint-disable-line no-console diff --git a/dist/helpers/index.js b/dist/helpers/index.js index ec7ec477..5e99b0ca 100644 --- a/dist/helpers/index.js +++ b/dist/helpers/index.js @@ -6,7 +6,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } -function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } const getPrettierInstance = require('./getPrettierInstance'); diff --git a/package.json b/package.json index 3a3db47f..3478c908 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "conventional-changelog-cli": "^2.0.31", "cz-conventional-changelog": "^3.1.0", "eslint": "^6.8.0", - "eslint-config-airbnb-base": "^13.2.0", + "eslint-config-airbnb-base": "^14.1.0", "eslint-config-prettier": "^6.10.1", "eslint-plugin-flowtype": "^4.7.0", "eslint-plugin-import": "^2.20.2", diff --git a/tests/mocks/textEditor.js b/tests/mocks/textEditor.js index 47951d2d..35aa5fe2 100644 --- a/tests/mocks/textEditor.js +++ b/tests/mocks/textEditor.js @@ -1,37 +1,34 @@ // @flow -const textEditorFactory = (overrides?: {} = {}): TextEditor => - Object.assign( - {}, - { - backwardsScanInBufferRange: jest.fn(), - buffer: { - file: { - path: 'xyz.js', - getPath: jest.fn(), - }, - }, - getBuffer: jest.fn(() => ({ - characterIndexForPosition: jest.fn(() => 1), - getRange: jest.fn(() => ({ - isEqual: jest.fn(), - start: { row: 0, column: 0 }, - end: { row: 0, column: 0 }, - })), - positionForCharacterIndex: jest.fn(), - setTextViaDiff: jest.fn(), - })), - getGrammar: jest.fn(() => ({ scopeName: 'FAKE SCOPE NAME' })), - getSelectedText: jest.fn(), - getLastCursor: jest.fn(), - getCursorScreenPosition: jest.fn(), - getCursorBufferPosition: jest.fn(), - getTextInBufferRange: jest.fn(), - setTextInBufferRange: jest.fn(), - getSelectedBufferRanges: jest.fn(), - setCursorScreenPosition: jest.fn(), - setCursorBufferPosition: jest.fn(), +// $FlowIssue +const textEditorFactory = (overrides?: {} = {}): TextEditor => ({ + backwardsScanInBufferRange: jest.fn(), + buffer: { + file: { + path: 'xyz.js', + getPath: jest.fn(), }, - overrides, - ); + }, + getBuffer: jest.fn(() => ({ + characterIndexForPosition: jest.fn(() => 1), + getRange: jest.fn(() => ({ + isEqual: jest.fn(), + start: { row: 0, column: 0 }, + end: { row: 0, column: 0 }, + })), + positionForCharacterIndex: jest.fn(), + setTextViaDiff: jest.fn(), + })), + getGrammar: jest.fn(() => ({ scopeName: 'FAKE SCOPE NAME' })), + getSelectedText: jest.fn(), + getLastCursor: jest.fn(), + getCursorScreenPosition: jest.fn(), + getCursorBufferPosition: jest.fn(), + getTextInBufferRange: jest.fn(), + setTextInBufferRange: jest.fn(), + getSelectedBufferRanges: jest.fn(), + setCursorScreenPosition: jest.fn(), + setCursorBufferPosition: jest.fn(), + ...overrides, +}); module.exports = textEditorFactory; diff --git a/yarn.lock b/yarn.lock index 7415d2bc..3f3db45a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2441,10 +2441,10 @@ configstore@^3.0.0: write-file-atomic "^2.0.0" xdg-basedir "^3.0.0" -confusing-browser-globals@^1.0.5: - version "1.0.7" - resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.7.tgz#5ae852bd541a910e7ffb2dbb864a2d21a36ad29b" - integrity sha512-cgHI1azax5ATrZ8rJ+ODDML9Fvu67PimB6aNxBrc/QwSaDaM9eTfIEUHx3bBLJJ82ioSb+/5zfsMCCEJax3ByQ== +confusing-browser-globals@^1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz#72bc13b483c0276801681871d4898516f8f54fdd" + integrity sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw== consistent-env@^1.2.0: version "1.3.1" @@ -3119,6 +3119,23 @@ es-abstract@^1.15.0: string.prototype.trimleft "^2.1.0" string.prototype.trimright "^2.1.0" +es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: + version "1.17.5" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9" + integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.1.5" + is-regex "^1.0.5" + object-inspect "^1.7.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimleft "^2.1.1" + string.prototype.trimright "^2.1.1" + es-to-primitive@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" @@ -3153,14 +3170,14 @@ escodegen@^1.11.1: optionalDependencies: source-map "~0.6.1" -eslint-config-airbnb-base@^13.2.0: - version "13.2.0" - resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.2.0.tgz#f6ea81459ff4dec2dda200c35f1d8f7419d57943" - integrity sha512-1mg/7eoB4AUeB0X1c/ho4vb2gYkNH8Trr/EgCT/aGmKhhG+F6vF5s8+iRBlWAzFIAphxIdp3YfEKgEl0f9Xg+w== +eslint-config-airbnb-base@^14.1.0: + version "14.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-14.1.0.tgz#2ba4592dd6843258221d9bff2b6831bd77c874e4" + integrity sha512-+XCcfGyCnbzOnktDVhwsCAx+9DmrzEmuwxyHUJpw+kqBVT744OUBrB09khgFKlK1lshVww6qXGsYPZpavoNjJw== dependencies: - confusing-browser-globals "^1.0.5" + confusing-browser-globals "^1.0.9" object.assign "^4.1.0" - object.entries "^1.1.0" + object.entries "^1.1.1" eslint-config-prettier@^6.10.1: version "6.10.1" @@ -4595,6 +4612,11 @@ is-callable@^1.1.4: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75" integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA== +is-callable@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" + integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== + is-ci@^1.0.10: version "1.1.0" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5" @@ -4830,6 +4852,13 @@ is-regex@^1.0.4: dependencies: has "^1.0.1" +is-regex@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" + integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== + dependencies: + has "^1.0.3" + is-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" @@ -6313,13 +6342,13 @@ object.assign@^4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" -object.entries@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.0.tgz#2024fc6d6ba246aee38bdb0ffd5cfbcf371b7519" - integrity sha512-l+H6EQ8qzGRxbkHOd5I/aHRhHDKoQXQ8g0BYt4uSweQU1/J6dZUOyWh9a2Vky35YCKjzmgxOzta2hH6kf9HuXA== +object.entries@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.1.tgz#ee1cf04153de02bb093fec33683900f57ce5399b" + integrity sha512-ilqR7BgdyZetJutmDPfXCDffGa0/Yzl2ivVNpbx/g4UeWrCdRnFDUBrKJGLhGieRHDATnyZXWBeCb29k9CJysQ== dependencies: define-properties "^1.1.3" - es-abstract "^1.12.0" + es-abstract "^1.17.0-next.1" function-bind "^1.1.1" has "^1.0.3" @@ -7977,6 +8006,14 @@ string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string.prototype.trimend@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" + integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string.prototype.trimleft@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz#6cc47f0d7eb8d62b0f3701611715a3954591d634" @@ -7985,6 +8022,15 @@ string.prototype.trimleft@^2.1.0: define-properties "^1.1.3" function-bind "^1.1.1" +string.prototype.trimleft@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz#4408aa2e5d6ddd0c9a80739b087fbc067c03b3cc" + integrity sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string.prototype.trimstart "^1.0.0" + string.prototype.trimright@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz#669d164be9df9b6f7559fa8e89945b168a5a6c58" @@ -7993,6 +8039,23 @@ string.prototype.trimright@^2.1.0: define-properties "^1.1.3" function-bind "^1.1.1" +string.prototype.trimright@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz#c76f1cef30f21bbad8afeb8db1511496cfb0f2a3" + integrity sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string.prototype.trimend "^1.0.0" + +string.prototype.trimstart@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" + integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + string_decoder@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.2.0.tgz#fe86e738b19544afe70469243b2a1ee9240eae8d" From 639e0db60440e2cc8e91b11fea98c62f21fe831c Mon Sep 17 00:00:00 2001 From: Rob Wise Date: Tue, 14 Apr 2020 14:15:31 -0600 Subject: [PATCH 2/5] chore(husky): fix deprecated use of Husky --- package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3478c908..75355eeb 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,12 @@ }, "scripts": { "start": "nps", - "test": "nps test", - "precommit": "opt --in pre-commit --exec \"npm start validate\"" + "test": "nps test" + }, + "husky": { + "hooks": { + "pre-commit": "opt --in pre-commit --exec \"npm start validate\"" + } }, "config": { "commitizen": { From fc9e9bfce53065437b6a8201cb2b560836e13936 Mon Sep 17 00:00:00 2001 From: Rob Wise Date: Tue, 14 Apr 2020 14:18:21 -0600 Subject: [PATCH 3/5] chore(deps): bump execa --- package.json | 2 +- yarn.lock | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 75355eeb..d23b79b3 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "atom-package-deps": "^5.1.0", "atom-text-buffer-point": "^1.0.0", "atom-text-buffer-range": "^1.0.0", - "execa": "^1.0.0", + "execa": "^4.0.0", "global-modules": "^2.0.0", "ignore": "^5.1.4", "lodash": "^4.17.13", diff --git a/yarn.lock b/yarn.lock index 3f3db45a..888aaf0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3473,6 +3473,21 @@ execa@^3.2.0: signal-exit "^3.0.2" strip-final-newline "^2.0.0" +execa@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.0.tgz#7f37d6ec17f09e6b8fc53288611695b6d12b9daf" + integrity sha512-JbDUxwV3BoT5ZVXQrSVbAiaXhXUkIwvbhPIwZ0N13kX+5yCzOhUNdocxB/UQRuYOHRYYwAxKYwJYc0T4D12pDA== + dependencies: + cross-spawn "^7.0.0" + get-stream "^5.0.0" + human-signals "^1.1.1" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.0" + onetime "^5.1.0" + signal-exit "^3.0.2" + strip-final-newline "^2.0.0" + execall@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/execall/-/execall-1.0.0.tgz#73d0904e395b3cab0658b08d09ec25307f29bb73" From 898ea715f001260b7f7c5a33667d4d1517e2610d Mon Sep 17 00:00:00 2001 From: Rob Wise Date: Tue, 14 Apr 2020 14:19:49 -0600 Subject: [PATCH 4/5] chore(deps): bump read-pkg-up --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index d23b79b3..81590c36 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "loophole": "^1.1.0", "prettier": "1.18.2", "prettier-stylelint": "^0.4.2", - "read-pkg-up": "^6.0.0", + "read-pkg-up": "^7.0.1", "yarn-global-modules": "^1.0.1" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 888aaf0e..f5b0f273 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7098,14 +7098,14 @@ read-pkg-up@^3.0.0: find-up "^2.0.0" read-pkg "^3.0.0" -read-pkg-up@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-6.0.0.tgz#da75ce72762f2fa1f20c5a40d4dd80c77db969e3" - integrity sha512-odtTvLl+EXo1eTsMnoUHRmg/XmXdTkwXVxy4VFE9Kp6cCq7b3l7QMdBndND3eAFzrbSAXC/WCUOQQ9rLjifKZw== +read-pkg-up@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" + integrity sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg== dependencies: - find-up "^4.0.0" - read-pkg "^5.1.1" - type-fest "^0.5.0" + find-up "^4.1.0" + read-pkg "^5.2.0" + type-fest "^0.8.1" read-pkg@^1.0.0: version "1.1.0" @@ -7131,7 +7131,7 @@ read-pkg@^3.0.0: normalize-package-data "^2.3.2" path-type "^3.0.0" -read-pkg@^5.1.1: +read-pkg@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-5.2.0.tgz#7bf295438ca5a33e56cd30e053b34ee7250c93cc" integrity sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg== @@ -8542,7 +8542,7 @@ type-fest@^0.10.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.10.0.tgz#7f06b2b9fbfc581068d1341ffabd0349ceafc642" integrity sha512-EUV9jo4sffrwlg8s0zDhP0T2WD3pru5Xi0+HTE3zTUmBaZNhfkite9PdSJwdXLwPVW0jnAHT56pZHIOYckPEiw== -type-fest@^0.5.0, type-fest@^0.5.2: +type-fest@^0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2" integrity sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw== From 1cab45e3b9d29239ae2a45a8bf5954af531df829 Mon Sep 17 00:00:00 2001 From: Rob Wise Date: Tue, 14 Apr 2020 14:31:53 -0600 Subject: [PATCH 5/5] feat(prettier): bump to version 2.0.2 --- decls/index.js | 2 +- package.json | 2 +- src/atomInterface/index.js | 12 +++--------- src/editorInterface/index.js | 2 +- src/executePrettier/handleError.js | 20 +++++++------------- src/formatOnSave/index.js | 2 +- src/formatOnSave/isPrettierInPackageJson.js | 12 +++--------- src/formatOnSave/shouldFormatOnSave.js | 10 ++-------- src/helpers/general.js | 15 ++++----------- src/helpers/getPrettierInstance.test.js | 4 ++-- src/helpers/isFileFormattable.js | 5 +---- src/helpers/isFileFormattable.test.js | 2 +- src/helpers/isPrettierProperVersion.js | 2 +- src/main.js | 12 ++++++------ src/manualFormat/index.js | 4 +++- src/statusTile/createStatusTile.test.js | 2 +- src/statusTile/updateStatusTile.test.js | 2 +- yarn.lock | 8 ++++---- 18 files changed, 43 insertions(+), 75 deletions(-) diff --git a/decls/index.js b/decls/index.js index 1bf1d060..feb0a342 100644 --- a/decls/index.js +++ b/decls/index.js @@ -92,7 +92,7 @@ declare var atom: { add: (target: HTMLElement, options?: Atom$Tooltips$Options) => Atom$Disposable, }, views: { - getView: Atom$Workspace => Atom$View, + getView: (Atom$Workspace) => Atom$View, }, workspace: Atom$Workspace, getVersion: () => string, diff --git a/package.json b/package.json index 81590c36..d96e42d7 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "ignore": "^5.1.4", "lodash": "^4.17.13", "loophole": "^1.1.0", - "prettier": "1.18.2", + "prettier": "2.0.2", "prettier-stylelint": "^0.4.2", "read-pkg-up": "^7.0.1", "yarn-global-modules": "^1.0.1" diff --git a/src/atomInterface/index.js b/src/atomInterface/index.js index 6febbb1e..964da291 100644 --- a/src/atomInterface/index.js +++ b/src/atomInterface/index.js @@ -13,7 +13,7 @@ const setConfigOption = (key: string, value: any) => atom.config.set(`prettier-a const isLinterLintCommandDefined = (editor: TextEditor) => atom.commands .findCommands({ target: atom.views.getView(editor) }) - .some(command => command.name === LINTER_LINT_COMMAND); + .some((command) => command.name === LINTER_LINT_COMMAND); // public const isLinterEslintAutofixEnabled = () => @@ -74,7 +74,7 @@ const runLinter = (editor: TextEditor) => atom.commands.dispatch(atom.views.getView(editor), LINTER_LINT_COMMAND); const invokeAtomRelativizePath = _.flow( - filePath => atom.project.relativizePath(filePath), // NOTE: fat arrow necessary for `this` + (filePath) => atom.project.relativizePath(filePath), // NOTE: fat arrow necessary for `this` _.get('[1]'), ); @@ -82,13 +82,7 @@ const relativizePathToDirname = (filePath: string) => path.relative(path.dirname const relativizePathFromAtomProject: (filePath: ?string) => ?string = _.cond([ [_.isNil, _.constant(null)], - [ - _.flow( - invokeAtomRelativizePath, - path.isAbsolute, - ), - relativizePathToDirname, - ], + [_.flow(invokeAtomRelativizePath, path.isAbsolute), relativizePathToDirname], [_.stubTrue, invokeAtomRelativizePath], ]); diff --git a/src/editorInterface/index.js b/src/editorInterface/index.js index ff2b5798..c7b67eb1 100644 --- a/src/editorInterface/index.js +++ b/src/editorInterface/index.js @@ -30,7 +30,7 @@ const getCurrentFilePath = (editor: TextEditor): ?FilePath => const isCurrentFilePathDefined = (editor: ?TextEditor) => editor && !!getCurrentFilePath(editor); -const getCurrentDir: (editor: TextEditor) => ?string = editor => +const getCurrentDir: (editor: TextEditor) => ?string = (editor) => lazyFlow()(getCurrentFilePath, (maybeFilePath: ?string) => typeof maybeFilePath === 'string' ? path.dirname(maybeFilePath) : undefined, )(editor); diff --git a/src/executePrettier/handleError.js b/src/executePrettier/handleError.js index b2033d40..3c69656e 100644 --- a/src/executePrettier/handleError.js +++ b/src/executePrettier/handleError.js @@ -41,24 +41,18 @@ const setErrorMessageInLinter = ({ editor, bufferRange, error }: HandleErrorArgs }, ]); -const isSyntaxError: HandleErrorArgs => boolean = _.overSome([ - _.flow( - _.get('error.loc.start.line'), - _.isInteger, - ), - _.flow( - _.get('error.loc.line'), - _.isInteger, - ), +const isSyntaxError: (HandleErrorArgs) => boolean = _.overSome([ + _.flow(_.get('error.loc.start.line'), _.isInteger), + _.flow(_.get('error.loc.line'), _.isInteger), ]); -const isUndefinedError: HandleErrorArgs => boolean = _.flow( +const isUndefinedError: (HandleErrorArgs) => boolean = _.flow( _.get('error.message'), // $FlowIssue _.matches('undefined'), ); -const isFilePathPresent: HandleErrorArgs => boolean = _.flow( +const isFilePathPresent: (HandleErrorArgs) => boolean = _.flow( _.get('editor'), getCurrentFilePath, _.negate(_.isNil), @@ -71,10 +65,10 @@ const displayErrorInPopup = (args: HandleErrorArgs) => dismissable: true, }); -const handleError: HandleErrorArgs => void = _.flow( +const handleError: (HandleErrorArgs) => void = _.flow( _.cond([ [_.overEvery([isSyntaxError, isFilePathPresent]), setErrorMessageInLinter], - [isUndefinedError, args => console.error('Prettier encountered an error:', args.error)], // eslint-disable-line no-console + [isUndefinedError, (args) => console.error('Prettier encountered an error:', args.error)], // eslint-disable-line no-console [_.stubTrue, displayErrorInPopup], ]), ); diff --git a/src/formatOnSave/index.js b/src/formatOnSave/index.js index 5dd53dc6..bcad4d6c 100644 --- a/src/formatOnSave/index.js +++ b/src/formatOnSave/index.js @@ -9,7 +9,7 @@ const shouldFormatOnSave = require('./shouldFormatOnSave'); const executePrettier = (editor: TextEditor) => executePrettierOnBufferRange(editor, getBufferRange(editor), { setTextViaDiff: true }); -const formatOnSaveIfAppropriate: TextEditor => void = _.flow( +const formatOnSaveIfAppropriate: (TextEditor) => void = _.flow( _.tap(clearLinterErrors), _.cond([[shouldFormatOnSave, executePrettier]]), ); diff --git a/src/formatOnSave/isPrettierInPackageJson.js b/src/formatOnSave/isPrettierInPackageJson.js index 83f0dbbc..6a866922 100644 --- a/src/formatOnSave/isPrettierInPackageJson.js +++ b/src/formatOnSave/isPrettierInPackageJson.js @@ -6,21 +6,15 @@ const { getCurrentDir } = require('../editorInterface'); const { shouldUseEslint } = require('../atomInterface'); const hasPackageDependency = (packageName: string): ((packageJson: {}) => boolean) => - _.flow( - _.get('package.dependencies'), - _.has(packageName), - ); + _.flow(_.get('package.dependencies'), _.has(packageName)); const hasPackageDevDependency = (packageName: string) => - _.flow( - _.get('package.devDependencies'), - _.has(packageName), - ); + _.flow(_.get('package.devDependencies'), _.has(packageName)); const hasPackage = (packageName: string): ((packageJson: {}) => boolean) => _.overSome([hasPackageDependency(packageName), hasPackageDevDependency(packageName)]); -const readContentsOfNearestPackageJson: TextEditor => {} = _.flow( +const readContentsOfNearestPackageJson: (TextEditor) => {} = _.flow( getCurrentDir, // $FlowIssue: lodashfp placeholders not supported yet _.set('cwd', _, {}), diff --git a/src/formatOnSave/shouldFormatOnSave.js b/src/formatOnSave/shouldFormatOnSave.js index 4c72cb9e..2aa93b33 100644 --- a/src/formatOnSave/shouldFormatOnSave.js +++ b/src/formatOnSave/shouldFormatOnSave.js @@ -28,10 +28,7 @@ const filePathDoesNotMatchBlacklistGlobs: (editor: TextEditor) => boolean = _.fl ); // $FlowFixMe -const noWhitelistGlobsPresent: () => boolean = _.flow( - getWhitelistedGlobs, - _.isEmpty, -); +const noWhitelistGlobsPresent: () => boolean = _.flow(getWhitelistedGlobs, _.isEmpty); const isFilePathWhitelisted: (editor: TextEditor) => boolean = _.flow( getCurrentFilePath, @@ -39,10 +36,7 @@ const isFilePathWhitelisted: (editor: TextEditor) => boolean = _.flow( (filePath: ?FilePath) => someGlobsMatchFilePath(getWhitelistedGlobs(), filePath), ); -const isEslintIgnored: (editor: TextEditor) => boolean = _.flow( - getCurrentFilePath, - isFilePathEslintIgnored, -); +const isEslintIgnored: (editor: TextEditor) => boolean = _.flow(getCurrentFilePath, isFilePathEslintIgnored); const isPrettierConfigPresent = (editor: TextEditor): boolean => // $FlowFixMe diff --git a/src/helpers/general.js b/src/helpers/general.js index 4171fd4b..11fca529 100644 --- a/src/helpers/general.js +++ b/src/helpers/general.js @@ -8,24 +8,17 @@ const isPresent = (target: any): boolean => !!target && (typeof target.length === 'undefined' || target.length > 0); const someGlobsMatchFilePath = (globs: Globs, filePath: ?FilePath) => - isPresent(filePath) && - ignore() - .add(globs) - .ignores(filePath); + isPresent(filePath) && ignore().add(globs).ignores(filePath); const safePathParse = (filePath: FilePath) => typeof filePath === 'string' && filePath.length > 0 ? path.parse(filePath) : undefined; // $FlowFixMe: calling `_.get` on possibly undefined value -const getDirFromFilePath: (filePath: ?FilePath) => ?FilePath = _.flow( - safePathParse, - _.get('dir'), -); +const getDirFromFilePath: (filePath: ?FilePath) => ?FilePath = _.flow(safePathParse, _.get('dir')); const findCachedFromFilePath = (filePath: ?FilePath, name: string | Array): ?FilePath => - _.flow( - getDirFromFilePath, - (dirPath: ?FilePath): ?FilePath => (isPresent(dirPath) ? findCached(dirPath, name) : undefined), + _.flow(getDirFromFilePath, (dirPath: ?FilePath): ?FilePath => + isPresent(dirPath) ? findCached(dirPath, name) : undefined, )(filePath); module.exports = { diff --git a/src/helpers/getPrettierInstance.test.js b/src/helpers/getPrettierInstance.test.js index f0b8e135..d6cac114 100644 --- a/src/helpers/getPrettierInstance.test.js +++ b/src/helpers/getPrettierInstance.test.js @@ -29,7 +29,7 @@ test("returns global prettier (by npm) if user's project has no local prettier p const file = { getPath: () => filePath }; const editor = createMockTextEditor({ buffer: { file } }); const fakeGloballyInstalledPrettier = path.join(__dirname, '..', '..', 'tests', 'fixtures', 'prettier.js'); - atomLinter.findCached.mockImplementation(dir => + atomLinter.findCached.mockImplementation((dir) => dir === globalModules ? fakeGloballyInstalledPrettier : null, ); @@ -48,7 +48,7 @@ test("returns global prettier (by yarn) if user's project has no local prettier const file = { getPath: () => filePath }; const editor = createMockTextEditor({ buffer: { file } }); const fakeGloballyInstalledPrettier = path.join(__dirname, '..', '..', 'tests', 'fixtures', 'prettier.js'); - atomLinter.findCached.mockImplementation(dir => + atomLinter.findCached.mockImplementation((dir) => dir === yarnGlobalModules ? fakeGloballyInstalledPrettier : null, ); diff --git a/src/helpers/isFileFormattable.js b/src/helpers/isFileFormattable.js index 7c490ed3..f510f5a1 100644 --- a/src/helpers/isFileFormattable.js +++ b/src/helpers/isFileFormattable.js @@ -22,10 +22,7 @@ const doesFileInfoIndicateFormattable = (fileInfo: Prettier$FileInfo): boolean = const isFileFormattable: (editor: ?TextEditor) => boolean = _.overEvery([ _.negate(_.isNil), // make sure editor is defined just in case there are weird edge cases isCurrentFilePathDefined, // make sure filepath is defined for same reason - _.flow( - getPrettierFileInfoForCurrentFilePath, - doesFileInfoIndicateFormattable, - ), + _.flow(getPrettierFileInfoForCurrentFilePath, doesFileInfoIndicateFormattable), ]); module.exports = isFileFormattable; diff --git a/src/helpers/isFileFormattable.test.js b/src/helpers/isFileFormattable.test.js index 9e08ca84..4a88e137 100644 --- a/src/helpers/isFileFormattable.test.js +++ b/src/helpers/isFileFormattable.test.js @@ -19,7 +19,7 @@ beforeEach(() => { findCachedFromFilePath.mockImplementation(() => '.prettierignore'); }); -const mockGetFileInfoSyncFunc = syncFunc => +const mockGetFileInfoSyncFunc = (syncFunc) => getPrettierInstance.mockImplementation(() => ({ getFileInfo: { sync: syncFunc } })); it('calls prettier.getFileInfo.sync with the proper arguments', () => { diff --git a/src/helpers/isPrettierProperVersion.js b/src/helpers/isPrettierProperVersion.js index f78a5be1..30a6e39d 100644 --- a/src/helpers/isPrettierProperVersion.js +++ b/src/helpers/isPrettierProperVersion.js @@ -21,7 +21,7 @@ const displayImproperPrettierVersionError = _.once(() => // NOTE: We are using the presence of getFileInfo.sync to determine whether prettier is new enough. // This may change over time so feel free to update this to use something else when necessary. -const isGetFileInfoDefined = prettier => !!_.get('getFileInfo.sync', prettier); +const isGetFileInfoDefined = (prettier) => !!_.get('getFileInfo.sync', prettier); const isPrettierProperVersion: (editor: TextEditor) => boolean = _.flow( getPrettierInstance, diff --git a/src/main.js b/src/main.js index acda5057..724d2d10 100644 --- a/src/main.js +++ b/src/main.js @@ -35,7 +35,7 @@ const attachStatusTile = () => { subscriptions.add( // onDidChangeActiveTextEditor is only available in Atom 1.18.0+. atom.workspace.onDidChangeActiveTextEditor - ? atom.workspace.onDidChangeActiveTextEditor(editor => updateStatusTileScope(tileElement, editor)) + ? atom.workspace.onDidChangeActiveTextEditor((editor) => updateStatusTileScope(tileElement, editor)) : atom.workspace.onDidChangeActivePaneItem(() => updateStatusTileScope(tileElement, atom.workspace.getActiveTextEditor()), ), @@ -70,12 +70,12 @@ const activate = () => { }), atom.commands.add('atom-workspace', 'prettier:debug', displayDebugInfo), atom.commands.add('atom-workspace', 'prettier:toggle-format-on-save', toggleFormatOnSave), - atom.workspace.observeTextEditors(editor => + atom.workspace.observeTextEditors((editor) => subscriptions.add(editor.getBuffer().onWillSave(() => editor && formatOnSave(editor))), ), atom.config.observe('linter-eslint.fixOnSave', warnAboutLinterEslintFixOnSave), atom.config.observe('prettier-atom.useEslint', warnAboutLinterEslintFixOnSave), - atom.config.observe('prettier-atom.formatOnSaveOptions.showInStatusBar', show => + atom.config.observe('prettier-atom.formatOnSaveOptions.showInStatusBar', (show) => show ? attachStatusTile() : detachStatusTile(), ), ); @@ -91,7 +91,7 @@ const deactivate = () => { detachStatusTile(); }; -const consumeStatusBar = statusBar => { +const consumeStatusBar = (statusBar) => { statusBarHandler = statusBar; const showInStatusBar = atom.config.get('prettier-atom.formatOnSaveOptions.showInStatusBar'); @@ -100,14 +100,14 @@ const consumeStatusBar = statusBar => { } }; -const consumeIndie = registerIndie => { +const consumeIndie = (registerIndie) => { const linter = registerIndie({ name: 'Prettier' }); linterInterface.set(linter); subscriptions.add(linter); // Setting and clearing messages per filePath subscriptions.add( - atom.workspace.observeTextEditors(textEditor => { + atom.workspace.observeTextEditors((textEditor) => { const editorPath = textEditor.getPath(); if (!editorPath) { return; diff --git a/src/manualFormat/index.js b/src/manualFormat/index.js index 670f94b4..d155d6c6 100644 --- a/src/manualFormat/index.js +++ b/src/manualFormat/index.js @@ -8,7 +8,9 @@ const { isPrettierProperVersion } = require('../helpers'); const hasSelectedText = (editor: TextEditor) => !!editor.getSelectedText(); const formatSelectedBufferRanges = (editor: TextEditor) => - editor.getSelectedBufferRanges().forEach(bufferRange => executePrettierOnBufferRange(editor, bufferRange)); + editor + .getSelectedBufferRanges() + .forEach((bufferRange) => executePrettierOnBufferRange(editor, bufferRange)); const executePrettierOnCurrentBufferRange = (editor: TextEditor) => executePrettierOnBufferRange(editor, getBufferRange(editor)); diff --git a/src/statusTile/createStatusTile.test.js b/src/statusTile/createStatusTile.test.js index c7d5cae1..078f5e63 100644 --- a/src/statusTile/createStatusTile.test.js +++ b/src/statusTile/createStatusTile.test.js @@ -16,7 +16,7 @@ beforeEach(() => { appendChild: jest.fn(), addEventListener: jest.fn(), })), - createTextNode: jest.fn(arg => arg), + createTextNode: jest.fn((arg) => arg), }; }); diff --git a/src/statusTile/updateStatusTile.test.js b/src/statusTile/updateStatusTile.test.js index f193e83b..c6b21af7 100644 --- a/src/statusTile/updateStatusTile.test.js +++ b/src/statusTile/updateStatusTile.test.js @@ -21,7 +21,7 @@ const callUpdateStatusTile = () => { }; beforeEach(() => { - atom = { tooltips: { add: jest.fn(x => x) } }; + atom = { tooltips: { add: jest.fn((x) => x) } }; }); it('disposes existing tooltip', () => { diff --git a/yarn.lock b/yarn.lock index f5b0f273..373e6027 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6954,10 +6954,10 @@ prettier-stylelint@^0.4.2: tempy "^0.2.1" update-notifier "^2.2.0" -prettier@1.18.2: - version "1.18.2" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" - integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== +prettier@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.2.tgz#1ba8f3eb92231e769b7fcd7cb73ae1b6b74ade08" + integrity sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg== prettier@^1.16.4, prettier@^1.19.1, prettier@^1.7.0: version "1.19.1"