441b6882ca
* Fix spacing * Update lint dependencies * Disable false positive rule * Update header rule * Install eslint-plugin-jsonc * Update lint rules to include jsonc extension
351 lines
13 KiB
JSON
351 lines
13 KiB
JSON
{
|
|
"root": true,
|
|
"extends": [
|
|
"eslint:recommended",
|
|
"plugin:jsonc/recommended-with-json"
|
|
],
|
|
"parserOptions": {
|
|
"ecmaVersion": 8,
|
|
"sourceType": "script",
|
|
"ecmaFeatures": {
|
|
"globalReturn": false,
|
|
"impliedStrict": true
|
|
}
|
|
},
|
|
"env": {
|
|
"browser": true,
|
|
"es2017": true,
|
|
"webextensions": true
|
|
},
|
|
"plugins": [
|
|
"no-unsanitized",
|
|
"header",
|
|
"jsdoc",
|
|
"jsonc"
|
|
],
|
|
"ignorePatterns": [
|
|
"/ext/lib/"
|
|
],
|
|
"rules": {
|
|
"arrow-parens": ["error", "always"],
|
|
"comma-dangle": ["error", "never"],
|
|
"curly": ["error", "all"],
|
|
"dot-notation": "error",
|
|
"eqeqeq": "error",
|
|
"func-names": ["error", "always"],
|
|
"guard-for-in": "error",
|
|
"new-parens": "error",
|
|
"no-case-declarations": "error",
|
|
"no-const-assign": "error",
|
|
"no-constant-condition": "off",
|
|
"no-global-assign": "error",
|
|
"no-param-reassign": "off",
|
|
"no-prototype-builtins": "error",
|
|
"no-shadow": ["error", {"builtinGlobals": false}],
|
|
"no-undef": "error",
|
|
"no-undefined": "error",
|
|
"no-underscore-dangle": ["error", {"allowAfterThis": true, "allowAfterSuper": false, "allowAfterThisConstructor": false}],
|
|
"no-unexpected-multiline": "error",
|
|
"no-unneeded-ternary": "error",
|
|
"no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}],
|
|
"no-unused-expressions": "error",
|
|
"no-var": "error",
|
|
"prefer-const": ["error", {"destructuring": "all"}],
|
|
"quote-props": ["error", "consistent"],
|
|
"quotes": ["error", "single", "avoid-escape"],
|
|
"require-atomic-updates": "off",
|
|
"semi": "error",
|
|
"wrap-iife": ["error", "inside"],
|
|
|
|
"brace-style": ["error", "1tbs", {"allowSingleLine": true}],
|
|
"indent": ["error", 4, {"SwitchCase": 1, "MemberExpression": 1, "flatTernaryExpressions": true, "ignoredNodes": ["ConditionalExpression"]}],
|
|
"object-curly-newline": "error",
|
|
"padded-blocks": ["error", "never"],
|
|
|
|
"array-bracket-spacing": ["error", "never"],
|
|
"arrow-spacing": ["error", {"before": true, "after": true}],
|
|
"block-spacing": ["error", "always"],
|
|
"comma-spacing": ["error", {"before": false, "after": true}],
|
|
"computed-property-spacing": ["error", "never"],
|
|
"func-call-spacing": ["error", "never"],
|
|
"function-paren-newline": ["error", "multiline-arguments"],
|
|
"generator-star-spacing": ["error", "before"],
|
|
"key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "strict"}],
|
|
"keyword-spacing": ["error", {"before": true, "after": true}],
|
|
"no-trailing-spaces": "error",
|
|
"no-whitespace-before-property": "error",
|
|
"object-curly-spacing": ["error", "never"],
|
|
"rest-spread-spacing": ["error", "never"],
|
|
"semi-spacing": ["error", {"before": false, "after": true}],
|
|
"space-before-function-paren": ["error", {
|
|
"anonymous": "never",
|
|
"named": "never",
|
|
"asyncArrow": "always"
|
|
}],
|
|
"space-in-parens": ["error", "never"],
|
|
"space-unary-ops": "error",
|
|
"spaced-comment": ["error", "always"],
|
|
"switch-colon-spacing": ["error", {"after": true, "before": false}],
|
|
"template-curly-spacing": ["error", "never"],
|
|
"template-tag-spacing": ["error", "never"],
|
|
|
|
"no-unsanitized/method": "error",
|
|
"no-unsanitized/property": "error",
|
|
|
|
"jsdoc/check-access": "error",
|
|
"jsdoc/check-alignment": "error",
|
|
"jsdoc/check-line-alignment": "error",
|
|
"jsdoc/check-param-names": "error",
|
|
"jsdoc/check-property-names": "error",
|
|
"jsdoc/check-tag-names": "error",
|
|
"jsdoc/check-types": "error",
|
|
"jsdoc/check-values": "error",
|
|
"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-param": "error",
|
|
"jsdoc/require-param-description": "error",
|
|
"jsdoc/require-param-name": "error",
|
|
"jsdoc/require-param-type": "error",
|
|
"jsdoc/require-property": "error",
|
|
"jsdoc/require-property-description": "error",
|
|
"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-type": "error",
|
|
"jsdoc/require-throws": "error",
|
|
"jsdoc/require-yields": "error",
|
|
"jsdoc/require-yields-check": "error",
|
|
"jsdoc/tag-lines": "error",
|
|
"jsdoc/valid-types": "error",
|
|
|
|
"jsonc/indent": ["error", 4],
|
|
"jsonc/array-bracket-newline": ["error", "consistent"],
|
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
"jsonc/array-element-newline": ["error", "consistent"],
|
|
"jsonc/comma-style": ["error", "last"],
|
|
"jsonc/key-spacing": ["error", {"beforeColon": false, "afterColon": true, "mode": "strict"}],
|
|
"jsonc/no-octal-escape": "error",
|
|
"jsonc/object-curly-newline": ["error", {"consistent": true}],
|
|
"jsonc/object-curly-spacing": ["error", "never"],
|
|
"jsonc/object-property-newline": ["error", {"allowAllPropertiesOnSameLine": true}]
|
|
},
|
|
"overrides": [
|
|
{
|
|
"files": [
|
|
"*.json"
|
|
],
|
|
"parser": "jsonc-eslint-parser"
|
|
},
|
|
{
|
|
"files": [
|
|
"test/data/anki-note-builder-test-results.json",
|
|
"test/data/translator-test-results-note-data1.json",
|
|
"test/data/translator-test-results.json"
|
|
],
|
|
"rules": {
|
|
"jsonc/indent": ["error", 2]
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"test/data/dictionaries/valid-dictionary1/term_bank_1.json"
|
|
],
|
|
"rules": {
|
|
"jsonc/array-element-newline": ["off"],
|
|
"jsonc/object-property-newline": ["off"]
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"*.js"
|
|
],
|
|
"rules": {
|
|
"header/header": ["error", "block", [
|
|
"",
|
|
{"pattern": " \\* Copyright \\(C\\) (\\d+-)?2022 Yomichan Authors"},
|
|
" *",
|
|
" * This program is free software: you can redistribute it and/or modify",
|
|
" * it under the terms of the GNU General Public License as published by",
|
|
" * the Free Software Foundation, either version 3 of the License, or",
|
|
" * (at your option) any later version.",
|
|
" *",
|
|
" * This program is distributed in the hope that it will be useful,",
|
|
" * but WITHOUT ANY WARRANTY; without even the implied warranty of",
|
|
" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
|
|
" * GNU General Public License for more details.",
|
|
" *",
|
|
" * You should have received a copy of the GNU General Public License",
|
|
" * along with this program. If not, see <https://www.gnu.org/licenses/>.",
|
|
" "
|
|
]]
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"ext/js/core.js",
|
|
"ext/js/**/sandbox/**/*.js"
|
|
],
|
|
"env": {
|
|
"webextensions": false
|
|
}
|
|
},
|
|
{
|
|
"files": ["ext/**/*.js"],
|
|
"excludedFiles": [
|
|
"ext/js/core.js",
|
|
"ext/js/accessibility/google-docs.js",
|
|
"ext/js/**/sandbox/**/*.js"
|
|
],
|
|
"globals": {
|
|
"serializeError": "readonly",
|
|
"deserializeError": "readonly",
|
|
"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/accessibility/google-docs.js",
|
|
"ext/js/yomichan.js",
|
|
"ext/js/**/sandbox/**/*.js"
|
|
],
|
|
"globals": {
|
|
"yomichan": "readonly"
|
|
}
|
|
},
|
|
{
|
|
"files": ["ext/js/yomichan.js"],
|
|
"globals": {
|
|
"chrome": "writable"
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"test/**/*.js",
|
|
"dev/**/*.js"
|
|
],
|
|
"excludedFiles": ["test/data/html/*.js"],
|
|
"parserOptions": {
|
|
"ecmaVersion": 8,
|
|
"sourceType": "module"
|
|
},
|
|
"env": {
|
|
"browser": false,
|
|
"es2017": true,
|
|
"node": true,
|
|
"webextensions": false
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"ext/js/core.js",
|
|
"ext/js/yomichan.js",
|
|
"ext/js/accessibility/accessibility-controller.js",
|
|
"ext/js/background/backend.js",
|
|
"ext/js/background/profile-conditions-util.js",
|
|
"ext/js/background/request-builder.js",
|
|
"ext/js/background/script-manager.js",
|
|
"ext/js/comm/anki-connect.js",
|
|
"ext/js/comm/clipboard-monitor.js",
|
|
"ext/js/comm/clipboard-reader.js",
|
|
"ext/js/comm/mecab.js",
|
|
"ext/js/data/anki-util.js",
|
|
"ext/js/data/database.js",
|
|
"ext/js/data/json-schema.js",
|
|
"ext/js/data/options-util.js",
|
|
"ext/js/data/permissions-util.js",
|
|
"ext/js/data/sandbox/array-buffer-util.js",
|
|
"ext/js/dom/simple-dom-parser.js",
|
|
"ext/js/extension/environment.js",
|
|
"ext/js/general/cache-map.js",
|
|
"ext/js/general/object-property-accessor.js",
|
|
"ext/js/general/regex-util.js",
|
|
"ext/js/general/text-source-map.js",
|
|
"ext/js/language/deinflector.js",
|
|
"ext/js/language/dictionary-database.js",
|
|
"ext/js/language/sandbox/dictionary-data-util.js",
|
|
"ext/js/language/sandbox/japanese-util.js",
|
|
"ext/js/language/translator.js",
|
|
"ext/js/media/audio-downloader.js",
|
|
"ext/js/media/media-util.js",
|
|
"ext/js/templates/template-patcher.js",
|
|
"ext/js/background/background-main.js"
|
|
],
|
|
"env": {
|
|
"browser": false,
|
|
"serviceworker": true,
|
|
"es2017": true,
|
|
"webextensions": true
|
|
},
|
|
"globals": {
|
|
"FileReader": "readonly",
|
|
"Intl": "readonly",
|
|
"crypto": "readonly"
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"ext/js/core.js",
|
|
"ext/js/data/database.js",
|
|
"ext/js/data/json-schema.js",
|
|
"ext/js/general/cache-map.js",
|
|
"ext/js/language/dictionary-database.js",
|
|
"ext/js/language/dictionary-importer.js",
|
|
"ext/js/language/dictionary-worker-handler.js",
|
|
"ext/js/language/dictionary-worker-media-loader.js",
|
|
"ext/js/media/media-util.js"
|
|
],
|
|
"env": {
|
|
"browser": false,
|
|
"worker": true,
|
|
"es2017": true,
|
|
"webextensions": true
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"ext/js/**/*.js"
|
|
],
|
|
"excludedFiles": [
|
|
"ext/js/core.js",
|
|
"ext/js/**/*main.js"
|
|
],
|
|
"rules": {
|
|
"no-implicit-globals": "error"
|
|
}
|
|
},
|
|
{
|
|
"files": [
|
|
"ext/js/**/*.js"
|
|
],
|
|
"globals": {
|
|
"AbortController": "readonly"
|
|
}
|
|
}
|
|
]
|
|
}
|