From 4ee211238dc214e9ccf29bd1e44fca70c6d5b163 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 10 Aug 2024 07:01:16 +0900 Subject: [PATCH 1/2] Start adding lint rules for 40px default size --- .eslintrc.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index cb669fb4177206..fd033cd93d118e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -278,7 +278,6 @@ module.exports = { }, }, { - // Temporary rules until we're ready to officially deprecate the bottom margins. files: [ 'packages/*/src/**/*.[tj]s?(x)' ], excludedFiles: [ 'packages/components/src/**/@(test|stories)/**', @@ -289,6 +288,7 @@ module.exports = { 'error', ...restrictedSyntax, ...restrictedSyntaxComponents, + // Temporary rules until we're ready to officially deprecate the bottom margins. ...[ 'CheckboxControl', 'ComboboxControl', @@ -308,6 +308,18 @@ module.exports = { componentName + ' should have the `__nextHasNoMarginBottom` prop to opt-in to the new margin-free styles.', } ) ), + // Temporary rules until we're ready to officially default to the new size. + ...[ + 'BorderBoxControl', + 'BorderControl', + 'DimensionControl', + 'FontSizePicker', + ].map( ( componentName ) => ( { + selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"][value.value!="default"]))`, + message: + componentName + + ' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.', + } ) ), ], }, }, From 0fc2b7ef0650b313631cd66c5defca341274fd9a Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 10 Aug 2024 09:40:28 +0900 Subject: [PATCH 2/2] Make stricter --- .eslintrc.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index fd033cd93d118e..80279ff13ed0a3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -315,7 +315,8 @@ module.exports = { 'DimensionControl', 'FontSizePicker', ].map( ( componentName ) => ( { - selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"])):not(:has(JSXAttribute[name.name="size"][value.value!="default"]))`, + // Falsy `__next40pxDefaultSize` without a non-default `size` prop. + selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__next40pxDefaultSize"][value.expression.value!=false])):not(:has(JSXAttribute[name.name="size"][value.value!="default"]))`, message: componentName + ' should have the `__next40pxDefaultSize` prop to opt-in to the new default size.',