Skip to content

Commit

Permalink
Generate “x-element.d.ts” from JSDoc comments.
Browse files Browse the repository at this point in the history
Previously, the “x-element.d.ts” file was hand-curated, which was prone
to falling out of date.

Because the TypeScript team manages JSDoc, it’s fairly straightforward
to properly “type” your JS with JSDoc and output declarations which can
be used by folks writing TypeScript — all of that without needing to
actually author TypeScript ourselves.†

Additionally, tools like JSR will build basic documentation for
libraries which author JSDoc comments, so some wins there.

Finally, to ensure best practices for our JSDocs, we enable some
recommended rules from the eslint plugin.

† One goal of “x-element” is to be _highly_ portable, it’s why no
  dependencies exist and why the “x-element.js” file can be used
  _verbatim_ without a build step.
  • Loading branch information
theengineear committed Oct 9, 2024
1 parent ff9e070 commit b69eb1f
Show file tree
Hide file tree
Showing 8 changed files with 650 additions and 137 deletions.
9 changes: 8 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"name": "@netflix/x-element",
"version": "1.0.0",
"exports": "./x-element.js"
"exports": {
"./x-element.d.ts": "./x-element.d.ts"
},
"include": [
"./x-element.js",
"./x-element.d.ts",
"./x-element.d.ts.map"
]
}
11 changes: 11 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import globals from 'globals';
import jsdoc from 'eslint-plugin-jsdoc';
import NetflixCommon from '@netflix/eslint-config';

export default [
jsdoc.configs['flat/recommended'],
{
...NetflixCommon,
files: ['**/*.js'],
Expand All @@ -12,6 +14,15 @@ export default [
'demo/react/*',
],
},
{
files: ['x-element.js'],
plugins: { jsdoc },
rules: {
'jsdoc/require-param-description': 'off',
'jsdoc/require-property-description': 'off',
'jsdoc/require-returns-description': 'off',
},
},
{
...NetflixCommon,
files: ['demo/react/**/*.js'],
Expand Down
Loading

0 comments on commit b69eb1f

Please sign in to comment.