Skip to content

Commit

Permalink
Finish refactoring, see #4. Introduce more accurate TS types, see #3.…
Browse files Browse the repository at this point in the history
… Improve JSDoc.
  • Loading branch information
martincizek committed May 28, 2020
1 parent f31dc79 commit 5417ed3
Show file tree
Hide file tree
Showing 13 changed files with 853 additions and 300 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
dist
scripts
57 changes: 35 additions & 22 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
{
"extends": "airbnb-base",
"extends": ["airbnb-base", "plugin:jsdoc/recommended"],
"plugins": ["jsdoc"],
"rules": {
"no-plusplus": "off",
"no-cond-assign": ["error", "except-parens"],
"no-unused-expressions": ["error", { "allowShortCircuit": true }],
"jsdoc/check-alignment": 1,
"jsdoc/require-jsdoc": ["warn", {
"publicOnly": true
}],
"jsdoc/no-undefined-types": ["warn", {
"definedTypes": [
"UnionReplacer",
"UnionReplacer.ReplacementBuilder",
"RegExpExecArray",
"true",
"false",
"T"
]
}],
"jsdoc/check-examples": 1,
"jsdoc/check-indentation": "off",
"jsdoc/check-param-names": 1,
"jsdoc/check-syntax": 1,
"jsdoc/check-tag-names": 1,
"jsdoc/check-types": 1,
"jsdoc/implements-on-classes": 1,
"jsdoc/match-description": 1,
"jsdoc/newline-after-description": 1,
"jsdoc/no-undefined-types": 1,
"jsdoc/require-description": 1,
"jsdoc/require-description": ["warn", {
"exemptedBy": ["inheritdoc", "private", "deprecated", "hideconstructor"]
}],
"jsdoc/require-description-complete-sentence": 1,
"jsdoc/require-example": 1,
"jsdoc/require-hyphen-before-param-description": 1,
"jsdoc/require-jsdoc": 1,
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 1,
"jsdoc/require-param-name": 1,
"jsdoc/require-param-type": 1,
"jsdoc/require-returns": 1,
"jsdoc/require-returns-check": 1,
"jsdoc/require-returns-description": 1,
"jsdoc/require-returns-type": 1,
"jsdoc/valid-types": 1
"jsdoc/require-param": ["warn", {
"exemptedBy": ["inheritdoc", "hideconstructor"]
}],
"jsdoc/require-example": ["warn", {
"contexts" : [
"ClassDeclaration[id.name='UnionReplacer'] > ClassBody > MethodDefinition"
],
"exemptedBy": ["inheritdoc", "private", "deprecated"]
}],
"jsdoc/require-hyphen-before-param-description": 1
},
"settings": {
"jsdoc": {
"mode": "closure",
"tagNamePreference": {
"function": "method"
}
}
}
}
24 changes: 24 additions & 0 deletions .jsdoc.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const template = env.opts.template || '';
const targetTs = template.includes('tsd-jsdoc');

const sourceIncludes = [
'src/UnionReplacer.js',
'src/MatchingContext.js',
'src/typedefs.js',
];

if (!targetTs) {
sourceIncludes.push('src/typedefs-tscompat.js');
}

module.exports = {
source: { include: sourceIncludes },
plugins: [
'./node_modules/tsd-jsdoc/dist/plugin',
'plugins/markdown',
],
opts: {
package: 'package.json',
readme: 'README.md',
},
};
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ newStr = replacer.replace(str)
[Specifying a string as a parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter).
- `flags`: regular expression flags to be set on the main underlying regexp, defaults to `gm`.
### API updates
- v2.0 removes the `addReplacement()` method, see
[#4](https://github.com/orchitech/union-replacer/issues/4) for details.
- v2.0 introduces TypeScript type definitions.
## Examples
### Convenient one-pass escaping of HTML special chars
Expand Down
Loading

0 comments on commit 5417ed3

Please sign in to comment.