From 0763981a1b17c49ab508a63f1b1d8349c9eaabb1 Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 25 Nov 2018 21:05:31 +0800 Subject: [PATCH 1/2] test: add tests --- tests_integration/__tests__/config-resolution.js | 10 ++++++++++ .../cli/config/editorconfig/.editorconfig | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests_integration/__tests__/config-resolution.js b/tests_integration/__tests__/config-resolution.js index 96ff204c6506..e477fc19b78e 100644 --- a/tests_integration/__tests__/config-resolution.js +++ b/tests_integration/__tests__/config-resolution.js @@ -150,6 +150,16 @@ test("API resolveConfig.sync with file arg and .editorconfig", () => { }); }); +test("API resolveConfig.sync with file arg and .editorconfig (key = unset)", () => { + const file = path.resolve( + path.join(__dirname, "../cli/config/editorconfig/tab_width=unset.js") + ); + + expect( + prettier.resolveConfig.sync(file, { editorconfig: true }) + ).toMatchObject({ tabWidth: "unset" }); +}); + test("API resolveConfig with nested file arg and .editorconfig", () => { const file = path.resolve( path.join(__dirname, "../cli/config/editorconfig/lib/file.js") diff --git a/tests_integration/cli/config/editorconfig/.editorconfig b/tests_integration/cli/config/editorconfig/.editorconfig index 8bd599323adc..3157081e413a 100644 --- a/tests_integration/cli/config/editorconfig/.editorconfig +++ b/tests_integration/cli/config/editorconfig/.editorconfig @@ -12,4 +12,7 @@ indent_style = space indent_size = 2 [lib/indent_size=tab.js] -indent_size = tab \ No newline at end of file +indent_size = tab + +[tab_width=unset.js] +tab_width = unset From bb34d0c6c3039be45fd9f318c46f81a089bb2d0a Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 25 Nov 2018 21:06:48 +0800 Subject: [PATCH 2/2] fix: update editorconfig-to-prettier --- package.json | 2 +- tests_integration/__tests__/config-resolution.js | 2 +- yarn.lock | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index b51d6ec205d6..442c81f1dbc5 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dedent": "0.7.0", "diff": "3.2.0", "editorconfig": "0.15.2", - "editorconfig-to-prettier": "0.1.0", + "editorconfig-to-prettier": "0.1.1", "emoji-regex": "6.5.1", "escape-string-regexp": "1.0.5", "esutils": "2.0.2", diff --git a/tests_integration/__tests__/config-resolution.js b/tests_integration/__tests__/config-resolution.js index e477fc19b78e..7d11f0fc182b 100644 --- a/tests_integration/__tests__/config-resolution.js +++ b/tests_integration/__tests__/config-resolution.js @@ -157,7 +157,7 @@ test("API resolveConfig.sync with file arg and .editorconfig (key = unset)", () expect( prettier.resolveConfig.sync(file, { editorconfig: true }) - ).toMatchObject({ tabWidth: "unset" }); + ).not.toMatchObject({ tabWidth: "unset" }); }); test("API resolveConfig with nested file arg and .editorconfig", () => { diff --git a/yarn.lock b/yarn.lock index 62fc4256773e..43e48df2bcf1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1815,9 +1815,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -editorconfig-to-prettier@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/editorconfig-to-prettier/-/editorconfig-to-prettier-0.1.0.tgz#c31d2ceea2ef922835c53f6ca0e5ba2930b8940d" +editorconfig-to-prettier@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/editorconfig-to-prettier/-/editorconfig-to-prettier-0.1.1.tgz#7391c7067dfd68ffee65afc2c4fbe4fba8d4219a" editorconfig@0.15.2: version "0.15.2"