From c5b6509f3b220e25445b8ac3de9cc692440ae7ed Mon Sep 17 00:00:00 2001 From: ismay Date: Fri, 10 May 2024 14:37:57 +0200 Subject: [PATCH 1/4] chore: add styled jsx syntax --- config/stylelint.config.js | 1 + package.json | 3 +++ yarn.lock | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/config/stylelint.config.js b/config/stylelint.config.js index 7c42d873..02381e81 100644 --- a/config/stylelint.config.js +++ b/config/stylelint.config.js @@ -1,4 +1,5 @@ module.exports = { + customSyntax: 'postcss-styled-jsx', plugins: ['stylelint-use-logical'], rules: { 'csstools/use-logical': [ diff --git a/package.json b/package.json index 5e8c3bf9..b1297950 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,9 @@ "husky": "^7.0.2", "micromatch": "^4.0.4", "perfy": "^1.1.5", + "postcss": "^8.4.38", + "postcss-styled-jsx": "^1.0.1", + "postcss-syntax": "^0.36.2", "prettier": "^2.4.1", "semver": "^7.3.5", "stylelint": "^16.3.1", diff --git a/yarn.lock b/yarn.lock index b4545760..2a258b9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4484,6 +4484,16 @@ postcss-selector-parser@^6.0.16: cssesc "^3.0.0" util-deprecate "^1.0.2" +postcss-styled-jsx@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/postcss-styled-jsx/-/postcss-styled-jsx-1.0.1.tgz#07c17ca3bc574a06627103bb5dd475006c2d0d9e" + integrity sha512-508Vg2A0pHQstRxz8eoNYiT+RiCZdgE4EqN0x8oiPIZ/a6pp5q2NYefL39RRG8ORlxDehLHU3u/EOpux0kuATQ== + +postcss-syntax@^0.36.2: + version "0.36.2" + resolved "https://registry.yarnpkg.com/postcss-syntax/-/postcss-syntax-0.36.2.tgz#f08578c7d95834574e5593a82dfbfa8afae3b51c" + integrity sha512-nBRg/i7E3SOHWxF3PpF5WnJM/jQ1YpY9000OaVXlAQj6Zp/kIqJxEDWIZ67tAd7NLuk7zqN4yqe9nc0oNAOs1w== + postcss-value-parser@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" From 832af338588f31451672bf0f3f809c8a4eab3a16 Mon Sep 17 00:00:00 2001 From: ismay Date: Fri, 10 May 2024 14:45:49 +0200 Subject: [PATCH 2/4] feat: add stylelint to check styled-jsx css in js --- src/commands/types/javascript.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/commands/types/javascript.js b/src/commands/types/javascript.js index 45f4497f..37352233 100644 --- a/src/commands/types/javascript.js +++ b/src/commands/types/javascript.js @@ -3,6 +3,7 @@ const { callback: runCb } = require('@dhis2/cli-helpers-engine').exec const { exit } = require('@dhis2/cli-helpers-engine') const { eslint } = require('../../tools/eslint.js') const { prettier } = require('../../tools/prettier.js') +const { stylelint } = require('../../tools/stylelint.js') const { configured } = require('../../utils/config.js') const { selectFiles } = require('../../utils/files.js') const { @@ -78,6 +79,17 @@ exports.handler = (argv, callback) => { log.log('No Prettier configuration found') } + if (configured('stylelint')) { + log.info('javascript > stylelint') + stylelint({ + apply, + files: jsFiles, + callback: finalStatus, + }) + } else { + log.log('No Prettier configuration found') + } + if (!callback) { log.debug(sayFilesChecked('javascript', jsFiles.length, apply)) exit(finalStatus()) From f3108f5d76baf76d89a2d17f8fd0694e069096e8 Mon Sep 17 00:00:00 2001 From: ismay Date: Wed, 15 May 2024 13:40:36 +0200 Subject: [PATCH 3/4] style: fix typo --- src/commands/types/javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/types/javascript.js b/src/commands/types/javascript.js index 37352233..c6a5d018 100644 --- a/src/commands/types/javascript.js +++ b/src/commands/types/javascript.js @@ -87,7 +87,7 @@ exports.handler = (argv, callback) => { callback: finalStatus, }) } else { - log.log('No Prettier configuration found') + log.log('No Stylelint configuration found') } if (!callback) { From 95144f22d097cad05f3aa3e890340f228c02c360 Mon Sep 17 00:00:00 2001 From: ismay Date: Wed, 15 May 2024 15:21:48 +0200 Subject: [PATCH 4/4] refactor: use recommended approach for applying custom syntax --- config/stylelint.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/stylelint.config.js b/config/stylelint.config.js index 02381e81..614cc0c2 100644 --- a/config/stylelint.config.js +++ b/config/stylelint.config.js @@ -1,5 +1,7 @@ module.exports = { - customSyntax: 'postcss-styled-jsx', + overrides: [ + { files: '**/*.{js,jsx,ts,tsx}', customSyntax: 'postcss-styled-jsx' }, + ], plugins: ['stylelint-use-logical'], rules: { 'csstools/use-logical': [