From 089907269acb2788127c8470674a28fae691b14f Mon Sep 17 00:00:00 2001 From: Andrew Simachev Date: Sat, 12 Aug 2023 18:06:02 +0200 Subject: [PATCH] add singlequote rule to linter --- .eslintrc.js | 89 +++++++++++++++------------ check-licenses.js | 6 +- electron.js | 18 +++--- electron/hook/locale.js | 2 +- electron/js/util.js | 2 +- save-node-deps.js | 5 +- src/ts/component/menu/block/latex.tsx | 2 +- src/ts/component/page/main/type.tsx | 2 +- webpack.node.config.js | 6 +- 9 files changed, 69 insertions(+), 63 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 13b131d6c5..288418b66d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,70 +5,77 @@ module.exports = { node: true, }, extends: [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended", + 'eslint:recommended', + 'plugin:react/recommended', + 'plugin:@typescript-eslint/recommended', ], overrides: [], - parser: "@typescript-eslint/parser", + parser: '@typescript-eslint/parser', parserOptions: { project: true, - ecmaVersion: "latest", - sourceType: "module", + ecmaVersion: 'latest', + sourceType: 'module', }, - plugins: ["react", "@typescript-eslint"], + plugins: ['react', '@typescript-eslint'], rules: { - "prefer-const": "warn", - "semi": ["warn", "always"], - "quotes": "off", - "no-mixed-spaces-and-tabs": "warn", - "no-multi-spaces": "warn", - "no-unsafe-optional-chaining": "warn", - "no-useless-escape": "off", - "no-empty": "off", - "no-fallthrough": "off", - "no-case-declarations": "off", - "no-console": "off", + 'prefer-const': 'warn', + 'semi': ['warn', 'always'], + 'quotes': [ + 'warn', + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true, + } + ], + 'no-mixed-spaces-and-tabs': 'warn', + 'no-multi-spaces': 'warn', + 'no-unsafe-optional-chaining': 'warn', + 'no-useless-escape': 'off', + 'no-empty': 'off', + 'no-fallthrough': 'off', + 'no-case-declarations': 'off', + 'no-console': 'off', // unused vars - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": [ - "off", + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': [ + 'off', { - argsIgnorePattern: "^_", - varsIgnorePattern: "^_", - caughtErrorsIgnorePattern: "^_", + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', }, ], - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-extra-semi": "off", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-inferrable-types": "off", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-empty-interface": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/ban-types": [ - "error", + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-extra-semi': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-inferrable-types': 'off', + '@typescript-eslint/no-var-requires': 'off', + '@typescript-eslint/no-empty-interface': 'off', + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/ban-types': [ + 'error', { extendDefaults: true, types: { - "{}": false, + '{}': false, }, }, ], // react, JSX related - "jsx-quotes": ["warn", "prefer-double"], - "react/jsx-key": "off", - "react/no-find-dom-node": "off", - "react/no-unescaped-entities": "off", - "react/no-direct-mutation-state": "off", - "react/display-name": "off", + 'jsx-quotes': ['warn', 'prefer-double'], + 'react/jsx-key': 'off', + 'react/no-find-dom-node': 'off', + 'react/no-unescaped-entities': 'off', + 'react/no-direct-mutation-state': 'off', + 'react/display-name': 'off', }, settings: { react: { - version: "detect", + version: 'detect', }, }, }; diff --git a/check-licenses.js b/check-licenses.js index 676ac5d91b..d10ed065e1 100644 --- a/check-licenses.js +++ b/check-licenses.js @@ -8,12 +8,12 @@ function processLicenses(licenses, allowedLicenses) { // The hyphenation language patterns are licensed under the LGPL (unless otherwise noted) and copyrighted to their respective creators and maintainers. // https://github.com/bramstein/hyphenation-patterns - if (pkg.startsWith("hyphenation.")) { - pkgLicenses = "LGPL"; + if (pkg.startsWith('hyphenation.')) { + pkgLicenses = 'LGPL'; }; // Solutions developed by Anytype or Any Association are allowed - if (licenses[pkg].publisher == "Anytype" || licenses[pkg].publisher == "Any" || licenses[pkg].publisher == "Any Association") { + if (licenses[pkg].publisher == 'Anytype' || licenses[pkg].publisher == 'Any' || licenses[pkg].publisher == 'Any Association') { return false; }; diff --git a/electron.js b/electron.js index 371d54ca41..e2e0cb64c0 100644 --- a/electron.js +++ b/electron.js @@ -22,15 +22,15 @@ const Server = require('./electron/js/server.js'); const Util = require('./electron/js/util.js'); const csp = [ - "default-src 'self' 'unsafe-eval' blob: http://localhost:*", - "img-src 'self' http://*:* https://*:* data: blob: file://*", - "media-src 'self' http://*:* https://*:* data: blob: file://*", - "style-src 'unsafe-inline' http://localhost:* file://*", - "font-src data: file://* http://localhost:*", - "connect-src file://* http://localhost:* http://127.0.0.1:* ws://localhost:* https://*.anytype.io https://api.amplitude.com/ devtools://devtools data:", - "script-src-elem file: http://localhost:* https://sentry.io devtools://devtools 'unsafe-inline'", - "frame-src chrome-extension://react-developer-tools", - "worker-src 'self' 'unsafe-eval' blob: http://localhost:*", + 'default-src "self" "unsafe-eval" blob: http://localhost:*', + 'img-src "self" http://*:* https://*:* data: blob: file://*', + 'media-src "self" http://*:* https://*:* data: blob: file://*', + 'style-src "unsafe-inline" http://localhost:* file://*', + 'font-src data: file://* http://localhost:*', + 'connect-src file://* http://localhost:* http://127.0.0.1:* ws://localhost:* https://*.anytype.io https://api.amplitude.com/ devtools://devtools data:', + 'script-src-elem file: http://localhost:* https://sentry.io devtools://devtools "unsafe-inline"', + 'frame-src chrome-extension://react-developer-tools', + 'worker-src "self" "unsafe-eval" blob: http://localhost:*', ]; app.commandLine.appendSwitch('ignore-connections-limit', 'localhost, 127.0.0.1'); diff --git a/electron/hook/locale.js b/electron/hook/locale.js index 107da3183e..2c72ed1a00 100644 --- a/electron/hook/locale.js +++ b/electron/hook/locale.js @@ -61,7 +61,7 @@ const request = async (lang) => { }; const error = error => { - console.log("Error: " + error.message); + console.log('Error: ' + error.message); reject(error); }; diff --git a/electron/js/util.js b/electron/js/util.js index 372d7373be..84f88b88e3 100644 --- a/electron/js/util.js +++ b/electron/js/util.js @@ -212,7 +212,7 @@ class Util { }; enabledLangs () { - return [ "da-DK", "de-DE", "en-US", "es-ES", "fr-FR", "hi-IN", "id-ID", "it-IT", "no-NO", "ro-RO", "ru-RU", "uk-UA", "zh-CN", "zh-TW" ]; + return [ 'da-DK', 'de-DE', 'en-US', 'es-ES', 'fr-FR', 'hi-IN', 'id-ID', 'it-IT', 'no-NO', 'ro-RO', 'ru-RU', 'uk-UA', 'zh-CN', 'zh-TW' ]; }; translate (key) { diff --git a/save-node-deps.js b/save-node-deps.js index 06fc3da2b7..14ff5cae0a 100644 --- a/save-node-deps.js +++ b/save-node-deps.js @@ -1,11 +1,10 @@ 'use strict'; const fs = require('fs'); - const stdin = process.openStdin(); -let data = ""; -stdin.on('data', function(chunk) { +let data = ''; +stdin.on('data', (chunk) => { data +=chunk; }); diff --git a/src/ts/component/menu/block/latex.tsx b/src/ts/component/menu/block/latex.tsx index 50ca3b4c39..09c58dffcc 100644 --- a/src/ts/component/menu/block/latex.tsx +++ b/src/ts/component/menu/block/latex.tsx @@ -205,7 +205,7 @@ const MenuBlockLatex = observer(class MenuBlockLatex extends React.Component dbStore.getRelationById(id)).map(it => it.relationKey) + const recommendedRelations = object.recommendedRelations.map(id => dbStore.getRelationById(id)).map(it => it.relationKey); menuStore.open('relationSuggest', { element: '#page .section.relation #item-add', diff --git a/webpack.node.config.js b/webpack.node.config.js index 0984baad63..6d06015a9f 100644 --- a/webpack.node.config.js +++ b/webpack.node.config.js @@ -1,7 +1,7 @@ module.exports = (env) => { return { - target: "node", - mode: "production", + target: 'node', + mode: 'production', optimization: { minimize: false, removeAvailableModules: false, @@ -11,7 +11,7 @@ module.exports = (env) => { entry: './electron.js', output: { - filename: "bundle-back.js" + filename: 'bundle-back.js' }, module: {