From 18a6641d9da4ae7eea94305f00c0adbdb2009982 Mon Sep 17 00:00:00 2001 From: richardtmiles Date: Thu, 27 Jul 2023 20:09:23 -0600 Subject: [PATCH 1/5] git actions use https://nodejs.dev/en/about/releases/ timelines, localsConvention gets non breaking changes. Custom functions can return array of strings and new case statements locals --- .github/workflows/test.js.yml | 2 +- .idea/.gitignore | 10 ++++ .idea/aws.xml | 11 ++++ .idea/inspectionProfiles/Project_Default.xml | 6 +++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 +++ .idea/postcss-modules.iml | 9 ++++ .idea/vcs.xml | 6 +++ package-lock.json | 56 +++++++------------- package.json | 2 +- src/localsConvention.js | 19 +++++++ 11 files changed, 96 insertions(+), 39 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/aws.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/postcss-modules.iml create mode 100644 .idea/vcs.xml diff --git a/.github/workflows/test.js.yml b/.github/workflows/test.js.yml index 3ff38ca..30f1e89 100644 --- a/.github/workflows/test.js.yml +++ b/.github/workflows/test.js.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - node-version: [10.x, 12.x, 14.x, 15.x] + node-version: [10.x, 12.x, 14.x, 15.x, 18.x, 20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ runs-on: ${{ matrix.os }} diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..0a8642f --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Zeppelin ignored files +/ZeppelinRemoteNotebooks/ diff --git a/.idea/aws.xml b/.idea/aws.xml new file mode 100644 index 0000000..b63b642 --- /dev/null +++ b/.idea/aws.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5816206 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/postcss-modules.iml b/.idea/postcss-modules.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/postcss-modules.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b447596..2937933 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "postcss-modules", - "version": "6.0.0", + "version": "6.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "postcss-modules", - "version": "6.0.0", + "version": "6.0.1", "license": "MIT", "dependencies": { "generic-names": "^4.0.0", @@ -4228,7 +4228,8 @@ "node_modules/colorette": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", - "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" + "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==", + "dev": true }, "node_modules/combined-stream": { "version": "1.0.8", @@ -8920,6 +8921,7 @@ "version": "3.1.20", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", + "dev": true, "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -9600,6 +9602,7 @@ "version": "8.2.4", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.4.tgz", "integrity": "sha512-kRFftRoExRVXZlwUuay9iC824qmXPcQQVzAjbCCgjpXnkdMCJYBu2gTwAaFBzv8ewND6O8xFb3aELmEkh9zTzg==", + "dev": true, "dependencies": { "colorette": "^1.2.1", "nanoid": "^3.1.20", @@ -9691,6 +9694,7 @@ "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -11800,20 +11804,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", - "integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==", - "dev": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", @@ -14785,8 +14775,7 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", - "dev": true, - "requires": {} + "dev": true }, "acorn-walk": { "version": "7.2.0", @@ -15453,7 +15442,8 @@ "colorette": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", - "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" + "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==", + "dev": true }, "combined-stream": { "version": "1.0.8", @@ -16821,8 +16811,7 @@ "icss-utils": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/icss-utils/-/icss-utils-5.1.0.tgz", - "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==", - "requires": {} + "integrity": "sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA==" }, "ignore": { "version": "4.0.6", @@ -17878,8 +17867,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.1.tgz", "integrity": "sha512-pgFw2tm54fzgYvc/OHrnysABEObZCUNFnhjoRjaVOCN8NYc032/gVjPaHD4Aq6ApkSieWtfKAFQtmDKAmhupnQ==", - "dev": true, - "requires": {} + "dev": true }, "jest-regex-util": { "version": "26.0.0", @@ -19051,7 +19039,8 @@ "nanoid": { "version": "3.1.20", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.20.tgz", - "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==" + "integrity": "sha512-a1cQNyczgKbLX9jwbS/+d7W8fX/RfgYR7lVWwWOGIPNgK2m0MWvrGF6/m4kk6U3QcFMnZf3RIhL0v2Jgh/0Uxw==", + "dev": true }, "nanomatch": { "version": "1.2.13", @@ -19578,6 +19567,7 @@ "version": "8.2.4", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.2.4.tgz", "integrity": "sha512-kRFftRoExRVXZlwUuay9iC824qmXPcQQVzAjbCCgjpXnkdMCJYBu2gTwAaFBzv8ewND6O8xFb3aELmEkh9zTzg==", + "dev": true, "requires": { "colorette": "^1.2.1", "nanoid": "^3.1.20", @@ -19587,15 +19577,15 @@ "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true } } }, "postcss-modules-extract-imports": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz", - "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==", - "requires": {} + "integrity": "sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw==" }, "postcss-modules-local-by-default": { "version": "4.0.0", @@ -21314,13 +21304,6 @@ "is-typedarray": "^1.0.0" } }, - "typescript": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", - "integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==", - "dev": true, - "peer": true - }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", @@ -21666,8 +21649,7 @@ "version": "7.3.0", "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==", - "dev": true, - "requires": {} + "dev": true }, "xml-name-validator": { "version": "3.0.0", diff --git a/package.json b/package.json index ef7896d..3570a04 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postcss-modules", - "version": "6.0.0", + "version": "6.0.1", "description": "PostCSS plugin to use CSS Modules everywhere", "main": "build/index.js", "types": "index.d.ts", diff --git a/src/localsConvention.js b/src/localsConvention.js index 91c9e30..a6ba263 100644 --- a/src/localsConvention.js +++ b/src/localsConvention.js @@ -10,12 +10,31 @@ export function makeLocalsConventionReducer(localsConvention, inputFile) { return (tokens, [className, value]) => { if (isFunc) { const convention = localsConvention(className, value, inputFile); + + if (Array.isArray(convention)) { + + convention.forEach(convention => tokens[convention] = value); + + return tokens; + + } + tokens[convention] = value; return tokens; } switch (localsConvention) { + case "none": + tokens[className] = value; + break; + + case "all": + tokens[className] = value; + tokens[camelCase(className)] = value; + tokens[dashesCamelCase(className)] = value; + break; + case "camelCase": tokens[className] = value; tokens[camelCase(className)] = value; From d072a8bcaa8b7340b6f95d5990db56cf85dc486f Mon Sep 17 00:00:00 2001 From: richardtmiles Date: Thu, 27 Jul 2023 20:09:35 -0600 Subject: [PATCH 2/5] git actions --- .github/workflows/test.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.js.yml b/.github/workflows/test.js.yml index 30f1e89..8fabe69 100644 --- a/.github/workflows/test.js.yml +++ b/.github/workflows/test.js.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - node-version: [10.x, 12.x, 14.x, 15.x, 18.x, 20.x] + node-version: [16.x, 18.x, 19.x, 20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ runs-on: ${{ matrix.os }} From 08f28a29bfaf66254ddcb2872af7d822958ca27b Mon Sep 17 00:00:00 2001 From: richardtmiles Date: Thu, 27 Jul 2023 20:11:13 -0600 Subject: [PATCH 3/5] removing intellij files --- .gitignore | 1 + .idea/.gitignore | 10 ---------- .idea/aws.xml | 11 ----------- .idea/inspectionProfiles/Project_Default.xml | 6 ------ .idea/misc.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/postcss-modules.iml | 9 --------- .idea/vcs.xml | 6 ------ 8 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/aws.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/postcss-modules.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 013eddc..5de664d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build/ npm-debug.log index.es5.js undefined.json +.idea/ diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 0a8642f..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml -# Zeppelin ignored files -/ZeppelinRemoteNotebooks/ diff --git a/.idea/aws.xml b/.idea/aws.xml deleted file mode 100644 index b63b642..0000000 --- a/.idea/aws.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 03d9549..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 639900d..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 5816206..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/postcss-modules.iml b/.idea/postcss-modules.iml deleted file mode 100644 index d6ebd48..0000000 --- a/.idea/postcss-modules.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From c9463cf79359f84ad811527dddc64f9202f56ff9 Mon Sep 17 00:00:00 2001 From: richardtmiles Date: Thu, 27 Jul 2023 20:17:34 -0600 Subject: [PATCH 4/5] updating doc --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2059f3c..979bdfc 100644 --- a/README.md +++ b/README.md @@ -197,11 +197,13 @@ Default: `null` Style of exported classnames, the keys in your json. | Name | Type | Description | -| :-------------------: | :--------: | :----------------------------------------------------------------------------------------------- | +|:---------------------:| :--------: |:-------------------------------------------------------------------------------------------------| | **`'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 | | **`'dashesOnly'`** | `{String}` | Dashes in class names will be camelized, the original class name will be removed from the locals | +| **`'all'`** | `{String}` | Apply camelCase dashes and the orignional naming convention | +| **`'none'`** | `{String}` | Only use the orignional naming convention with out locals | In lieu of a string, a custom function can generate the exported class names. From b9bf8015ce14ac84d1708e1b44cae5f2c835c1b8 Mon Sep 17 00:00:00 2001 From: richardtmiles Date: Thu, 27 Jul 2023 20:18:15 -0600 Subject: [PATCH 5/5] commas --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 979bdfc..ad25065 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ postcss([ ### localsConvention -Type: `String | (originalClassName: string, generatedClassName: string, inputFile: string) => className: string` +Type: `String | (originalClassName: string, generatedClassName: string, inputFile: string) => className: (string|string[])` Default: `null` Style of exported classnames, the keys in your json. @@ -202,7 +202,7 @@ Style of exported classnames, the keys in your json. | **`'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 | | **`'dashesOnly'`** | `{String}` | Dashes in class names will be camelized, the original class name will be removed from the locals | -| **`'all'`** | `{String}` | Apply camelCase dashes and the orignional naming convention | +| **`'all'`** | `{String}` | Apply camelCase, dashes, and the orignional naming convention | | **`'none'`** | `{String}` | Only use the orignional naming convention with out locals | In lieu of a string, a custom function can generate the exported class names.