From b920aeb00bc6201ec6ad05e127c8266a6b7609db Mon Sep 17 00:00:00 2001 From: Matyas Szabo Date: Mon, 25 Nov 2024 12:25:42 +0100 Subject: [PATCH] refactor(many): fix docs code blocks, fix whitespace not trimmed --- packages/__docs__/src/compileMarkdown.tsx | 3 ++- packages/babel-plugin-transform-imports/README.md | 13 +++++++++++++ packages/ui-form-field/README.md | 3 +++ packages/ui-test-locator/README.md | 5 ++++- packages/ui-tooltip/README.md | 3 +++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/packages/__docs__/src/compileMarkdown.tsx b/packages/__docs__/src/compileMarkdown.tsx index 8e530cf413..6ffba4a915 100644 --- a/packages/__docs__/src/compileMarkdown.tsx +++ b/packages/__docs__/src/compileMarkdown.tsx @@ -49,7 +49,8 @@ function trimIndent(str: string) { let indent = '' lines.forEach((line, _i) => { // matches whitespace at the end of a string - line.replace(/\s*$/, '') + // eslint-disable-next-line no-param-reassign + line = line.replace(/\s*$/, '') if (indentFound === false) { if (line === '') { return diff --git a/packages/babel-plugin-transform-imports/README.md b/packages/babel-plugin-transform-imports/README.md index deb973a1cf..cc406fd55b 100644 --- a/packages/babel-plugin-transform-imports/README.md +++ b/packages/babel-plugin-transform-imports/README.md @@ -7,16 +7,29 @@ category: packages This will convert any non-default imports that are referencing the package only to reference the full path to the module instead. For example: ```js +--- + type: code +--- // a named member import: import { Text } from '@instructure/ui-elements' +``` would be converted to +```js +--- + type: code +--- // a named import using the full module path: import { Text } from '@instructure/ui-elements/lib/Text' +``` Note that any default imports you are currently using will not be transformed: +```js +--- + type: code +--- // a default import using the full path (will not be transformed): import Text from '@instructure/ui-elements/lib/Text' ``` diff --git a/packages/ui-form-field/README.md b/packages/ui-form-field/README.md index d0f888f1d3..778552322d 100644 --- a/packages/ui-form-field/README.md +++ b/packages/ui-form-field/README.md @@ -30,6 +30,9 @@ npm install @instructure/ui-form-field ### Usage ```js +--- + type: code +--- import React from 'react' import { FormField } from '@instructure/ui-form-field' diff --git a/packages/ui-test-locator/README.md b/packages/ui-test-locator/README.md index ccd3fcfefd..c5ae70378b 100644 --- a/packages/ui-test-locator/README.md +++ b/packages/ui-test-locator/README.md @@ -18,7 +18,10 @@ npm install @instructure/ui-test-locator ### Usage -```javascript +```js +--- + type: code +--- // MyComponent.js import { testable } from '@instructure/ui-testable' diff --git a/packages/ui-tooltip/README.md b/packages/ui-tooltip/README.md index 5c0d96e0cb..1d576432bf 100644 --- a/packages/ui-tooltip/README.md +++ b/packages/ui-tooltip/README.md @@ -25,6 +25,9 @@ npm install @instructure/ui-tooltip ### Usage ```js +--- + type: code +--- import React from 'react' import { Tooltip } from '@instructure/ui-tooltip'