Skip to content

Commit

Permalink
Add JSDoc type annotations to project
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Nov 27, 2023
1 parent c437897 commit 3397ce5
Show file tree
Hide file tree
Showing 292 changed files with 25,135 additions and 5,867 deletions.
225 changes: 208 additions & 17 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
"root": true,
"extends": [
"eslint:recommended",
"plugin:jsonc/recommended-with-json"
"plugin:jsonc/recommended-with-json",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "script",
"ecmaFeatures": {
"globalReturn": false,
"impliedStrict": true
}
},
"project": [
"./jsconfig.json",
"./dev/jsconfig.json",
"./test/jsconfig.json"
]
},
"env": {
"browser": true,
Expand All @@ -21,7 +28,10 @@
"no-unsanitized",
"header",
"jsdoc",
"jsonc"
"jsonc",
"unused-imports",
"@typescript-eslint",
"@stylistic/ts"
],
"ignorePatterns": [
"/ext/lib/"
Expand Down Expand Up @@ -54,7 +64,7 @@
"no-param-reassign": "off",
"no-prototype-builtins": "error",
"no-shadow": [
"error",
"off",
{
"builtinGlobals": false
}
Expand Down Expand Up @@ -233,7 +243,7 @@
"no-unsanitized/property": "error",
"jsdoc/check-access": "error",
"jsdoc/check-alignment": "error",
"jsdoc/check-line-alignment": "error",
"jsdoc/check-line-alignment": ["error", "never", {"wrapIndent": " "}],
"jsdoc/check-param-names": "error",
"jsdoc/check-property-names": "error",
"jsdoc/check-tag-names": "error",
Expand All @@ -242,34 +252,48 @@
"jsdoc/empty-tags": "error",
"jsdoc/implements-on-classes": "error",
"jsdoc/multiline-blocks": "error",
"jsdoc/newline-after-description": [
"error",
"never"
],
"jsdoc/no-bad-blocks": "error",
"jsdoc/no-multi-asterisks": "error",
"jsdoc/require-asterisk-prefix": "error",
"jsdoc/require-hyphen-before-param-description": [
"error",
"never"
],
"jsdoc/require-jsdoc": "off",
"jsdoc/require-jsdoc": [
"error",
{
"require": {
"ClassDeclaration": false,
"FunctionDeclaration": true,
"MethodDefinition": false
},
"contexts": [
"MethodDefinition[kind=constructor]>FunctionExpression>BlockStatement>ExpressionStatement>AssignmentExpression[left.object.type=ThisExpression]",
"ClassDeclaration>Classbody>PropertyDefinition",
"MethodDefinition[kind!=constructor][kind!=set]",
"MethodDefinition[kind=constructor][value.params.length>0]"
],
"checkGetters": "no-setter",
"checkSetters": "no-getter"
}
],
"jsdoc/require-description": "off",
"jsdoc/require-param": "error",
"jsdoc/require-param-description": "error",
"jsdoc/require-param-description": "off",
"jsdoc/require-param-name": "error",
"jsdoc/require-param-type": "error",
"jsdoc/require-property": "error",
"jsdoc/require-property-description": "error",
"jsdoc/require-property-description": "off",
"jsdoc/require-property-name": "error",
"jsdoc/require-property-type": "error",
"jsdoc/require-returns": "error",
"jsdoc/require-returns-check": "error",
"jsdoc/require-returns-description": "error",
"jsdoc/require-returns-description": "off",
"jsdoc/require-returns-type": "error",
"jsdoc/require-throws": "error",
"jsdoc/require-yields": "error",
"jsdoc/require-yields-check": "error",
"jsdoc/tag-lines": "error",
"jsdoc/tag-lines": ["error", "never", {"startLines": 0}],
"jsdoc/valid-types": "error",
"jsonc/indent": [
"error",
Expand Down Expand Up @@ -315,9 +339,162 @@
{
"allowAllPropertiesOnSameLine": true
}
]
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"object": true
},
"extendDefaults": true
}
],
"@typescript-eslint/consistent-type-exports": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-shadow": [
"error",
{
"builtinGlobals": false
}
],
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off"
},
"overrides": [
{
"files": [
"*.ts"
],
"rules": {
"no-undef": "off",
"unused-imports/no-unused-imports": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
"vars": "local",
"args": "after-used",
"argsIgnorePattern": "^_",
"caughtErrors": "none"
}
],
"comma-dangle": "off",
"@typescript-eslint/comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline",
"enums": "always-multiline",
"generics": "always-multiline",
"tuples": "always-multiline"
}
],
"@stylistic/ts/block-spacing": "off",
"@stylistic/ts/brace-style": [
"error",
"1tbs",
{
"allowSingleLine": true
}
],
"@stylistic/ts/comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline",
"enums": "always-multiline",
"generics": "always-multiline",
"tuples": "always-multiline"
}
],
"@stylistic/ts/comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"@stylistic/ts/function-call-spacing": [
"error",
"never"
],
"@stylistic/ts/indent": [
"error",
4
],
"@stylistic/ts/key-spacing": [
"error",
{
"beforeColon": false,
"afterColon": true,
"mode": "strict"
}
],
"@stylistic/ts/keyword-spacing": [
"error",
{
"before": true,
"after": true
}
],
"@stylistic/ts/lines-around-comment": "off",
"@stylistic/ts/lines-between-class-members": [
"error",
"always"
],
"@stylistic/ts/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
},
"multilineDetection": "brackets"
}
],
"@stylistic/ts/no-extra-parens": [
"error",
"all"
],
"@stylistic/ts/no-extra-semi": "error",
"@stylistic/ts/object-curly-spacing": [
"error",
"never"
],
"@stylistic/ts/padding-line-between-statements": "off",
"@stylistic/ts/quotes": [
"error",
"single",
"avoid-escape"
],
"@stylistic/ts/semi": "error",
"@stylistic/ts/space-before-blocks": [
"error",
"always"
],
"@stylistic/ts/space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"@stylistic/ts/space-infix-ops": "error",
"@stylistic/ts/type-annotation-spacing": "error"
}
},
{
"files": [
"*.json"
Expand Down Expand Up @@ -367,24 +544,35 @@
{
"files": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/**/sandbox/**/*.js"
],
"env": {
"webextensions": false
}
},
{
"files": [
"ext/**/*.js"
],
"excludedFiles": [
"ext/js/core/extension-error.js"
],
"globals": {
"ExtensionError": "readonly"
}
},
{
"files": [
"ext/**/*.js"
],
"excludedFiles": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/accessibility/google-docs.js",
"ext/js/**/sandbox/**/*.js"
],
"globals": {
"serializeError": "readonly",
"deserializeError": "readonly",
"isObject": "readonly",
"stringReverse": "readonly",
"promiseTimeout": "readonly",
Expand All @@ -408,6 +596,7 @@
],
"excludedFiles": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/accessibility/google-docs.js",
"ext/js/yomichan.js",
"ext/js/**/sandbox/**/*.js"
Expand Down Expand Up @@ -475,6 +664,7 @@
{
"files": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/yomichan.js",
"ext/js/accessibility/accessibility-controller.js",
"ext/js/background/backend.js",
Expand Down Expand Up @@ -522,6 +712,7 @@
{
"files": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/data/database.js",
"ext/js/data/json-schema.js",
"ext/js/general/cache-map.js",
Expand Down
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"html-validate.vscode-html-validate",
"stylelint.vscode-stylelint"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.tabSize": 4,
"editor.insertSpaces": true,
"eslint.validate": [
"javascript",
"typescript"
],
"files.eol": "\n"
}
7 changes: 7 additions & 0 deletions dev/build-libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const fs = require('fs');
const path = require('path');
const browserify = require('browserify');

/**
* @returns {Promise<Buffer>}
*/
async function buildParse5() {
const parse5Path = require.resolve('parse5');
const cwd = process.cwd();
Expand All @@ -45,13 +48,17 @@ async function buildParse5() {
}
}

/**
* @returns {{path: string, build: () => Promise<Buffer|string>}[]}
*/
function getBuildTargets() {
const extLibPath = path.join(__dirname, '..', 'ext', 'lib');
return [
{path: path.join(extLibPath, 'parse5.js'), build: buildParse5}
];
}

/** */
async function main() {
for (const {path: path2, build} of getBuildTargets()) {
const content = await build();
Expand Down
Loading

0 comments on commit 3397ce5

Please sign in to comment.