Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): add eslint-community/eslint-plugin-eslint-comments #331

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
},
extends: [
"airbnb-base",
"plugin:@eslint-community/eslint-comments/recommended",
"plugin:jsdoc/recommended",
"plugin:promise/recommended",
"plugin:regexp/recommended",
Expand Down Expand Up @@ -49,10 +50,12 @@ module.exports = {
],
root: true,
rules: {
"@eslint-community/eslint-comments/disable-enable-pair": "off",
"@eslint-community/eslint-comments/no-unused-disable": "error",
"@eslint-community/eslint-comments/require-description": "error",
"import/no-extraneous-dependencies": "error",
"jsdoc/check-syntax": "error",
"jsdoc/require-hyphen-before-param-description": "error",
"no-console": "off",
"no-multiple-empty-lines": ["error", { max: 1 }],
"prefer-destructuring": ["error", { object: true, array: false }],
"promise/prefer-await-to-callbacks": "warn",
Expand Down
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"redhat.vscode-yaml"
]
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"files.eol": "\n",
"gitlens.telemetry.enabled": false,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down
17 changes: 16 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

* [UnRTF](#UnRTF)
* [new UnRTF([binPath])](#new_UnRTF_new)
* [.unrtfPath](#UnRTF+unrtfPath) : <code>string</code> \| <code>undefined</code>
* [.unrtfVersion](#UnRTF+unrtfVersion) : <code>string</code> \| <code>undefined</code>
* [.unrtfAcceptedOptions](#UnRTF+unrtfAcceptedOptions) : <code>object</code>
* [.convert(file, [options])](#UnRTF+convert) ⇒ <code>Promise.&lt;string&gt;</code>

<a name="new_UnRTF_new"></a>
Expand All @@ -13,8 +16,20 @@

| Param | Type | Description |
| --- | --- | --- |
| [binPath] | <code>string</code> | Path of UnRTF binary. |
| [binPath] | <code>string</code> | Path of UnRTF binary. If not provided, the constructor will attempt to find the binary in the PATH environment variable. For `win32`, a binary is bundled with the package and will be used if a local installation is not found. |

<a name="UnRTF+unrtfPath"></a>

### unRTF.unrtfPath : <code>string</code> \| <code>undefined</code>
**Kind**: instance property of [<code>UnRTF</code>](#UnRTF)
<a name="UnRTF+unrtfVersion"></a>

### unRTF.unrtfVersion : <code>string</code> \| <code>undefined</code>
**Kind**: instance property of [<code>UnRTF</code>](#UnRTF)
<a name="UnRTF+unrtfAcceptedOptions"></a>

### unRTF.unrtfAcceptedOptions : <code>object</code>
**Kind**: instance property of [<code>UnRTF</code>](#UnRTF)
<a name="UnRTF+convert"></a>

### unRTF.convert(file, [options]) ⇒ <code>Promise.&lt;string&gt;</code>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
"@types/jest": "^29.5.5",
"eslint": "^8.50.0",
"eslint-config-airbnb-base": "^15.0.0",
Expand Down
3 changes: 0 additions & 3 deletions scripts/license-checker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable security/detect-object-injection */
/* eslint-disable security-node/detect-crlf */

"use strict";

const { promisify } = require("node:util");
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function parseOptions(acceptedOptions, options, version) {
const invalidArgs = [];
Object.keys(options).forEach((key) => {
if (Object.hasOwn(acceptedOptions, key)) {
// eslint-disable-next-line valid-typeof
// eslint-disable-next-line valid-typeof -- `type` is a string
if (typeof options[key] === acceptedOptions[key].type) {
// Skip boolean options if false
if (acceptedOptions[key].type === "boolean" && !options[key]) {
Expand Down Expand Up @@ -203,7 +203,7 @@ class UnRTF {
*/
let buff;
try {
// eslint-disable-next-line security/detect-non-literal-fs-filename
// eslint-disable-next-line security/detect-non-literal-fs-filename -- File read is wanted
buff = await readFile(normalizeTrim(file));
} catch {
throw new Error("File missing");
Expand Down
8 changes: 4 additions & 4 deletions src/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable global-require, jest/no-conditional-expect */
/* eslint-disable global-require, security/detect-child-process -- Mocking child_process */
/* eslint-disable jest/no-conditional-expect -- Depends on the version of the binary */

"use strict";

Expand Down Expand Up @@ -63,7 +64,7 @@ describe("Constructor", () => {
* @todo Fix this test, mocking of "node:" scheme not supported yet
* @see {@link https://github.com/jestjs/jest/pull/14297 | Jest PR #14297}
*/
// eslint-disable-next-line jest/no-disabled-tests
// eslint-disable-next-line jest/no-disabled-tests -- Blocked by Jest PR #14297
it.skip("Throws an Error if the binary path is not found", () => {
Object.defineProperty(process, "platform", {
value: "mockOS",
Expand All @@ -78,13 +79,12 @@ describe("Constructor", () => {
},
})),
}));
// eslint-disable-next-line security/detect-child-process
require("node:child_process");
const { UnRTF: UnRTFMock } = require("./index");

expect.assertions(1);
try {
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line no-unused-vars -- This is intentional
const unRtf = new UnRTFMock();
} catch (err) {
expect(err.message).toBe(
Expand Down
2 changes: 0 additions & 2 deletions test_resources/utils/bt-power-set.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable security/detect-object-injection */

"use strict";

/**
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"lib": ["ES2023"],
"lib": ["ES2022"],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "types",
Expand Down
16 changes: 14 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
export default UnRTF;
export class UnRTF {
/** @param {string} [binPath] - Path of UnRTF binary. */
/**
* @param {string} [binPath] - Path of UnRTF binary.
* If not provided, the constructor will attempt to find the binary
* in the PATH environment variable.
*
* For `win32`, a binary is bundled with the package and will be used
* if a local installation is not found.
*/
constructor(binPath?: string);
unrtfPath: string;
/** @type {string|undefined} */
unrtfPath: string | undefined;
/** @type {string|undefined} */
unrtfVersion: string | undefined;
/** @type {object} */
unrtfAcceptedOptions: object;
/**
* @author Frazer Smith
* @description Converts an RTF file to HTML/LaTeX/RTF/TXT.
Expand Down