From aa75fa77ed6cce18856321f87747e59d030674d8 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Tue, 11 Jun 2019 14:15:25 +0300 Subject: [PATCH] feat: `exportOnlyLocals` was remove in favor new `onlyLocals` option (#957) BREAKING CHANGE: rename `exportOnlyLocals` option to `onlyLocals` option --- README.md | 8 ++++---- src/index.js | 2 +- src/options.json | 2 +- ...option.test.js.snap => onlyLocals-option.test.js.snap} | 0 test/__snapshots__/validate-options.test.js.snap | 2 +- ...nlyLocals-option.test.js => onlyLocals-option.test.js} | 2 +- test/validate-options.test.js | 8 +++----- 7 files changed, 11 insertions(+), 13 deletions(-) rename test/__snapshots__/{exportOnlyLocals-option.test.js.snap => onlyLocals-option.test.js.snap} (100%) rename test/{exportOnlyLocals-option.test.js => onlyLocals-option.test.js} (96%) diff --git a/README.md b/README.md index 1aa98769..b8033ee0 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ module.exports = { | **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enable/Disable Sourcemaps | | **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Number of loaders applied before CSS loader | | **[`exportLocalsStyle`](#exportlocalsstyle)** | `{String}` | `asIs` | Setup style of exported classnames | -| **[`exportOnlyLocals`](#exportonlylocals)** | `{Boolean}` | `false` | Export only locals | +| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals | ### `url` @@ -772,7 +772,7 @@ By default, the exported JSON keys mirror the class names (i.e `asIs` value). | Name | Type | Description | | :-------------------: | :--------: | :----------------------------------------------------------------------------------------------- | -| **`asIs`** | `{String}` | Class names will be exported as is. | +| **`'asIs'`** | `{String}` | Class names will be exported as is. | | **`'camelCase'`** | `{String}` | Class names will be camelized, the original class name will not to be removed from the locals | | **`'camelCaseOnly'`** | `{String}` | Class names will be camelized, the original class name will be removed from the locals | | **`'dashes'`** | `{String}` | Only dashes in class names will be camelized | @@ -809,7 +809,7 @@ module.exports = { }; ``` -### `exportOnlyLocals` +### `onlyLocals` Type: `Boolean` Default: `false` @@ -828,7 +828,7 @@ module.exports = { test: /\.css$/i, loader: 'css-loader', options: { - exportOnlyLocals: true, + onlyLocals: true, }, }, ], diff --git a/src/index.js b/src/index.js index 547d6d5e..c51bd6d0 100644 --- a/src/index.js +++ b/src/index.js @@ -115,7 +115,7 @@ export default function loader(content, map, meta) { result.messages = []; } - const { exportOnlyLocals: onlyLocals } = options; + const { onlyLocals } = options; const importItems = result.messages .filter((message) => (message.type === 'import' ? message : false)) diff --git a/src/options.json b/src/options.json index 46f9dab9..6a4fba82 100644 --- a/src/options.json +++ b/src/options.json @@ -92,7 +92,7 @@ } ] }, - "exportOnlyLocals": { + "onlyLocals": { "type": "boolean" } }, diff --git a/test/__snapshots__/exportOnlyLocals-option.test.js.snap b/test/__snapshots__/onlyLocals-option.test.js.snap similarity index 100% rename from test/__snapshots__/exportOnlyLocals-option.test.js.snap rename to test/__snapshots__/onlyLocals-option.test.js.snap diff --git a/test/__snapshots__/validate-options.test.js.snap b/test/__snapshots__/validate-options.test.js.snap index d6bcf1da..f77d9bce 100644 --- a/test/__snapshots__/validate-options.test.js.snap +++ b/test/__snapshots__/validate-options.test.js.snap @@ -179,6 +179,6 @@ options.importLoaders should match some schema in anyOf exports[`validate options 18`] = ` "CSS Loader Invalid Options -options.exportOnlyLocals should be boolean +options.onlyLocals should be boolean " `; diff --git a/test/exportOnlyLocals-option.test.js b/test/onlyLocals-option.test.js similarity index 96% rename from test/exportOnlyLocals-option.test.js rename to test/onlyLocals-option.test.js index 826da10f..3b547342 100644 --- a/test/exportOnlyLocals-option.test.js +++ b/test/onlyLocals-option.test.js @@ -9,7 +9,7 @@ describe('modules', () => { mode: 'local', localIdentName: '_[local]', }, - exportOnlyLocals: true, + onlyLocals: true, }, }, }; diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 2f711d3a..2f7def7b 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -107,9 +107,7 @@ it('validate options', () => { expect(() => validate({ importLoaders: 2 })).not.toThrow(); expect(() => validate({ importLoaders: '1' })).toThrowErrorMatchingSnapshot(); - expect(() => validate({ exportOnlyLocals: true })).not.toThrow(); - expect(() => validate({ exportOnlyLocals: false })).not.toThrow(); - expect(() => - validate({ exportOnlyLocals: 'true' }) - ).toThrowErrorMatchingSnapshot(); + expect(() => validate({ onlyLocals: true })).not.toThrow(); + expect(() => validate({ onlyLocals: false })).not.toThrow(); + expect(() => validate({ onlyLocals: 'true' })).toThrowErrorMatchingSnapshot(); });