Просмотр исходного кода

configure biome for remark-growi-directive and autofix

Futa Arai 10 месяцев назад
Родитель
Сommit
ea54c7adc0
20 измененных файлов с 415 добавлено и 385 удалено
  1. 2 3
      biome.json
  2. 1 2
      packages/remark-growi-directive/.eslintignore
  3. 0 13
      packages/remark-growi-directive/.eslintrc.cjs
  4. 2 2
      packages/remark-growi-directive/package.json
  5. 23 28
      packages/remark-growi-directive/src/mdast-util-growi-directive/index.d.ts
  6. 17 13
      packages/remark-growi-directive/src/mdast-util-growi-directive/lib/index.js
  7. 7 1
      packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/directive-leaf.js
  8. 9 3
      packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/directive-text.js
  9. 57 49
      packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-attributes.js
  10. 13 13
      packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-label.js
  11. 3 3
      packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-name.js
  12. 6 7
      packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/html.js
  13. 5 5
      packages/remark-growi-directive/src/micromark-factory-attributes-devider/index.d.ts
  14. 4 1
      packages/remark-growi-directive/src/micromark-factory-attributes-devider/index.js
  15. 22 19
      packages/remark-growi-directive/src/remark-growi-directive.js
  16. 71 53
      packages/remark-growi-directive/test/mdast-util-growi-directive.test.js
  17. 165 151
      packages/remark-growi-directive/test/micromark-extension-growi-directive.test.js
  18. 4 7
      packages/remark-growi-directive/test/remark-growi-directive.test.js
  19. 3 9
      packages/remark-growi-directive/tsconfig.json
  20. 1 3
      packages/remark-growi-directive/vitest.config.ts

+ 2 - 3
biome.json

@@ -29,8 +29,7 @@
       "./packages/preset-templates/**",
       "./packages/preset-templates/**",
       "./packages/preset-themes/**",
       "./packages/preset-themes/**",
       "./packages/remark-attachment-refs/**",
       "./packages/remark-attachment-refs/**",
-      "./packages/remark-drawio/**",
-      "./packages/remark-growi-directive/**"
+      "./packages/remark-drawio/**"
     ]
     ]
   },
   },
   "formatter": {
   "formatter": {
@@ -51,4 +50,4 @@
       "quoteStyle": "single"
       "quoteStyle": "single"
     }
     }
   }
   }
-}
+}

+ 1 - 2
packages/remark-growi-directive/.eslintignore

@@ -1,2 +1 @@
-/dist/**
-/types/**
+*

+ 0 - 13
packages/remark-growi-directive/.eslintrc.cjs

@@ -1,13 +0,0 @@
-module.exports = {
-  rules: {
-    'import/extensions': [
-      'error',
-      'ignorePackages',
-      {
-        ts: 'never',
-        tsx: 'never',
-      },
-    ],
-    '@typescript-eslint/no-use-before-define': 'off',
-  },
-};

+ 2 - 2
packages/remark-growi-directive/package.json

@@ -24,8 +24,8 @@
     "test": "cross-env NODE_ENV=test npm run test-coverage",
     "test": "cross-env NODE_ENV=test npm run test-coverage",
     "test-api": "vitest run --coverage",
     "test-api": "vitest run --coverage",
     "test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
     "test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
-    "lint": "eslint \"**/*.{cjs, js,jsx,ts,tsx}\"",
-    "lint:fix": "eslint \"**/*.{cjs, js,jsx,ts,tsx}\" --fix"
+    "lint": "biome check",
+    "lint:fix": "biome check --write"
   },
   },
   "dependencies": {
   "dependencies": {
     "@types/mdast": "^4.0.4",
     "@types/mdast": "^4.0.4",

+ 23 - 28
packages/remark-growi-directive/src/mdast-util-growi-directive/index.d.ts

@@ -1,8 +1,4 @@
-import type {
-  Data,
-  Parent,
-  PhrasingContent,
-} from 'mdast';
+import type { Data, Parent, PhrasingContent } from 'mdast';
 
 
 import { DirectiveType as DirectiveTypeObject } from './lib/index.js';
 import { DirectiveType as DirectiveTypeObject } from './lib/index.js';
 
 
@@ -18,12 +14,12 @@ interface DirectiveFields {
   /**
   /**
    * Directive name.
    * Directive name.
    */
    */
-  name: string
+  name: string;
 
 
   /**
   /**
    * Directive attributes.
    * Directive attributes.
    */
    */
-  attributes?: Record<string, string | null | undefined> | null | undefined
+  attributes?: Record<string, string | null | undefined> | null | undefined;
 }
 }
 
 
 /**
 /**
@@ -33,25 +29,25 @@ export interface LeafGrowiPluginDirective extends Parent, DirectiveFields {
   /**
   /**
    * Node type of leaf directive.
    * Node type of leaf directive.
    */
    */
-  type: DirectiveType['Leaf']
+  type: DirectiveType['Leaf'];
 
 
   /**
   /**
    * Children of leaf directive.
    * Children of leaf directive.
    */
    */
-  children: PhrasingContent[]
+  children: PhrasingContent[];
 
 
   /**
   /**
    * Data associated with the mdast leaf directive.
    * Data associated with the mdast leaf directive.
    */
    */
-  data?: LeafGrowiPluginDirectiveData | undefined
+  data?: LeafGrowiPluginDirectiveData | undefined;
 }
 }
 
 
 /**
 /**
  * Info associated with mdast leaf directive nodes by the ecosystem.
  * Info associated with mdast leaf directive nodes by the ecosystem.
  */
  */
 export interface LeafGrowiPluginDirectiveData extends Data {
 export interface LeafGrowiPluginDirectiveData extends Data {
-  hName?: string,
-  hProperties?: Record<string, string>
+  hName?: string;
+  hProperties?: Record<string, string>;
 }
 }
 
 
 /**
 /**
@@ -61,34 +57,33 @@ export interface TextGrowiPluginDirective extends Parent, DirectiveFields {
   /**
   /**
    * Node type of text directive.
    * Node type of text directive.
    */
    */
-  type: DirectiveType['Text']
+  type: DirectiveType['Text'];
 
 
   /**
   /**
    * Children of text directive.
    * Children of text directive.
    */
    */
-  children: PhrasingContent[]
+  children: PhrasingContent[];
 
 
   /**
   /**
    * Data associated with the text leaf directive.
    * Data associated with the text leaf directive.
    */
    */
-  data?: TextGrowiPluginDirectiveData | undefined
+  data?: TextGrowiPluginDirectiveData | undefined;
 }
 }
 
 
 /**
 /**
  * Info associated with mdast text directive nodes by the ecosystem.
  * Info associated with mdast text directive nodes by the ecosystem.
  */
  */
 export interface TextGrowiPluginDirectiveData extends Data {
 export interface TextGrowiPluginDirectiveData extends Data {
-  hName?: string,
-  hProperties?: Record<string, string>
+  hName?: string;
+  hProperties?: Record<string, string>;
 }
 }
 
 
-
 /**
 /**
  * Union of registered mdast directive nodes.
  * Union of registered mdast directive nodes.
  *
  *
  * It is not possible to register custom mdast directive node types.
  * It is not possible to register custom mdast directive node types.
  */
  */
-export type Directives = LeafGrowiPluginDirective | TextGrowiPluginDirective
+export type Directives = LeafGrowiPluginDirective | TextGrowiPluginDirective;
 
 
 // Add custom data tracked to turn markdown into a tree.
 // Add custom data tracked to turn markdown into a tree.
 declare module 'mdast-util-from-markdown' {
 declare module 'mdast-util-from-markdown' {
@@ -96,7 +91,7 @@ declare module 'mdast-util-from-markdown' {
     /**
     /**
      * Attributes for current directive.
      * Attributes for current directive.
      */
      */
-    directiveAttributes?: Array<[string, string]> | undefined
+    directiveAttributes?: Array<[string, string]> | undefined;
   }
   }
 }
 }
 
 
@@ -111,7 +106,7 @@ declare module 'mdast-util-to-markdown' {
      *     ^^^
      *     ^^^
      * ```
      * ```
      */
      */
-    leafGrowiPluginDirective: 'leafGrowiPluginDirective'
+    leafGrowiPluginDirective: 'leafGrowiPluginDirective';
 
 
     /**
     /**
      * Label of a leaf directive.
      * Label of a leaf directive.
@@ -121,7 +116,7 @@ declare module 'mdast-util-to-markdown' {
      *        ^^^
      *        ^^^
      * ```
      * ```
      */
      */
-    leafGrowiPluginDirectiveLabel: 'leafGrowiPluginDirectiveLabel'
+    leafGrowiPluginDirectiveLabel: 'leafGrowiPluginDirectiveLabel';
 
 
     /**
     /**
      * Whole text directive.
      * Whole text directive.
@@ -131,7 +126,7 @@ declare module 'mdast-util-to-markdown' {
      *     ^^
      *     ^^
      * ```
      * ```
      */
      */
-    textGrowiPluginDirective: 'textGrowiPluginDirective'
+    textGrowiPluginDirective: 'textGrowiPluginDirective';
 
 
     /**
     /**
      * Label of a text directive.
      * Label of a text directive.
@@ -141,7 +136,7 @@ declare module 'mdast-util-to-markdown' {
      *       ^^^
      *       ^^^
      * ```
      * ```
      */
      */
-    textGrowiPluginDirectiveLabel: 'textGrowiPluginDirectiveLabel'
+    textGrowiPluginDirectiveLabel: 'textGrowiPluginDirectiveLabel';
   }
   }
 }
 }
 
 
@@ -152,14 +147,14 @@ declare module 'mdast' {
      * Directive in flow content (such as in the root document, or block
      * Directive in flow content (such as in the root document, or block
      * quotes), which contains nothing.
      * quotes), which contains nothing.
      */
      */
-    leafGrowiPluginDirective: LeafGrowiPluginDirective
+    leafGrowiPluginDirective: LeafGrowiPluginDirective;
   }
   }
 
 
   interface PhrasingContentMap {
   interface PhrasingContentMap {
     /**
     /**
      * Directive in phrasing content (such as in paragraphs, headings).
      * Directive in phrasing content (such as in paragraphs, headings).
      */
      */
-    textGrowiPluginDirective: TextGrowiPluginDirective
+    textGrowiPluginDirective: TextGrowiPluginDirective;
   }
   }
 
 
   interface RootContentMap {
   interface RootContentMap {
@@ -167,11 +162,11 @@ declare module 'mdast' {
      * Directive in flow content (such as in the root document, or block
      * Directive in flow content (such as in the root document, or block
      * quotes), which contains nothing.
      * quotes), which contains nothing.
      */
      */
-    leafGrowiPluginDirective: LeafGrowiPluginDirective
+    leafGrowiPluginDirective: LeafGrowiPluginDirective;
 
 
     /**
     /**
      * Directive in phrasing content (such as in paragraphs, headings).
      * Directive in phrasing content (such as in paragraphs, headings).
      */
      */
-    textGrowiPluginDirective: TextGrowiPluginDirective
+    textGrowiPluginDirective: TextGrowiPluginDirective;
   }
   }
 }
 }

+ 17 - 13
packages/remark-growi-directive/src/mdast-util-growi-directive/lib/index.js

@@ -24,7 +24,6 @@ const own = {}.hasOwnProperty;
 
 
 const shortcut = /^[^\t\n\r "#'.<=>`}]+$/;
 const shortcut = /^[^\t\n\r "#'.<=>`}]+$/;
 
 
-
 export const DirectiveType = Object.freeze({
 export const DirectiveType = Object.freeze({
   Text: 'textGrowiPluginDirective',
   Text: 'textGrowiPluginDirective',
   Leaf: 'leafGrowiPluginDirective',
   Leaf: 'leafGrowiPluginDirective',
@@ -102,9 +101,15 @@ function enterText(token) {
  * @param {Token} token
  * @param {Token} token
  */
  */
 function enter(type, token) {
 function enter(type, token) {
-  this.enter({
-    type, name: '', attributes: {}, children: [],
-  }, token);
+  this.enter(
+    {
+      type,
+      name: '',
+      attributes: {},
+      children: [],
+    },
+    token,
+  );
 }
 }
 
 
 /**
 /**
@@ -213,7 +218,8 @@ function peekDirective() {
  */
  */
 function attributes(node, state) {
 function attributes(node, state) {
   const quote = state.options.quote || '"';
   const quote = state.options.quote || '"';
-  const subset = node.type === DirectiveType.Text ? [quote] : [quote, '\n', '\r'];
+  const subset =
+    node.type === DirectiveType.Text ? [quote] : [quote, '\n', '\r'];
   const attrs = node.attributes || {};
   const attrs = node.attributes || {};
   /** @type {Array.<string>} */
   /** @type {Array.<string>} */
   const values = [];
   const values = [];
@@ -229,9 +235,9 @@ function attributes(node, state) {
   // eslint-disable-next-line no-restricted-syntax
   // eslint-disable-next-line no-restricted-syntax
   for (key in attrs) {
   for (key in attrs) {
     if (
     if (
-      own.call(attrs, key)
-      && attrs[key] !== undefined
-      && attrs[key] !== null
+      own.call(attrs, key) &&
+      attrs[key] !== undefined &&
+      attrs[key] !== null
     ) {
     ) {
       const value = String(attrs[key]);
       const value = String(attrs[key]);
 
 
@@ -248,8 +254,8 @@ function attributes(node, state) {
    */
    */
   function quoted(key, value) {
   function quoted(key, value) {
     return (
     return (
-      key
-      + (value
+      key +
+      (value
         ? `=${quote}${stringifyEntitiesLight(value, { subset })}${quote}`
         ? `=${quote}${stringifyEntitiesLight(value, { subset })}${quote}`
         : '')
         : '')
     );
     );
@@ -265,11 +271,9 @@ function fence(node) {
 
 
   if (node.type === DirectiveType.Leaf) {
   if (node.type === DirectiveType.Leaf) {
     size = 1;
     size = 1;
-  }
-  else {
+  } else {
     size = 1;
     size = 1;
   }
   }
 
 
   return '$'.repeat(size);
   return '$'.repeat(size);
-
 }
 }

+ 7 - 1
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/directive-leaf.js

@@ -64,7 +64,13 @@ function tokenizeDirectiveLeaf(effects, ok, nok) {
     assert(code === codes.dollarSign, 'expected `$`');
     assert(code === codes.dollarSign, 'expected `$`');
     effects.enter('directiveGrowiLeaf');
     effects.enter('directiveGrowiLeaf');
     effects.consume(code);
     effects.consume(code);
-    return factoryName.call(self, effects, afterName, nok, 'directiveGrowiLeafName');
+    return factoryName.call(
+      self,
+      effects,
+      afterName,
+      nok,
+      'directiveGrowiLeafName',
+    );
   }
   }
 
 
   /** @type {State} */
   /** @type {State} */

+ 9 - 3
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/directive-text.js

@@ -25,8 +25,8 @@ const attributes = { tokenize: tokenizeAttributes, partial: true };
 function previous(code) {
 function previous(code) {
   // If there is a previous code, there will always be a tail.
   // If there is a previous code, there will always be a tail.
   return (
   return (
-    code !== codes.dollarSign
-    || this.events[this.events.length - 1][1].type === types.characterEscape
+    code !== codes.dollarSign ||
+    this.events[this.events.length - 1][1].type === types.characterEscape
   );
   );
 }
 }
 
 
@@ -45,7 +45,13 @@ function tokenizeDirectiveText(effects, ok, nok) {
     effects.enter('directiveGrowiTextMarker');
     effects.enter('directiveGrowiTextMarker');
     effects.consume(code);
     effects.consume(code);
     effects.exit('directiveGrowiTextMarker');
     effects.exit('directiveGrowiTextMarker');
-    return factoryName.call(self, effects, afterName, nok, 'directiveGrowiTextName');
+    return factoryName.call(
+      self,
+      effects,
+      afterName,
+      nok,
+      'directiveGrowiTextName',
+    );
   }
   }
 
 
   /** @type {State} */
   /** @type {State} */

+ 57 - 49
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-attributes.js

@@ -14,7 +14,10 @@ import {
 import { codes, types } from 'micromark-util-symbol';
 import { codes, types } from 'micromark-util-symbol';
 import { ok as assert } from 'uvu/assert';
 import { ok as assert } from 'uvu/assert';
 
 
-import { markdownLineEndingOrSpaceOrComma, factoryAttributesDevider } from '../../micromark-factory-attributes-devider/index.js';
+import {
+  factoryAttributesDevider,
+  markdownLineEndingOrSpaceOrComma,
+} from '../../micromark-factory-attributes-devider/index.js';
 
 
 /**
 /**
  * @param {Effects} effects
  * @param {Effects} effects
@@ -33,19 +36,19 @@ import { markdownLineEndingOrSpaceOrComma, factoryAttributesDevider } from '../.
  */
  */
 /* eslint-disable-next-line max-params */
 /* eslint-disable-next-line max-params */
 export function factoryAttributes(
 export function factoryAttributes(
-    effects,
-    ok,
-    nok,
-    attributesType,
-    attributesMarkerType,
-    attributeType,
-    attributeNameType,
-    attributeInitializerType,
-    attributeValueLiteralType,
-    attributeValueType,
-    attributeValueMarker,
-    attributeValueData,
-    disallowEol,
+  effects,
+  ok,
+  nok,
+  attributesType,
+  attributesMarkerType,
+  attributeType,
+  attributeNameType,
+  attributeInitializerType,
+  attributeValueLiteralType,
+  attributeValueType,
+  attributeValueMarker,
+  attributeValueData,
+  disallowEol,
 ) {
 ) {
   /** @type {string} */
   /** @type {string} */
   let type;
   let type;
@@ -79,12 +82,13 @@ export function factoryAttributes(
       return factoryAttributesDevider(effects, between)(code);
       return factoryAttributesDevider(effects, between)(code);
     }
     }
 
 
-    if (code !== codes.rightParenthesis
-      && code !== codes.eof
-      && code !== codes.carriageReturn
-      && code !== codes.lineFeed
-      && code !== codes.carriageReturnLineFeed
-      && code !== codes.ampersand
+    if (
+      code !== codes.rightParenthesis &&
+      code !== codes.eof &&
+      code !== codes.carriageReturn &&
+      code !== codes.lineFeed &&
+      code !== codes.carriageReturnLineFeed &&
+      code !== codes.ampersand
     ) {
     ) {
       effects.enter(attributeType);
       effects.enter(attributeType);
       effects.enter(attributeNameType);
       effects.enter(attributeNameType);
@@ -98,19 +102,19 @@ export function factoryAttributes(
   /** @type {State} */
   /** @type {State} */
   function name(code) {
   function name(code) {
     if (
     if (
-      code !== codes.eof
-        && code !== codes.carriageReturn
-        && code !== codes.lineFeed
-        && code !== codes.carriageReturnLineFeed
-        && code !== codes.quotationMark
-        && code !== codes.apostrophe
-        && code !== codes.lessThan
-        && code !== codes.equalsTo
-        && code !== codes.greaterThan
-        && code !== codes.graveAccent
-        && code !== codes.rightParenthesis
-        && code !== codes.space
-        && code !== codes.comma
+      code !== codes.eof &&
+      code !== codes.carriageReturn &&
+      code !== codes.lineFeed &&
+      code !== codes.carriageReturnLineFeed &&
+      code !== codes.quotationMark &&
+      code !== codes.apostrophe &&
+      code !== codes.lessThan &&
+      code !== codes.equalsTo &&
+      code !== codes.greaterThan &&
+      code !== codes.graveAccent &&
+      code !== codes.rightParenthesis &&
+      code !== codes.space &&
+      code !== codes.comma
     ) {
     ) {
       effects.consume(code);
       effects.consume(code);
       return name;
       return name;
@@ -146,13 +150,13 @@ export function factoryAttributes(
   /** @type {State} */
   /** @type {State} */
   function valueBefore(code) {
   function valueBefore(code) {
     if (
     if (
-      code === codes.eof
-      || code === codes.lessThan
-      || code === codes.equalsTo
-      || code === codes.greaterThan
-      || code === codes.graveAccent
-      || code === codes.rightParenthesis
-      || (disallowEol && markdownLineEnding(code))
+      code === codes.eof ||
+      code === codes.lessThan ||
+      code === codes.equalsTo ||
+      code === codes.greaterThan ||
+      code === codes.graveAccent ||
+      code === codes.rightParenthesis ||
+      (disallowEol && markdownLineEnding(code))
     ) {
     ) {
       return nok(code);
       return nok(code);
     }
     }
@@ -184,18 +188,21 @@ export function factoryAttributes(
   /** @type {State} */
   /** @type {State} */
   function valueUnquoted(code) {
   function valueUnquoted(code) {
     if (
     if (
-      code === codes.eof
-      || code === codes.quotationMark
-      || code === codes.apostrophe
-      || code === codes.lessThan
-      || code === codes.equalsTo
-      || code === codes.greaterThan
-      || code === codes.graveAccent
+      code === codes.eof ||
+      code === codes.quotationMark ||
+      code === codes.apostrophe ||
+      code === codes.lessThan ||
+      code === codes.equalsTo ||
+      code === codes.greaterThan ||
+      code === codes.graveAccent
     ) {
     ) {
       return nok(code);
       return nok(code);
     }
     }
 
 
-    if (code === codes.rightParenthesis || markdownLineEndingOrSpaceOrComma(code)) {
+    if (
+      code === codes.rightParenthesis ||
+      markdownLineEndingOrSpaceOrComma(code)
+    ) {
       effects.exit(attributeValueData);
       effects.exit(attributeValueData);
       effects.exit(attributeValueType);
       effects.exit(attributeValueType);
       effects.exit(attributeType);
       effects.exit(attributeType);
@@ -257,7 +264,8 @@ export function factoryAttributes(
 
 
   /** @type {State} */
   /** @type {State} */
   function valueQuotedAfter(code) {
   function valueQuotedAfter(code) {
-    return code === codes.rightParenthesis || markdownLineEndingOrSpaceOrComma(code)
+    return code === codes.rightParenthesis ||
+      markdownLineEndingOrSpaceOrComma(code)
       ? between(code)
       ? between(code)
       : end(code);
       : end(code);
   }
   }

+ 13 - 13
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-label.js

@@ -5,7 +5,7 @@
  */
  */
 
 
 import { markdownLineEnding } from 'micromark-util-character';
 import { markdownLineEnding } from 'micromark-util-character';
-import { codes, constants, types } from 'micromark-util-symbol';
+import { constants, codes, types } from 'micromark-util-symbol';
 import { ok as assert } from 'uvu/assert';
 import { ok as assert } from 'uvu/assert';
 
 
 // This is a fork of:
 // This is a fork of:
@@ -24,13 +24,13 @@ import { ok as assert } from 'uvu/assert';
  */
  */
 // eslint-disable-next-line max-params
 // eslint-disable-next-line max-params
 export function factoryLabel(
 export function factoryLabel(
-    effects,
-    ok,
-    nok,
-    type,
-    markerType,
-    stringType,
-    disallowEol,
+  effects,
+  ok,
+  nok,
+  type,
+  markerType,
+  stringType,
+  disallowEol,
 ) {
 ) {
   let size = 0;
   let size = 0;
   let balance = 0;
   let balance = 0;
@@ -85,8 +85,8 @@ export function factoryLabel(
     }
     }
 
 
     if (
     if (
-      code === codes.leftSquareBracket
-      && ++balance > constants.linkResourceDestinationBalanceMax
+      code === codes.leftSquareBracket &&
+      ++balance > constants.linkResourceDestinationBalanceMax
     ) {
     ) {
       return nok(code);
       return nok(code);
     }
     }
@@ -113,9 +113,9 @@ export function factoryLabel(
   /** @type {State} */
   /** @type {State} */
   function dataEscape(code) {
   function dataEscape(code) {
     if (
     if (
-      code === codes.leftSquareBracket
-      || code === codes.backslash
-      || code === codes.rightSquareBracket
+      code === codes.leftSquareBracket ||
+      code === codes.backslash ||
+      code === codes.rightSquareBracket
     ) {
     ) {
       effects.consume(code);
       effects.consume(code);
       size++;
       size++;

+ 3 - 3
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/factory-name.js

@@ -34,9 +34,9 @@ export function factoryName(effects, ok, nok, type) {
   /** @type {State} */
   /** @type {State} */
   function name(code) {
   function name(code) {
     if (
     if (
-      code === codes.dash
-      || code === codes.underscore
-      || asciiAlphanumeric(code)
+      code === codes.dash ||
+      code === codes.underscore ||
+      asciiAlphanumeric(code)
     ) {
     ) {
       effects.consume(code);
       effects.consume(code);
       return name;
       return name;

+ 6 - 7
packages/remark-growi-directive/src/micromark-extension-growi-directive/lib/html.js

@@ -28,13 +28,12 @@ import { DirectiveType } from '../../mdast-util-growi-directive/lib/index.js';
 const own = {}.hasOwnProperty;
 const own = {}.hasOwnProperty;
 
 
 /**
 /**
-  * @param {HtmlOptions} [options]
-  * @returns {HtmlExtension}
-  */
+ * @param {HtmlOptions} [options]
+ * @returns {HtmlExtension}
+ */
 export function directiveHtml(options = {}) {
 export function directiveHtml(options = {}) {
   return {
   return {
     enter: {
     enter: {
-
       directiveGrowiLeaf() {
       directiveGrowiLeaf() {
         return enter.call(this, DirectiveType.Leaf);
         return enter.call(this, DirectiveType.Leaf);
       },
       },
@@ -65,9 +64,9 @@ export function directiveHtml(options = {}) {
   };
   };
 
 
   /**
   /**
-    * @this {CompileContext}
-    * @param {DirectiveType} type
-    */
+   * @this {CompileContext}
+   * @param {DirectiveType} type
+   */
   function enter(type) {
   function enter(type) {
     /** @type {Directive[]} */
     /** @type {Directive[]} */
     let stack = this.getData('directiveStack');
     let stack = this.getData('directiveStack');

+ 5 - 5
packages/remark-growi-directive/src/micromark-factory-attributes-devider/index.d.ts

@@ -4,9 +4,9 @@
  */
  */
 export function factoryAttributesDevider(
 export function factoryAttributesDevider(
   effects: Effects,
   effects: Effects,
-  ok: State
+  ok: State,
 ): (
 ): (
-  code: import('micromark-util-types').Code
-) => void | import('micromark-util-types').State
-export type Effects = import('micromark-util-types').Effects
-export type State = import('micromark-util-types').State
+  code: import('micromark-util-types').Code,
+) => void | import('micromark-util-types').State;
+export type Effects = import('micromark-util-types').Effects;
+export type State = import('micromark-util-types').State;

+ 4 - 1
packages/remark-growi-directive/src/micromark-factory-attributes-devider/index.js

@@ -7,7 +7,10 @@ import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
 import { codes } from 'micromark-util-symbol';
 import { codes } from 'micromark-util-symbol';
 
 
 export function markdownLineEndingOrSpaceOrComma(code) {
 export function markdownLineEndingOrSpaceOrComma(code) {
-  return code !== null && (code < codes.nul || code === codes.space || code === codes.comma);
+  return (
+    code !== null &&
+    (code < codes.nul || code === codes.space || code === codes.comma)
+  );
 }
 }
 
 
 /**
 /**

+ 22 - 19
packages/remark-growi-directive/src/remark-growi-directive.js

@@ -3,30 +3,33 @@
  * @typedef {import('unified').Processor<Root>} Processor
  * @typedef {import('unified').Processor<Root>} Processor
  */
  */
 
 
-import { directiveFromMarkdown, directiveToMarkdown } from './mdast-util-growi-directive/index.js';
+import {
+  directiveFromMarkdown,
+  directiveToMarkdown,
+} from './mdast-util-growi-directive/index.js';
 import { directive } from './micromark-extension-growi-directive/index.js';
 import { directive } from './micromark-extension-growi-directive/index.js';
 
 
 /**
 /**
-    * Plugin to support GROWI plugin (`$lsx(/path, depth=2)`).
-    *
-    * Add support for generic directives.
-    *
-    * ###### Notes
-    *
-    * Doesn’t handle the directives: create your own plugin to do that.
-    *
-    * @returns {undefined}
-    *   Nothing.
-    */
+ * Plugin to support GROWI plugin (`$lsx(/path, depth=2)`).
+ *
+ * Add support for generic directives.
+ *
+ * ###### Notes
+ *
+ * Doesn’t handle the directives: create your own plugin to do that.
+ *
+ * @returns {undefined}
+ *   Nothing.
+ */
 export function remarkGrowiDirectivePlugin() {
 export function remarkGrowiDirectivePlugin() {
-  // @ts-expect-error: TS is wrong about `this`.
-  // eslint-disable-next-line @typescript-eslint/no-this-alias
-  const self = /** @type {Processor} */ (this);
-  const data = self.data();
+  const data = this.data();
 
 
-  const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
-  const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
-  const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
+  const micromarkExtensions =
+    data.micromarkExtensions || (data.micromarkExtensions = []);
+  const fromMarkdownExtensions =
+    data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
+  const toMarkdownExtensions =
+    data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
 
 
   micromarkExtensions.push(directive());
   micromarkExtensions.push(directive());
   fromMarkdownExtensions.push(directiveFromMarkdown());
   fromMarkdownExtensions.push(directiveFromMarkdown());

+ 71 - 53
packages/remark-growi-directive/test/mdast-util-growi-directive.test.js

@@ -1,13 +1,15 @@
 import { fromMarkdown } from 'mdast-util-from-markdown';
 import { fromMarkdown } from 'mdast-util-from-markdown';
 import { toMarkdown } from 'mdast-util-to-markdown';
 import { toMarkdown } from 'mdast-util-to-markdown';
 import { removePosition } from 'unist-util-remove-position';
 import { removePosition } from 'unist-util-remove-position';
-import { describe, it, expect } from 'vitest';
+import { describe, expect, it } from 'vitest';
 
 
-import { directiveFromMarkdown, directiveToMarkdown } from '../src/mdast-util-growi-directive/index.js';
+import {
+  directiveFromMarkdown,
+  directiveToMarkdown,
+} from '../src/mdast-util-growi-directive/index.js';
 import { DirectiveType } from '../src/mdast-util-growi-directive/lib/index.js';
 import { DirectiveType } from '../src/mdast-util-growi-directive/lib/index.js';
 import { directive } from '../src/micromark-extension-growi-directive/index.js';
 import { directive } from '../src/micromark-extension-growi-directive/index.js';
 
 
-
 describe('markdown -> mdast', () => {
 describe('markdown -> mdast', () => {
   it('should support directives (text)', () => {
   it('should support directives (text)', () => {
     expect(
     expect(
@@ -88,7 +90,6 @@ describe('markdown -> mdast', () => {
     });
     });
   });
   });
 
 
-
   it('should support content in a label', () => {
   it('should support content in a label', () => {
     const tree = fromMarkdown('x $a[b *c*\nd]', {
     const tree = fromMarkdown('x $a[b *c*\nd]', {
       extensions: [directive()],
       extensions: [directive()],
@@ -97,32 +98,29 @@ describe('markdown -> mdast', () => {
 
 
     removePosition(tree, { force: true });
     removePosition(tree, { force: true });
 
 
-    expect(tree).toEqual(
-      {
-        type: 'root',
-        children: [
-          {
-            type: 'paragraph',
-            children: [
-              { type: 'text', value: 'x ' },
-              {
-                type: DirectiveType.Text,
-                name: 'a',
-                attributes: {},
-                children: [
-                  { type: 'text', value: 'b ' },
-                  { type: 'emphasis', children: [{ type: 'text', value: 'c' }] },
-                  { type: 'text', value: '\nd' },
-                ],
-              },
-            ],
-          },
-        ],
-      },
-    );
+    expect(tree).toEqual({
+      type: 'root',
+      children: [
+        {
+          type: 'paragraph',
+          children: [
+            { type: 'text', value: 'x ' },
+            {
+              type: DirectiveType.Text,
+              name: 'a',
+              attributes: {},
+              children: [
+                { type: 'text', value: 'b ' },
+                { type: 'emphasis', children: [{ type: 'text', value: 'c' }] },
+                { type: 'text', value: '\nd' },
+              ],
+            },
+          ],
+        },
+      ],
+    });
   });
   });
 
 
-
   it('should support attributes', () => {
   it('should support attributes', () => {
     const tree = fromMarkdown('x $a(#b.c.d e=f g="h&amp;i&unknown;j")', {
     const tree = fromMarkdown('x $a(#b.c.d e=f g="h&amp;i&unknown;j")', {
       extensions: [directive()],
       extensions: [directive()],
@@ -142,7 +140,9 @@ describe('markdown -> mdast', () => {
               type: DirectiveType.Text,
               type: DirectiveType.Text,
               name: 'a',
               name: 'a',
               attributes: {
               attributes: {
-                '#b.c.d': '', e: 'f', g: 'h&i&unknown;j',
+                '#b.c.d': '',
+                e: 'f',
+                g: 'h&i&unknown;j',
               },
               },
               children: [],
               children: [],
             },
             },
@@ -152,7 +152,6 @@ describe('markdown -> mdast', () => {
     });
     });
   });
   });
 
 
-
   it('should support EOLs in attributes', () => {
   it('should support EOLs in attributes', () => {
     const tree = fromMarkdown('$a(b\nc="d\ne")', {
     const tree = fromMarkdown('$a(b\nc="d\ne")', {
       extensions: [directive()],
       extensions: [directive()],
@@ -287,7 +286,12 @@ describe('mdast -> markdown', () => {
               name: 'b',
               name: 'b',
               // @ts-expect-error: should contain only `string`s
               // @ts-expect-error: should contain only `string`s
               attributes: {
               attributes: {
-                c: 'd', e: 'f', g: '', h: null, i: undefined, j: 2,
+                c: 'd',
+                e: 'f',
+                g: '',
+                h: null,
+                i: undefined,
+                j: 2,
               },
               },
               children: [],
               children: [],
             },
             },
@@ -383,7 +387,7 @@ describe('mdast -> markdown', () => {
     ).toBe('a $b(c.d e<f) g.\n');
     ).toBe('a $b(c.d e<f) g.\n');
   });
   });
 
 
-  it('should not use the `class` shortcut if impossible characters exist (but should use it for classes that don\'t)', () => {
+  it("should not use the `class` shortcut if impossible characters exist (but should use it for classes that don't)", () => {
     expect(
     expect(
       toMarkdown(
       toMarkdown(
         {
         {
@@ -394,7 +398,10 @@ describe('mdast -> markdown', () => {
               type: DirectiveType.Text,
               type: DirectiveType.Text,
               name: 'b',
               name: 'b',
               attributes: {
               attributes: {
-                'c.d': '', e: '', 'f<g': '', hij: '',
+                'c.d': '',
+                e: '',
+                'f<g': '',
+                hij: '',
               },
               },
               children: [],
               children: [],
             },
             },
@@ -480,19 +487,25 @@ describe('mdast -> markdown', () => {
 
 
   it('should not escape a `:` in phrasing when followed by a non-alpha', () => {
   it('should not escape a `:` in phrasing when followed by a non-alpha', () => {
     expect(
     expect(
-      toMarkdown({
-        type: 'paragraph',
-        children: [{ type: 'text', value: 'a$9' }],
-      }, { extensions: [directiveToMarkdown()] }),
+      toMarkdown(
+        {
+          type: 'paragraph',
+          children: [{ type: 'text', value: 'a$9' }],
+        },
+        { extensions: [directiveToMarkdown()] },
+      ),
     ).toBe('a$9\n');
     ).toBe('a$9\n');
   });
   });
 
 
   it('should not escape a `:` in phrasing when preceded by a colon', () => {
   it('should not escape a `:` in phrasing when preceded by a colon', () => {
     expect(
     expect(
-      toMarkdown({
-        type: 'paragraph',
-        children: [{ type: 'text', value: 'a$c' }],
-      }, { extensions: [directiveToMarkdown()] }),
+      toMarkdown(
+        {
+          type: 'paragraph',
+          children: [{ type: 'text', value: 'a$c' }],
+        },
+        { extensions: [directiveToMarkdown()] },
+      ),
     ).toBe('a\\$c\n');
     ).toBe('a\\$c\n');
   });
   });
 
 
@@ -522,23 +535,28 @@ describe('mdast -> markdown', () => {
 
 
   it('should escape a `:` at a break when followed by a colon', () => {
   it('should escape a `:` at a break when followed by a colon', () => {
     expect(
     expect(
-      toMarkdown({
-        type: 'paragraph',
-        children: [{ type: 'text', value: '$\na' }],
-      }, { extensions: [directiveToMarkdown()] }),
+      toMarkdown(
+        {
+          type: 'paragraph',
+          children: [{ type: 'text', value: '$\na' }],
+        },
+        { extensions: [directiveToMarkdown()] },
+      ),
     ).toBe('$\na\n');
     ).toBe('$\na\n');
   });
   });
 
 
   it('should escape a `:` after a text directive', () => {
   it('should escape a `:` after a text directive', () => {
     expect(
     expect(
-      toMarkdown({
-        type: 'paragraph',
-        children: [
-          { type: DirectiveType.Text, name: 'red', children: [] },
-          { type: 'text', value: '$' },
-        ],
-      }, { extensions: [directiveToMarkdown()] }),
+      toMarkdown(
+        {
+          type: 'paragraph',
+          children: [
+            { type: DirectiveType.Text, name: 'red', children: [] },
+            { type: 'text', value: '$' },
+          ],
+        },
+        { extensions: [directiveToMarkdown()] },
+      ),
     ).toBe('$red$\n');
     ).toBe('$red$\n');
   });
   });
-
 });
 });

+ 165 - 151
packages/remark-growi-directive/test/micromark-extension-growi-directive.test.js

@@ -5,15 +5,16 @@
 
 
 import { htmlVoidElements } from 'html-void-elements';
 import { htmlVoidElements } from 'html-void-elements';
 import { micromark } from 'micromark';
 import { micromark } from 'micromark';
-import { describe, it, expect } from 'vitest';
+import { describe, expect, it } from 'vitest';
 
 
 import { DirectiveType } from '../src/mdast-util-growi-directive/lib/index.js';
 import { DirectiveType } from '../src/mdast-util-growi-directive/lib/index.js';
-import { directive as syntax, directiveHtml as html } from '../src/micromark-extension-growi-directive/index.js';
-
+import {
+  directiveHtml as html,
+  directive as syntax,
+} from '../src/micromark-extension-growi-directive/index.js';
 
 
 const own = {}.hasOwnProperty;
 const own = {}.hasOwnProperty;
 
 
-
 describe('micromark-extension-directive (syntax)', () => {
 describe('micromark-extension-directive (syntax)', () => {
   describe('text', () => {
   describe('text', () => {
     it('should support an escaped colon which would otherwise be a directive', () => {
     it('should support an escaped colon which would otherwise be a directive', () => {
@@ -73,7 +74,9 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should not interfere w/ emphasis (`_`)', () => {
     it('should not interfere w/ emphasis (`_`)', () => {
-      expect(micromark('_$directive_', options())).toBe('<p><em>$directive</em></p>');
+      expect(micromark('_$directive_', options())).toBe(
+        '<p><em>$directive</em></p>',
+      );
     });
     });
 
 
     it('should support a name followed by an unclosed `[`', () => {
     it('should support a name followed by an unclosed `[`', () => {
@@ -120,27 +123,19 @@ describe('micromark-extension-directive (syntax)', () => {
     // );
     // );
 
 
     it('should support a directive in an label', () => {
     it('should support a directive in an label', () => {
-      expect(
-        micromark('a $b[c :d[e] f] g', options()),
-      ).toBe('<p>a  g</p>');
+      expect(micromark('a $b[c :d[e] f] g', options())).toBe('<p>a  g</p>');
     });
     });
 
 
     it('should support content after a label', () => {
     it('should support content after a label', () => {
-      expect(
-        micromark('$a[]asd', options()),
-      ).toBe('<p>asd</p>');
+      expect(micromark('$a[]asd', options())).toBe('<p>asd</p>');
     });
     });
 
 
     it('should support empty attributes', () => {
     it('should support empty attributes', () => {
-      expect(
-        micromark('a $a()', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a()', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support whitespace only attributes', () => {
     it('should support whitespace only attributes', () => {
-      expect(
-        micromark('a $a( \t)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a( \t)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support an eol in attributes', () => {
     it('should support an eol in attributes', () => {
@@ -172,7 +167,9 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support attributes w/ shortcuts combined w/ other attributes', () => {
     it('should support attributes w/ shortcuts combined w/ other attributes', () => {
-      expect(micromark('a $a(#a.b.c#d e f=g #h.i.j)', options())).toBe('<p>a </p>');
+      expect(micromark('a $a(#a.b.c#d e f=g #h.i.j)', options())).toBe(
+        '<p>a </p>',
+      );
     });
     });
 
 
     it('should support attrs which starts w/ continuous dots', () => {
     it('should support attrs which starts w/ continuous dots', () => {
@@ -192,51 +189,37 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support with the attr `(.a"b)`', () => {
     it('should support with the attr `(.a"b)`', () => {
-      expect(
-        micromark('a $a(.a"b)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(.a"b)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support with the attr `(.a<b)`', () => {
     it('should support with the attr `(.a<b)`', () => {
-      expect(
-        micromark('a $a(.a<b)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(.a<b)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support most characters in shortcuts', () => {
     it('should support most characters in shortcuts', () => {
-      expect(
-        micromark('a $a(.a💚b)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(.a💚b)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support an underscore in attribute names', () => {
     it('should support an underscore in attribute names', () => {
-      expect(
-        micromark('a $a(_)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(_)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support a colon in attribute names', () => {
     it('should support a colon in attribute names', () => {
-      expect(
-        micromark('a $a(xml:lang)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(xml:lang)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support double quoted attributes', () => {
     it('should support double quoted attributes', () => {
-      expect(
-        micromark('a $a(a="b" c="d e f")', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(a="b" c="d e f")', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support single quoted attributes', () => {
     it('should support single quoted attributes', () => {
-      expect(
-        micromark("a $a(a='b' c='d e f')", options()),
-      ).toBe('<p>a </p>');
+      expect(micromark("a $a(a='b' c='d e f')", options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support whitespace around initializers', () => {
     it('should support whitespace around initializers', () => {
-      expect(
-        micromark('a $a(a = b c\t=\t\'d\' f  =\r"g")', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(a = b c\t=\t\'d\' f  =\r"g")', options())).toBe(
+        '<p>a </p>',
+      );
     });
     });
 
 
     it('should not support `=` to start an unquoted attribute value', () => {
     it('should not support `=` to start an unquoted attribute value', () => {
@@ -256,49 +239,31 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support most other characters in attribute keys', () => {
     it('should support most other characters in attribute keys', () => {
-      expect(
-        micromark('a $a(b💚=a💚b)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(b💚=a💚b)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support most other characters in unquoted attribute values', () => {
     it('should support most other characters in unquoted attribute values', () => {
-      expect(
-        micromark('a $a(b=a💚b)', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(b=a💚b)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should not support an EOF in a quoted attribute value', () => {
     it('should not support an EOF in a quoted attribute value', () => {
-      expect(
-        micromark('$a(b="c', options()),
-      ).toBe('<p>(b=&quot;c</p>');
+      expect(micromark('$a(b="c', options())).toBe('<p>(b=&quot;c</p>');
     });
     });
 
 
     it('should support most other characters in quoted attribute values', () => {
     it('should support most other characters in quoted attribute values', () => {
-      expect(
-        micromark('a $a(b="a💚b")', options()),
-      ).toBe('<p>a </p>');
+      expect(micromark('a $a(b="a💚b")', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support EOLs in quoted attribute values', () => {
     it('should support EOLs in quoted attribute values', () => {
-      expect(
-        micromark('$a(b="\nc\r  d")', options()),
-      ).toBe(
-        '<p></p>',
-      );
+      expect(micromark('$a(b="\nc\r  d")', options())).toBe('<p></p>');
     });
     });
 
 
     it('should not support an EOF after a quoted attribute value', () => {
     it('should not support an EOF after a quoted attribute value', () => {
-      expect(
-        micromark('$a(b="c"', options()),
-      ).toBe(
-        '<p>(b=&quot;c&quot;</p>',
-      );
+      expect(micromark('$a(b="c"', options())).toBe('<p>(b=&quot;c&quot;</p>');
     });
     });
-
   });
   });
 
 
   describe('leaf', () => {
   describe('leaf', () => {
-
     it('should support a directive', () => {
     it('should support a directive', () => {
       expect(micromark('$b', options())).toBe('');
       expect(micromark('$b', options())).toBe('');
     });
     });
@@ -461,15 +426,21 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support a block quote after a leaf', () => {
     it('should support a block quote after a leaf', () => {
-      expect(micromark('$a(b=c)\n>a', options())).toBe('<blockquote>\n<p>a</p>\n</blockquote>');
+      expect(micromark('$a(b=c)\n>a', options())).toBe(
+        '<blockquote>\n<p>a</p>\n</blockquote>',
+      );
     });
     });
 
 
     it('should support code (fenced) after a leaf', () => {
     it('should support code (fenced) after a leaf', () => {
-      expect(micromark('$a(b=c)\n```js\na', options())).toBe('<pre><code class="language-js">a\n</code></pre>\n');
+      expect(micromark('$a(b=c)\n```js\na', options())).toBe(
+        '<pre><code class="language-js">a\n</code></pre>\n',
+      );
     });
     });
 
 
     it('should support code (indented) after a leaf', () => {
     it('should support code (indented) after a leaf', () => {
-      expect(micromark('$a(b=c)\n    a', options())).toBe('<pre><code>a\n</code></pre>');
+      expect(micromark('$a(b=c)\n    a', options())).toBe(
+        '<pre><code>a\n</code></pre>',
+      );
     });
     });
 
 
     it('should support a definition after a leaf', () => {
     it('should support a definition after a leaf', () => {
@@ -489,7 +460,9 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support a list after a leaf', () => {
     it('should support a list after a leaf', () => {
-      expect(micromark('$a(b=c)\n* a', options())).toBe('<ul>\n<li>a</li>\n</ul>');
+      expect(micromark('$a(b=c)\n* a', options())).toBe(
+        '<ul>\n<li>a</li>\n</ul>',
+      );
     });
     });
 
 
     it('should support a paragraph after a leaf', () => {
     it('should support a paragraph after a leaf', () => {
@@ -501,15 +474,21 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support a block quote before a leaf', () => {
     it('should support a block quote before a leaf', () => {
-      expect(micromark('>a\n$a(b=c)', options())).toBe('<blockquote>\n<p>a</p>\n</blockquote>\n');
+      expect(micromark('>a\n$a(b=c)', options())).toBe(
+        '<blockquote>\n<p>a</p>\n</blockquote>\n',
+      );
     });
     });
 
 
     it('should support code (fenced) before a leaf', () => {
     it('should support code (fenced) before a leaf', () => {
-      expect(micromark('```js\na\n```\n$a(b=c)', options())).toBe('<pre><code class="language-js">a\n</code></pre>\n');
+      expect(micromark('```js\na\n```\n$a(b=c)', options())).toBe(
+        '<pre><code class="language-js">a\n</code></pre>\n',
+      );
     });
     });
 
 
     it('should support code (indented) before a leaf', () => {
     it('should support code (indented) before a leaf', () => {
-      expect(micromark('    a\n$a(b=c)', options())).toBe('<pre><code>a\n</code></pre>\n');
+      expect(micromark('    a\n$a(b=c)', options())).toBe(
+        '<pre><code>a\n</code></pre>\n',
+      );
     });
     });
 
 
     it('should support a definition before a leaf', () => {
     it('should support a definition before a leaf', () => {
@@ -529,7 +508,9 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should support a list before a leaf', () => {
     it('should support a list before a leaf', () => {
-      expect(micromark('* a\n$a(b=c)', options())).toBe('<ul>\n<li>a</li>\n</ul>\n');
+      expect(micromark('* a\n$a(b=c)', options())).toBe(
+        '<ul>\n<li>a</li>\n</ul>\n',
+      );
     });
     });
 
 
     it('should support a paragraph before a leaf', () => {
     it('should support a paragraph before a leaf', () => {
@@ -541,19 +522,20 @@ describe('micromark-extension-directive (syntax)', () => {
     });
     });
 
 
     it('should not support lazyness (1)', () => {
     it('should not support lazyness (1)', () => {
-      expect(micromark('> $a\nb', options({ '*': h }))).toBe('<blockquote><a></a>\n</blockquote>\n<p>b</p>');
+      expect(micromark('> $a\nb', options({ '*': h }))).toBe(
+        '<blockquote><a></a>\n</blockquote>\n<p>b</p>',
+      );
     });
     });
 
 
     it('should not support lazyness (2)', () => {
     it('should not support lazyness (2)', () => {
-      expect(micromark('> a\n$b', options({ '*': h }))).toBe('<blockquote>\n<p>a</p>\n</blockquote>\n<b></b>');
+      expect(micromark('> a\n$b', options({ '*': h }))).toBe(
+        '<blockquote>\n<p>a</p>\n</blockquote>\n<b></b>',
+      );
     });
     });
-
   });
   });
-
 });
 });
 
 
 describe('micromark-extension-directive (compile)', () => {
 describe('micromark-extension-directive (compile)', () => {
-
   it('should support a directives (abbr)', () => {
   it('should support a directives (abbr)', () => {
     expect(
     expect(
       micromark(
       micromark(
@@ -653,7 +635,10 @@ describe('micromark-extension-directive (compile)', () => {
 
 
   it('should support fall through directives (`*`)', () => {
   it('should support fall through directives (`*`)', () => {
     expect(
     expect(
-      micromark('a $youtube[Cat in a box]\n$br a', options({ youtube, '*': h })),
+      micromark(
+        'a $youtube[Cat in a box]\n$br a',
+        options({ youtube, '*': h }),
+      ),
     ).toBe('<p>a <youtube>Cat in a box</youtube>\n<br> a</p>');
     ).toBe('<p>a <youtube>Cat in a box</youtube>\n<br> a</p>');
   });
   });
 
 
@@ -662,55 +647,65 @@ describe('micromark-extension-directive (compile)', () => {
       micromark('a $a[$img(src="x" alt=y)](href="z")', options({ '*': h })),
       micromark('a $a[$img(src="x" alt=y)](href="z")', options({ '*': h })),
     ).toBe('<p>a <a href="z"><img src="x" alt="y"></a></p>');
     ).toBe('<p>a <a href="z"><img src="x" alt="y"></a></p>');
   });
   });
-
 });
 });
 
 
 describe('content', () => {
 describe('content', () => {
-
   it('should support character escapes and character references in label', () => {
   it('should support character escapes and character references in label', () => {
-    expect(micromark('a $abbr[x\\&y&amp;z]', options({ abbr })))
-      .toBe('<p>a <abbr>x&amp;y&amp;z</abbr></p>');
+    expect(micromark('a $abbr[x\\&y&amp;z]', options({ abbr }))).toBe(
+      '<p>a <abbr>x&amp;y&amp;z</abbr></p>',
+    );
   });
   });
 
 
   it('should support escaped brackets in a label', () => {
   it('should support escaped brackets in a label', () => {
-    expect(micromark('a $abbr[x\\[y\\]z]', options({ abbr })))
-      .toBe('<p>a <abbr>x[y]z</abbr></p>');
+    expect(micromark('a $abbr[x\\[y\\]z]', options({ abbr }))).toBe(
+      '<p>a <abbr>x[y]z</abbr></p>',
+    );
   });
   });
 
 
   it('should support balanced brackets in a label', () => {
   it('should support balanced brackets in a label', () => {
-    expect(micromark('a $abbr[x[y]z]', options({ abbr })))
-      .toBe('<p>a <abbr>x[y]z</abbr></p>');
+    expect(micromark('a $abbr[x[y]z]', options({ abbr }))).toBe(
+      '<p>a <abbr>x[y]z</abbr></p>',
+    );
   });
   });
 
 
   it('should support balanced brackets in a label, 32 levels deep', () => {
   it('should support balanced brackets in a label, 32 levels deep', () => {
-    expect(micromark(
-      'a $abbr[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
-      options({ abbr }),
-    )).toBe('<p>a <abbr>1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]</abbr></p>');
+    expect(
+      micromark(
+        'a $abbr[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
+        options({ abbr }),
+      ),
+    ).toBe(
+      '<p>a <abbr>1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]</abbr></p>',
+    );
   });
   });
 
 
   it('should *not* support balanced brackets in a label, 33 levels deep', () => {
   it('should *not* support balanced brackets in a label, 33 levels deep', () => {
-    expect(micromark(
-      '$abbr[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[33[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
-      options({ abbr }),
-    )).toBe(
+    expect(
+      micromark(
+        '$abbr[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[33[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]',
+        options({ abbr }),
+      ),
+    ).toBe(
       '<p><abbr></abbr>[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[33[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]</p>',
       '<p><abbr></abbr>[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[33[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]</p>',
     );
     );
   });
   });
 
 
   it('should support EOLs in a label', () => {
   it('should support EOLs in a label', () => {
-    expect(micromark('$abbr[a\nb\rc]', options({ abbr })))
-      .toBe('<p><abbr>a\nb\rc</abbr></p>');
+    expect(micromark('$abbr[a\nb\rc]', options({ abbr }))).toBe(
+      '<p><abbr>a\nb\rc</abbr></p>',
+    );
   });
   });
 
 
   it('should support EOLs at the edges of a label (1)', () => {
   it('should support EOLs at the edges of a label (1)', () => {
-    expect(micromark('$abbr[\na\r]', options({ abbr })))
-      .toBe('<p><abbr>\na\r</abbr></p>');
+    expect(micromark('$abbr[\na\r]', options({ abbr }))).toBe(
+      '<p><abbr>\na\r</abbr></p>',
+    );
   });
   });
 
 
   it('should support EOLs at the edges of a label (2)', () => {
   it('should support EOLs at the edges of a label (2)', () => {
-    expect(micromark('$abbr[\n]', options({ abbr })))
-      .toBe('<p><abbr>\n</abbr></p>');
+    expect(micromark('$abbr[\n]', options({ abbr }))).toBe(
+      '<p><abbr>\n</abbr></p>',
+    );
   });
   });
 
 
   // == does not work but I don't know why.. -- 2022.08.12 Yuki Takei
   // == does not work but I don't know why.. -- 2022.08.12 Yuki Takei
@@ -720,122 +715,142 @@ describe('content', () => {
   // });
   // });
 
 
   it('should support EOLs inside nested directives (1)', () => {
   it('should support EOLs inside nested directives (1)', () => {
-    expect(micromark('$abbr[$abbr[\n]]', options({ abbr })))
-      .toBe('<p><abbr><abbr>\n</abbr></abbr></p>');
+    expect(micromark('$abbr[$abbr[\n]]', options({ abbr }))).toBe(
+      '<p><abbr><abbr>\n</abbr></abbr></p>',
+    );
   });
   });
 
 
   it('should support EOLs inside nested directives (2)', () => {
   it('should support EOLs inside nested directives (2)', () => {
-    expect(micromark('$abbr[$abbr[a\nb]]', options({ abbr })))
-      .toBe('<p><abbr><abbr>a\nb</abbr></abbr></p>');
+    expect(micromark('$abbr[$abbr[a\nb]]', options({ abbr }))).toBe(
+      '<p><abbr><abbr>a\nb</abbr></abbr></p>',
+    );
   });
   });
 
 
   it('should support EOLs inside nested directives (3)', () => {
   it('should support EOLs inside nested directives (3)', () => {
-    expect(micromark('$abbr[$abbr[\nb\n]]', options({ abbr })))
-      .toBe('<p><abbr><abbr>\nb\n</abbr></abbr></p>');
+    expect(micromark('$abbr[$abbr[\nb\n]]', options({ abbr }))).toBe(
+      '<p><abbr><abbr>\nb\n</abbr></abbr></p>',
+    );
   });
   });
 
 
   it('should support EOLs inside nested directives (4)', () => {
   it('should support EOLs inside nested directives (4)', () => {
-    expect(micromark('$abbr[$abbr[\\\n]]', options({ abbr })))
-      .toBe('<p><abbr><abbr><br />\n</abbr></abbr></p>');
+    expect(micromark('$abbr[$abbr[\\\n]]', options({ abbr }))).toBe(
+      '<p><abbr><abbr><br />\n</abbr></abbr></p>',
+    );
   });
   });
 
 
   it('should support markdown in a label', () => {
   it('should support markdown in a label', () => {
-    expect(micromark('a $abbr[a *b* **c** d]', options({ abbr })))
-      .toBe('<p>a <abbr>a <em>b</em> <strong>c</strong> d</abbr></p>');
+    expect(micromark('a $abbr[a *b* **c** d]', options({ abbr }))).toBe(
+      '<p>a <abbr>a <em>b</em> <strong>c</strong> d</abbr></p>',
+    );
   });
   });
 
 
   it('should support character references in unquoted attribute values', () => {
   it('should support character references in unquoted attribute values', () => {
-    expect(micromark('a $abbr(title=a&apos;b)', options({ abbr })))
-      .toBe('<p>a <abbr title="a\'b"></abbr></p>');
+    expect(micromark('a $abbr(title=a&apos;b)', options({ abbr }))).toBe(
+      '<p>a <abbr title="a\'b"></abbr></p>',
+    );
   });
   });
 
 
   it('should support character references in double attribute values', () => {
   it('should support character references in double attribute values', () => {
-    expect(micromark('a $abbr(title="a&apos;b")', options({ abbr })))
-      .toBe('<p>a <abbr title="a\'b"></abbr></p>');
+    expect(micromark('a $abbr(title="a&apos;b")', options({ abbr }))).toBe(
+      '<p>a <abbr title="a\'b"></abbr></p>',
+    );
   });
   });
 
 
   it('should support character references in single attribute values', () => {
   it('should support character references in single attribute values', () => {
-    expect(micromark("a $abbr(title='a&apos;b')", options({ abbr })))
-      .toBe('<p>a <abbr title="a\'b"></abbr></p>');
+    expect(micromark("a $abbr(title='a&apos;b')", options({ abbr }))).toBe(
+      '<p>a <abbr title="a\'b"></abbr></p>',
+    );
   });
   });
 
 
   it('should support unknown character references in attribute values', () => {
   it('should support unknown character references in attribute values', () => {
-    expect(micromark('a $abbr(title="a&somethingelse;b")', options({ abbr })))
-      .toBe('<p>a <abbr title="a&amp;somethingelse;b"></abbr></p>');
+    expect(
+      micromark('a $abbr(title="a&somethingelse;b")', options({ abbr })),
+    ).toBe('<p>a <abbr title="a&amp;somethingelse;b"></abbr></p>');
   });
   });
 
 
   it('should support EOLs between attributes', () => {
   it('should support EOLs between attributes', () => {
-    expect(micromark('$span(a\nb)', options({ '*': h })))
-      .toBe('<p><span a="" b=""></span></p>');
+    expect(micromark('$span(a\nb)', options({ '*': h }))).toBe(
+      '<p><span a="" b=""></span></p>',
+    );
   });
   });
 
 
   it('should support EOLs at the edges of attributes', () => {
   it('should support EOLs at the edges of attributes', () => {
-    expect(micromark('$span(\na\n)', options({ '*': h })))
-      .toBe('<p><span a=""></span></p>');
+    expect(micromark('$span(\na\n)', options({ '*': h }))).toBe(
+      '<p><span a=""></span></p>',
+    );
   });
   });
 
 
   it('should support EOLs before initializer', () => {
   it('should support EOLs before initializer', () => {
-    expect(micromark('$span(a\r= b)', options({ '*': h })))
-      .toBe('<p><span a="b"></span></p>');
+    expect(micromark('$span(a\r= b)', options({ '*': h }))).toBe(
+      '<p><span a="b"></span></p>',
+    );
   });
   });
 
 
   it('should support EOLs after initializer', () => {
   it('should support EOLs after initializer', () => {
-    expect(micromark('$span(a=\r\nb)', options({ '*': h })))
-      .toBe('<p><span a="b"></span></p>');
+    expect(micromark('$span(a=\r\nb)', options({ '*': h }))).toBe(
+      '<p><span a="b"></span></p>',
+    );
   });
   });
 
 
   it('should support EOLs between an unquoted attribute value and a next attribute name', () => {
   it('should support EOLs between an unquoted attribute value and a next attribute name', () => {
-    expect(micromark('$span(a=b\nc)', options({ '*': h })))
-      .toBe('<p><span a="b" c=""></span></p>');
+    expect(micromark('$span(a=b\nc)', options({ '*': h }))).toBe(
+      '<p><span a="b" c=""></span></p>',
+    );
   });
   });
 
 
   it('should support EOLs in a double quoted attribute value', () => {
   it('should support EOLs in a double quoted attribute value', () => {
-    expect(micromark('$span(a="b\nc")', options({ '*': h })))
-      .toBe('<p><span a="b\nc"></span></p>');
+    expect(micromark('$span(a="b\nc")', options({ '*': h }))).toBe(
+      '<p><span a="b\nc"></span></p>',
+    );
   });
   });
 
 
   it('should support EOLs in a single quoted attribute value', () => {
   it('should support EOLs in a single quoted attribute value', () => {
-    expect(micromark("$span(a='b\nc')", options({ '*': h })))
-      .toBe('<p><span a="b\nc"></span></p>');
+    expect(micromark("$span(a='b\nc')", options({ '*': h }))).toBe(
+      '<p><span a="b\nc"></span></p>',
+    );
   });
   });
 
 
   it('should support attrs which contains `#` (1)', () => {
   it('should support attrs which contains `#` (1)', () => {
-    expect(micromark('a $span(#a#b)', options({ '*': h })))
-      .toBe('<p>a <span #a#b=""></span></p>');
+    expect(micromark('a $span(#a#b)', options({ '*': h }))).toBe(
+      '<p>a <span #a#b=""></span></p>',
+    );
   });
   });
 
 
   it('should support attrs which contains `#` (2)', () => {
   it('should support attrs which contains `#` (2)', () => {
-    expect(micromark('a $span(id=a id="b" #c#d)', options({ '*': h })))
-      .toBe('<p>a <span id="b" #c#d=""></span></p>');
+    expect(micromark('a $span(id=a id="b" #c#d)', options({ '*': h }))).toBe(
+      '<p>a <span id="b" #c#d=""></span></p>',
+    );
   });
   });
 
 
   it('should support attrs with dot notation', () => {
   it('should support attrs with dot notation', () => {
-    expect(micromark('a $span(.a.b)', options({ '*': h })))
-      .toBe('<p>a <span .a.b=""></span></p>');
+    expect(micromark('a $span(.a.b)', options({ '*': h }))).toBe(
+      '<p>a <span .a.b=""></span></p>',
+    );
   });
   });
 
 
   describe('spec for growi plugin', () => {
   describe('spec for growi plugin', () => {
     it('should support name with slash', () => {
     it('should support name with slash', () => {
-      expect(micromark('a $lsx(/Sandbox)', options()))
-        .toBe('<p>a </p>');
+      expect(micromark('a $lsx(/Sandbox)', options())).toBe('<p>a </p>');
     });
     });
 
 
     it('should support name=value and an attribute w/o value', () => {
     it('should support name=value and an attribute w/o value', () => {
-      expect(micromark('a $lsx(key=value, reverse)', options()))
-        .toBe('<p>a </p>');
+      expect(micromark('a $lsx(key=value, reverse)', options())).toBe(
+        '<p>a </p>',
+      );
     });
     });
 
 
     it('should support consecutive attributes w/o value', () => {
     it('should support consecutive attributes w/o value', () => {
-      expect(micromark('a $lsx(key=value, reverse, reverse2)', options()))
-        .toBe('<p>a </p>');
+      expect(micromark('a $lsx(key=value, reverse, reverse2)', options())).toBe(
+        '<p>a </p>',
+      );
     });
     });
 
 
     it('should support name=value after an empty value attribute', () => {
     it('should support name=value after an empty value attribute', () => {
-      expect(micromark('a $lsx(/Sandbox, key=value, reverse)', options()))
-        .toBe('<p>a </p>');
+      expect(micromark('a $lsx(/Sandbox, key=value, reverse)', options())).toBe(
+        '<p>a </p>',
+      );
     });
     });
   });
   });
-
 });
 });
 
 
 /** @type {Handle} */
 /** @type {Handle} */
@@ -899,8 +914,7 @@ function lsx(d) {
   for (const key in attrs) {
   for (const key in attrs) {
     if (attrs[key].length === 0) {
     if (attrs[key].length === 0) {
       props.push(`prefix="${key}"`);
       props.push(`prefix="${key}"`);
-    }
-    else {
+    } else {
       props.push(`${key}="${attrs[key]}"`);
       props.push(`${key}="${attrs[key]}"`);
     }
     }
   }
   }

+ 4 - 7
packages/remark-growi-directive/test/remark-growi-directive.test.js

@@ -5,12 +5,11 @@
 import fs from 'node:fs';
 import fs from 'node:fs';
 import path from 'node:path';
 import path from 'node:path';
 
 
-
 import { isHidden } from 'is-hidden';
 import { isHidden } from 'is-hidden';
 import { remark } from 'remark';
 import { remark } from 'remark';
 import { readSync } from 'to-vfile';
 import { readSync } from 'to-vfile';
 import { unified } from 'unified';
 import { unified } from 'unified';
-import { describe, it, expect } from 'vitest';
+import { describe, expect, it } from 'vitest';
 
 
 import { remarkGrowiDirectivePlugin } from '../src/remark-growi-directive.js';
 import { remarkGrowiDirectivePlugin } from '../src/remark-growi-directive.js';
 
 
@@ -30,7 +29,7 @@ describe('directive()', () => {
 
 
 describe('fixtures', () => {
 describe('fixtures', () => {
   const base = path.join('test', 'fixtures');
   const base = path.join('test', 'fixtures');
-  const entries = fs.readdirSync(base).filter(d => !isHidden(d));
+  const entries = fs.readdirSync(base).filter((d) => !isHidden(d));
 
 
   entries.forEach((fixture) => {
   entries.forEach((fixture) => {
     it(`should handle ${fixture}`, () => {
     it(`should handle ${fixture}`, () => {
@@ -47,8 +46,7 @@ describe('fixtures', () => {
 
 
       try {
       try {
         expected = JSON.parse(String(fs.readFileSync(treePath)));
         expected = JSON.parse(String(fs.readFileSync(treePath)));
-      }
-      catch {
+      } catch {
         // New fixture.
         // New fixture.
         fs.writeFileSync(treePath, `${JSON.stringify(actual, null, 2)}\n`);
         fs.writeFileSync(treePath, `${JSON.stringify(actual, null, 2)}\n`);
         expected = actual;
         expected = actual;
@@ -56,8 +54,7 @@ describe('fixtures', () => {
 
 
       try {
       try {
         output = fs.readFileSync(outputPath, 'utf8');
         output = fs.readFileSync(outputPath, 'utf8');
-      }
-      catch {
+      } catch {
         output = input;
         output = input;
       }
       }
 
 

+ 3 - 9
packages/remark-growi-directive/tsconfig.json

@@ -2,14 +2,8 @@
   "$schema": "http://json.schemastore.org/tsconfig",
   "$schema": "http://json.schemastore.org/tsconfig",
   "extends": "../../tsconfig.base.json",
   "extends": "../../tsconfig.base.json",
   "compilerOptions": {
   "compilerOptions": {
-    "types": [
-      "vitest/globals"
-    ],
+    "types": ["vitest/globals"]
   },
   },
-  "include": [
-    "src"
-  ],
-  "exclude": [
-    "test"
-  ]
+  "include": ["src"],
+  "exclude": ["test"]
 }
 }

+ 1 - 3
packages/remark-growi-directive/vitest.config.ts

@@ -2,9 +2,7 @@ import tsconfigPaths from 'vite-tsconfig-paths';
 import { defineConfig } from 'vitest/config';
 import { defineConfig } from 'vitest/config';
 
 
 export default defineConfig({
 export default defineConfig({
-  plugins: [
-    tsconfigPaths(),
-  ],
+  plugins: [tsconfigPaths()],
   test: {
   test: {
     environment: 'node',
     environment: 'node',
     clearMocks: true,
     clearMocks: true,