@es-joy/jsdoccomment
Advanced tools
| name: Node.js CI | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| branches: | ||
| - master | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: | ||
| - 12.x | ||
| - 14.x | ||
| - 16.x | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm ci | ||
| - run: npm run build --if-present | ||
| - run: npm test |
+17
-0
| # CHANGES for `@es-joy/jsdoccomment` | ||
| ## 0.4.2 | ||
| - Fix: Ensure replacement of camel-casing (used in `jsdoctypeparser` nodes and | ||
| visitor keys is global. The practical effect is that | ||
| `JSDocTypeNamed_parameter` -> `JSDocTypeNamedParameter`, | ||
| `JSDocTypeRecord_entry` -> `JSDocTypeRecordEntry` | ||
| `JSDocTypeNot_nullable` -> `JSDocTypeNotNullable` | ||
| `JSDocTypeInner_member` -> `JSDocTypeInnerMember` | ||
| `JSDocTypeInstance_member` -> `JSDocTypeInstanceMember` | ||
| `JSDocTypeString_value` -> `JSDocTypeStringValue` | ||
| `JSDocTypeNumber_value` -> `JSDocTypeNumberValue` | ||
| `JSDocTypeFile_path` -> `JSDocTypeFilePath` | ||
| `JSDocTypeType_query` -> `JSDocTypeTypeQuery` | ||
| `JSDocTypeKey_query` -> `JSDocTypeKeyQuery` | ||
| - Fix: Add missing `JSDocTypeLine` to visitor keys | ||
| - Docs: Explain AST structure/differences | ||
| ## 0.4.1 | ||
@@ -4,0 +21,0 @@ |
@@ -23,3 +23,3 @@ 'use strict'; | ||
| const toCamelCase = str => { | ||
| return str.toLowerCase().replace(/^[a-z]/u, init => { | ||
| return str.toLowerCase().replace(/^[a-z]/gu, init => { | ||
| return init.toUpperCase(); | ||
@@ -204,2 +204,3 @@ }).replace(/_(?:<wordInit>[a-z])/u, (_, n1, o, s, { | ||
| JSDocDescriptionLine: [], | ||
| JSDocTypeLine: [], | ||
| JSDocTag: ['descriptionLines', 'typeLines', 'parsedType'] | ||
@@ -206,0 +207,0 @@ }; |
+8
-1
| { | ||
| "name": "@es-joy/jsdoccomment", | ||
| "version": "0.4.1", | ||
| "version": "0.4.2", | ||
| "author": "Brett Zamir <brettz9@yahoo.com>", | ||
@@ -18,2 +18,9 @@ "contributors": [], | ||
| }, | ||
| "c8": { | ||
| "checkCoverage": true, | ||
| "branches": 100, | ||
| "statements": 100, | ||
| "lines": 100, | ||
| "functions": 100 | ||
| }, | ||
| "browserslist": [ | ||
@@ -20,0 +27,0 @@ "cover 100%" |
+90
-0
| # @es-joy/jsdoccomment | ||
| [](https://github.com/brettz9/getJSDocComment/actions) | ||
| This project aims to preserve and expand upon the | ||
@@ -21,2 +23,90 @@ `SourceCode#getJSDocComment` functionality of the deprecated ESLint method. | ||
| ## ESLint AST produced for `comment-parser` nodes (`JSDocBlock`, `JSDocTag`, and `JSDocDescriptionLine`) | ||
| ### `JSDocBlock` | ||
| Has two visitable properties: | ||
| 1. `tags` (an array of `JSDocTag`; see below) | ||
| 2. `descriptionLines` (an array of `JSDocDescriptionLine` for multiline | ||
| descriptions). | ||
| Has the following custom non-visitable property: | ||
| 1. `lastDescriptionLine` - A number | ||
| May also have the following non-visitable properties from `comment-parser`: | ||
| 1. `description` - Same as `descriptionLines` but as a string with newlines. | ||
| 2. `delimiter` | ||
| 3. `end` | ||
| 4. `postDelimiter` | ||
| ### `JSDocTag` | ||
| Has three visitable properties: | ||
| 1. `parsedType` (the `jsdoctypeparser` AST representaiton of the tag's | ||
| type (see the `jsdoctypeparser` section below)). | ||
| 2. `descriptionLines`' (an array of `JSDocDescriptionLine` for multiline | ||
| descriptions) | ||
| 3. `typeLines` (an array of `JSDocDescriptionLine` for multiline type | ||
| strings) | ||
| May also have the following non-visitable properties from `comment-parser` | ||
| (note that all are included from `comment-parser` except `end` as that is only | ||
| for JSDoc blocks and note that `type` is renamed to `rawType`): | ||
| 1. `description` - Same as `descriptionLines` but as a string with newlines. | ||
| 2. `rawType` - `comment-parser` has this named as `type`, but because of a | ||
| conflict with ESTree using `type` for Node type, we renamed it to | ||
| `rawType`. It is otherwise the same as in `comment-parser`, i.e., a string | ||
| with newlines, though with the initial `{` and final `}` stripped out. | ||
| See `typeLines` for the array version of this property. | ||
| 3. `start` | ||
| 4. `delimiter` | ||
| 5. `postDelimiter` | ||
| 6. `tag` | ||
| 7. `postTag` | ||
| 8. `name` | ||
| 9. `postName` | ||
| 10. `type` | ||
| 11. `postType` | ||
| ### `JSDocDescriptionLine` | ||
| No visitable properties. | ||
| May also have the following non-visitable properties from `comment-parser`: | ||
| 1. `delimiter` | ||
| 2. `postDelimiter` | ||
| 3. `start` | ||
| 4. `description` | ||
| ### `JSDocTypeLine` | ||
| No visitable properties. | ||
| May also have the following non-visitable properties from `comment-parser`: | ||
| 1. `delimiter` | ||
| 2. `postDelimiter` | ||
| 3. `start` | ||
| 4. `rawType` - Renamed from `comment-parser` to avoid a conflict. See | ||
| explanation under `JSDocTag` | ||
| ## ESLint AST produced for `jsdoctypeparser` | ||
| The `type` has been changed for the type AST. Relative to `jsdoctypeparser` | ||
| nodes, the type will have a `JSDocType` prefix added plus a camel-casing of the | ||
| old type name, so, e.g., `INSTANCE_MEMBER` will become | ||
| `JSDocTypeInstanceMember`. | ||
| See [jsdoctypeparser](https://github.com/jsdoctypeparser/jsdoctypeparser) | ||
| for the current list of node types which are transformed in this manner. | ||
| Otherwise, the node properties are as in `jsdoctypeparser`. | ||
| The `jsdoctypeparser` visitor keys are also modified accordingly. | ||
| ## Installation | ||
@@ -23,0 +113,0 @@ |
@@ -143,2 +143,3 @@ import {parse as jsdoctypeParse} from 'jsdoctypeparser'; | ||
| JSDocDescriptionLine: [], | ||
| JSDocTypeLine: [], | ||
| JSDocTag: ['descriptionLines', 'typeLines', 'parsedType'] | ||
@@ -145,0 +146,0 @@ }; |
| const toCamelCase = (str) => { | ||
| return str.toLowerCase().replace(/^[a-z]/u, (init) => { | ||
| return str.toLowerCase().replace(/^[a-z]/gu, (init) => { | ||
| return init.toUpperCase(); | ||
@@ -4,0 +4,0 @@ }).replace(/_(?:<wordInit>[a-z])/u, (_, n1, o, s, {wordInit}) => { |
42389
11.44%17
6.25%1069
0.19%136
195.65%