chore(jsdoc-eslint-config): move packages to the correct package.json file; enable Prettier; fix linter issues

This commit is contained in:
Jeff Williams 2023-11-25 10:28:22 -08:00
parent 443148ab8f
commit 5a74ffd016
No known key found for this signature in database
11 changed files with 626 additions and 684 deletions

View File

@ -14,6 +14,6 @@
limitations under the License.
*/
module.exports = {
extends: ['@jsdoc', 'plugin:prettier/recommended'],
extends: ['@jsdoc'],
root: true,
};

8
package-lock.json generated
View File

@ -40,9 +40,6 @@
"ajv": "^8.12.0",
"c8": "^8.0.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"execa": "^8.0.1",
"hereby": "^1.8.8",
"jasmine": "^5.1.0",
@ -12274,13 +12271,16 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/eslint-parser": "^7.23.3",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0"
},
"engines": {
"node": ">=v18.12.0"
},
"peerDependencies": {
"eslint": ">= 8.54.0"
"eslint": ">= 8.54.0",
"prettier": ">= 3.1.0"
}
},
"packages/jsdoc-parse": {

View File

@ -19,9 +19,6 @@
"ajv": "^8.12.0",
"c8": "^8.0.1",
"eslint": "^8.54.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"execa": "^8.0.1",
"hereby": "^1.8.8",
"jasmine": "^5.1.0",

View File

@ -62,16 +62,12 @@ export class DocletStore {
static #propertiesWithMaps = ['kind', 'longname', 'memberof'];
static #propertyToMapName = new Map(
DocletStore.#propertiesWithMaps.map((prop) => {
return [prop, 'docletsBy' + _.capitalize(prop)];
})
DocletStore.#propertiesWithMaps.map((prop) => [prop, 'docletsBy' + _.capitalize(prop)])
);
static #propertiesWithSets = ['augments', 'borrowed', 'implements', 'mixes'];
static #propertyToSetName = new Map(
DocletStore.#propertiesWithSets.map((prop) => {
return [prop, 'docletsWith' + _.capitalize(prop)];
})
DocletStore.#propertiesWithSets.map((prop) => [prop, 'docletsWith' + _.capitalize(prop)])
);
constructor(dependencies) {
@ -113,9 +109,8 @@ export class DocletStore {
const isVisible = doclet.isVisible();
const newDoclet = opts.newDoclet ?? false;
const wasVisible = newDoclet ? false : this.doclets.has(doclet);
const visibilityChanged = (() => {
return newDoclet || (!wasVisible && isVisible) || (wasVisible && !isVisible);
})();
const visibilityChanged = (() =>
newDoclet || (!wasVisible && isVisible) || (wasVisible && !isVisible))();
const docletInfo = {
isGlobal: doclet.isGlobal(),
isVisible,

View File

@ -14,6 +14,8 @@
limitations under the License.
*/
module.exports = {
extends: ['plugin:prettier/recommended'],
env: {
es6: true,
jasmine: true,
@ -26,7 +28,7 @@ module.exports = {
requireConfigFile: false,
sourceType: 'module',
},
plugins: ['simple-import-sort'],
plugins: ['prettier', 'simple-import-sort'],
rules: {
// Possible errors
@ -238,5 +240,8 @@ module.exports = {
// https://github.com/lydell/eslint-plugin-simple-import-sort
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// https://github.com/prettier/eslint-plugin-prettier
'prettier/prettier': 'error',
},
};

View File

@ -12,10 +12,13 @@
"main": "index.js",
"dependencies": {
"@babel/eslint-parser": "^7.23.3",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0"
},
"peerDependencies": {
"eslint": ">= 8.54.0"
"eslint": ">= 8.54.0",
"prettier": ">= 3.1.0"
},
"publishConfig": {
"access": "public"

View File

@ -53,6 +53,7 @@ function getLastValue(set) {
let value;
if (set) {
// eslint-disable-next-line curly
for (value of set);
}

View File

@ -16,7 +16,5 @@
const Salty = require('./lib/salty');
module.exports = {
taffy: (items) => {
return new Salty(items);
},
taffy: (items) => new Salty(items),
};

File diff suppressed because it is too large Load Diff

View File

@ -15,49 +15,47 @@
*/
// Tags that JSDoc uses internally, and that must always be defined.
export const getTags = () => {
return {
// Special separator tag indicating that multiple doclets should be generated for the same
// comment. Used internally (and by some JSDoc users, although it's not officially supported).
//
// In the following example, the parser will replace `//**` with an `@also` tag:
// /**
// * Foo.
// *//**
// * Foo with a param.
// * @param {string} bar
// */
// function foo(bar) {}
also: {
onTagged() {
// Let the parser handle it. We define the tag here to avoid "not a known tag" errors.
},
export const getTags = () => ({
// Special separator tag indicating that multiple doclets should be generated for the same
// comment. Used internally (and by some JSDoc users, although it's not officially supported).
//
// In the following example, the parser will replace `//**` with an `@also` tag:
// /**
// * Foo.
// *//**
// * Foo with a param.
// * @param {string} bar
// */
// function foo(bar) {}
also: {
onTagged() {
// Let the parser handle it. We define the tag here to avoid "not a known tag" errors.
},
description: {
mustHaveValue: true,
onTagged: (doclet, { value }) => {
doclet.description = value;
},
synonyms: ['desc'],
},
description: {
mustHaveValue: true,
onTagged: (doclet, { value }) => {
doclet.description = value;
},
kind: {
mustHaveValue: true,
onTagged: (doclet, { value }) => {
doclet.kind = value;
},
synonyms: ['desc'],
},
kind: {
mustHaveValue: true,
onTagged: (doclet, { value }) => {
doclet.kind = value;
},
name: {
mustHaveValue: true,
onTagged: (doclet, { value }) => {
doclet.name = value;
},
},
name: {
mustHaveValue: true,
onTagged: (doclet, { value }) => {
doclet.name = value;
},
undocumented: {
mustNotHaveValue: true,
onTagged(doclet) {
doclet.undocumented = true;
doclet.comment = '';
},
},
undocumented: {
mustNotHaveValue: true,
onTagged(doclet) {
doclet.undocumented = true;
doclet.comment = '';
},
};
};
},
});

View File

@ -60,9 +60,7 @@ function matchmaker(name, checker) {
}
const matcherFuncs = {
toBeArray: (actual) => {
return _.isArray(actual);
},
toBeArray: (actual) => _.isArray(actual),
toBeArrayOfSize: (actual, expected) => {
if (_.isArray(actual) && actual.length === expected) {
return true;
@ -77,76 +75,31 @@ const matcherFuncs = {
return !actual.some((item) => !_.isString(item));
},
toBeArrayOfObjects: (actual) => {
return _.isArray(actual) && !actual.some((item) => !_.isObject(item));
},
toBeBoolean: (actual) => {
return _.isBoolean(actual);
},
toBeEmptyArray: (actual) => {
return _.isArray(actual) && actual.length === 0;
},
toBeEmptyMap: (actual) => {
return _.isMap(actual) && actual.size === 0;
},
toBeEmptyObject: (actual) => {
return _.isObject(actual) && !Object.keys(actual).length;
},
toBeEmptySet: (actual) => {
return _.isSet(actual) && actual.size === 0;
},
toBeEmptyString: (actual) => {
return actual === '';
},
toBeError: (actual) => {
return actual instanceof Error;
},
toBeErrorOfType: (actual, expected) => {
return actual instanceof Error && actual.name === expected;
},
toBeFunction: (actual) => {
return _.isFunction(actual);
},
toBeArrayOfObjects: (actual) => _.isArray(actual) && !actual.some((item) => !_.isObject(item)),
toBeBoolean: (actual) => _.isBoolean(actual),
toBeEmptyArray: (actual) => _.isArray(actual) && actual.length === 0,
toBeEmptyMap: (actual) => _.isMap(actual) && actual.size === 0,
toBeEmptyObject: (actual) => _.isObject(actual) && !Object.keys(actual).length,
toBeEmptySet: (actual) => _.isSet(actual) && actual.size === 0,
toBeEmptyString: (actual) => actual === '',
toBeError: (actual) => actual instanceof Error,
toBeErrorOfType: (actual, expected) => actual instanceof Error && actual.name === expected,
toBeFunction: (actual) => _.isFunction(actual),
toBeInstanceOf: isInstanceOf,
toBeLessThanOrEqualTo: (actual, expected) => {
return actual <= expected;
},
toBeMap: (actual) => {
return _.isMap(actual);
},
toBeNonEmptyObject: (actual) => {
return _.isObject(actual) && Object.keys(actual).length;
},
toBeNonEmptyString: (actual) => {
return _.isString(actual) && actual.length > 0;
},
toBeNumber: (actual) => {
return _.isNumber(actual);
},
toBeObject: (actual) => {
return _.isObject(actual);
},
toBeSet: (actual) => {
return _.isSet(actual);
},
toBeString: (actual) => {
return _.isString(actual);
},
toBeWholeNumber: (actual) => {
return Number.isInteger(actual);
},
toEndWith: (actual, expected) => {
return _.isString(actual) && _.isString(expected) && actual.endsWith(expected);
},
toHave: (actual, expected) => {
return (_.isMap(actual) || _.isSet(actual)) && actual.has(expected);
},
toHaveMethod: (actual, expected) => {
return _.isObject(actual) && _.isFunction(actual[expected]);
},
toHaveOwnProperty: (actual, expected) => {
return Object.hasOwn(actual, expected);
},
toBeLessThanOrEqualTo: (actual, expected) => actual <= expected,
toBeMap: (actual) => _.isMap(actual),
toBeNonEmptyObject: (actual) => _.isObject(actual) && Object.keys(actual).length,
toBeNonEmptyString: (actual) => _.isString(actual) && actual.length > 0,
toBeNumber: (actual) => _.isNumber(actual),
toBeObject: (actual) => _.isObject(actual),
toBeSet: (actual) => _.isSet(actual),
toBeString: (actual) => _.isString(actual),
toBeWholeNumber: (actual) => Number.isInteger(actual),
toEndWith: (actual, expected) =>
_.isString(actual) && _.isString(expected) && actual.endsWith(expected),
toHave: (actual, expected) => (_.isMap(actual) || _.isSet(actual)) && actual.has(expected),
toHaveMethod: (actual, expected) => _.isObject(actual) && _.isFunction(actual[expected]),
toHaveOwnProperty: (actual, expected) => Object.hasOwn(actual, expected),
// The objects in `actual` must have all of the keys and values from the corresponding objects in
// `expected`. The object in `actual` can have additional properties as well. For example, if
// `expected[0]` is `{ a: 1 }`, and `actual[0]` is `{ a: 1, b: 2 }`, then the objects match.
@ -176,9 +129,7 @@ const matcherFuncs = {
// The `actual` object must have all of the keys and values from the `expected` object. The
// `actual` object can have additional properties as well. For example, if `expected` is
// `{ a: 1 }`, and `actual` is `{ a: 1, b: 2 }`, then the objects match.
toMatchObject: (actual, expected) => {
return _.isMatch(actual, expected);
},
toMatchObject: (actual, expected) => _.isMatch(actual, expected),
toThrowErrorOfType: (actual, expected) => {
let error;