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

feat: exportLocalsStyle was remove in favor new localsConvention #958

Merged
merged 1 commit into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ module.exports = {

## Options

| Name | Type | Default | Description |
| :-------------------------------------------: | :-------------------------: | :-----: | :------------------------------------------------- |
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enable/Disable `url()` handling |
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enable/Disable @import handling |
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `false` | Enable/Disable CSS Modules and setup their options |
| **[`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 |
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |
| Name | Type | Default | Description |
| :-----------------------------------------: | :-------------------------: | :-----: | :------------------------------------------------- |
| **[`url`](#url)** | `{Boolean\|Function}` | `true` | Enable/Disable `url()` handling |
| **[`import`](#import)** | `{Boolean\|Function}` | `true` | Enable/Disable @import handling |
| **[`modules`](#modules)** | `{Boolean\|String\|Object}` | `false` | Enable/Disable CSS Modules and setup their options |
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `false` | Enable/Disable Sourcemaps |
| **[`importLoaders`](#importloaders)** | `{Number}` | `0` | Number of loaders applied before CSS loader |
| **[`localsConvention`](#localsconvention)** | `{String}` | `asIs` | Setup style of exported classnames |
| **[`onlyLocals`](#onlylocals)** | `{Boolean}` | `false` | Export only locals |

### `url`

Expand Down Expand Up @@ -763,7 +763,7 @@ module.exports = {

This may change in the future when the module system (i. e. webpack) supports loader matching by origin.

### `exportLocalsStyle`
### `localsConvention`

Type: `String`
Default: `undefined`
Expand Down Expand Up @@ -801,7 +801,7 @@ module.exports = {
test: /\.css$/i,
loader: 'css-loader',
options: {
exportLocalsStyle: 'camelCase',
localsConvention: 'camelCase',
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function loader(content, map, meta) {
icssParser({
loaderContext: this,
importPrefix,
exportLocalsStyle: options.exportLocalsStyle,
localsConvention: options.localsConvention,
})
);

Expand Down
2 changes: 1 addition & 1 deletion src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
}
]
},
"exportLocalsStyle": {
"localsConvention": {
"anyOf": [
{
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/postcss-icss-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default postcss.plugin(

result.messages.push({
pluginName,
export: getExportItemCode(name, value, options.exportLocalsStyle),
export: getExportItemCode(name, value, options.localsConvention),
type: 'export',
item: { name, value },
});
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,15 @@ function getModuleCode(result, sourceMap, onlyLocals) {
)}, ""${sourceMap && result.map ? `,${result.map}` : ''}]);\n`;
}

function getExportItemCode(key, value, localsStyle) {
function getExportItemCode(key, value, localsConvention) {
let targetKey;
const items = [];

function addEntry(k) {
items.push(`\t${JSON.stringify(k)}: ${JSON.stringify(value)}`);
}

switch (localsStyle) {
switch (localsConvention) {
case 'camelCase':
addEntry(key);
targetKey = camelCase(key);
Expand Down
241 changes: 0 additions & 241 deletions test/__snapshots__/exportLocalsStyle-option.test.js.snap

This file was deleted.

Loading