Skip to content

Commit

Permalink
Add JSDoc type annotations to project (rebased)
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Nov 27, 2023
1 parent fd6bba8 commit 4da4827
Show file tree
Hide file tree
Showing 261 changed files with 32,766 additions and 13,545 deletions.
258 changes: 248 additions & 10 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": 2022,
"sourceType": "module",
"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 @@ -56,7 +66,7 @@
"no-param-reassign": "off",
"no-prototype-builtins": "error",
"no-shadow": [
"error",
"off",
{
"builtinGlobals": false
}
Expand Down Expand Up @@ -259,23 +269,41 @@
"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 @@ -321,9 +349,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 @@ -373,12 +554,67 @@
{
"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": {
"isObject": "readonly",
"stringReverse": "readonly",
"promiseTimeout": "readonly",
"escapeRegExp": "readonly",
"deferPromise": "readonly",
"clone": "readonly",
"deepEqual": "readonly",
"generateId": "readonly",
"promiseAnimationFrame": "readonly",
"invokeMessageHandler": "readonly",
"log": "readonly",
"DynamicProperty": "readonly",
"EventDispatcher": "readonly",
"EventListenerCollection": "readonly",
"Logger": "readonly"
}
},
{
"files": [
"ext/**/*.js"
],
"excludedFiles": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/accessibility/google-docs.js",
"ext/js/yomitan.js",
"ext/js/**/sandbox/**/*.js"
],
"globals": {
"yomitan": "readonly"
}
},
{
"files": [
"ext/js/yomitan.js"
Expand Down Expand Up @@ -417,6 +653,7 @@
{
"files": [
"ext/js/core.js",
"ext/js/core/extension-error.js",
"ext/js/yomitan.js",
"ext/js/accessibility/accessibility-controller.js",
"ext/js/background/backend.js",
Expand Down Expand Up @@ -466,6 +703,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"
]
}
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"markdown.extension.toc.levels": "1..3",
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.addMissingImports": false,
"source.organizeImports": true,
"source.fixAll.eslint": true,
},
"eslint.format.enable": true,
"javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": false,
"javascript.preferences.importModuleSpecifierEnding": "js",
"editor.tabSize": 4,
"editor.insertSpaces": true,
"eslint.validate": [
"javascript",
"typescript"
],
"files.eol": "\n",
"html-validate.validate": [
"html"
]
}
1 change: 1 addition & 0 deletions dev/bin/generate-css-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import fs from 'fs';
import {formatRulesJson, generateRules, getTargets} from '../generate-css-json.js';

/** */
function main() {
for (const {cssFile, overridesCssFile, outputPath} of getTargets()) {
const json = formatRulesJson(generateRules(cssFile, overridesCssFile));
Expand Down
Loading

0 comments on commit 4da4827

Please sign in to comment.