From 63e48099ad2bf8729d1f6025682d05038ac2606b Mon Sep 17 00:00:00 2001 From: eight04 Date: Sun, 12 Dec 2021 23:38:17 +0800 Subject: [PATCH] Pass eslint --- .eslintignore | 2 -- .gitignore | 2 ++ dist/edit.html | 2 +- dist/install-usercss/install-usercss.js | 3 ++- package.json | 8 ++++++- rollup.config.mjs | 30 ++++++++++++------------- src/codemirror/base.mjs | 23 +++++++++---------- src/codemirror/edit.mjs | 20 ++++++++--------- 8 files changed, 48 insertions(+), 42 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index a710e413..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -vendor/ -vendor-overwrites/ diff --git a/.gitignore b/.gitignore index b05c94c7..1911273a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,7 @@ pull_locales_login.rb node_modules/ yarn.lock *.zip +*.log +*.swp .eslintcache .transifexrc diff --git a/dist/edit.html b/dist/edit.html index 5962bcd0..d49b926d 100644 --- a/dist/edit.html +++ b/dist/edit.html @@ -21,7 +21,7 @@ - + diff --git a/dist/install-usercss/install-usercss.js b/dist/install-usercss/install-usercss.js index b977e471..e30f772b 100644 --- a/dist/install-usercss/install-usercss.js +++ b/dist/install-usercss/install-usercss.js @@ -5,6 +5,7 @@ /* global prefs */ /* global preinit */ /* global t */// localization.js +/* global requireOrdered */// polyfill 'use strict'; let cm; @@ -39,7 +40,7 @@ setTimeout(() => !cm && showSpinner($('#header')), 200); } const scriptsReady = requireOrdered( /* global CodeMirror */ -["/codemirror/base.js"] // codemirror-base + ["/codemirror/base.js"] // codemirror-base ).then(() => require([ '/vendor/codemirror/keymap/emacs', '/vendor/codemirror/keymap/vim', // TODO: load conditionally diff --git a/package.json b/package.json index 3f7e35e9..7c5e59c5 100644 --- a/package.json +++ b/package.json @@ -57,5 +57,11 @@ }, "webExt": { "sourceDir": "dist" - } + }, + "eslintIgnore": [ + "dist/vendor/**", + "dist/vendor-overwrites/**", + "dist/chunks/*", + "dist/codemirror/*" + ] } diff --git a/rollup.config.mjs b/rollup.config.mjs index 50d57060..a44d63ef 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,19 +1,19 @@ -import cjs from "rollup-plugin-cjs-es"; -import resolve from "@rollup/plugin-node-resolve"; -import iife from "rollup-plugin-iife"; -import { terser } from "rollup-plugin-terser"; -import output from "rollup-plugin-write-output"; +import cjs from 'rollup-plugin-cjs-es'; +import resolve from '@rollup/plugin-node-resolve'; +import iife from 'rollup-plugin-iife'; +import {terser} from 'rollup-plugin-terser'; +import output from 'rollup-plugin-write-output'; import escapeRe from 'escape-string-regexp'; export default { input: { - "codemirror/base": "src/codemirror/base.mjs", - "codemirror/edit": "src/codemirror/edit.mjs" + 'codemirror/base': 'src/codemirror/base.mjs', + 'codemirror/edit': 'src/codemirror/edit.mjs', }, output: { - dir: "dist", - chunkFileNames: 'chunks/[name]-[hash].js' + dir: 'dist', + chunkFileNames: 'chunks/[name]-[hash].js', }, plugins: [ resolve(), @@ -24,17 +24,17 @@ export default { { test: /codemirror\/edit\.js/, target: 'dist/edit.html', - handle: (content, {htmlScripts}) => replaceLine(content, '', htmlScripts) + handle: (content, {htmlScripts}) => replaceLine(content, '', htmlScripts), }, { test: /codemirror\/base\.js/, target: 'dist/install-usercss/install-usercss.js', handle: (content, {scripts}) => replaceLine(content, '// codemirror-base', - JSON.stringify(scripts.map(resolvePath('/install-usercss/install-usercss.js')))) - } - ]) + JSON.stringify(scripts.map(resolvePath('/install-usercss/install-usercss.js')))), + }, + ]), ], - preserveEntrySignatures: false + preserveEntrySignatures: false, }; function resolvePath(base) { @@ -46,5 +46,5 @@ function resolvePath(base) { } function replaceLine(content, marker, repl) { - return content.replace(new RegExp(`.*${escapeRe(marker)}`), `${repl} ${marker}`); + return content.replace(new RegExp(`\\S.*${escapeRe(marker)}`), `${repl} ${marker}`); } diff --git a/src/codemirror/base.mjs b/src/codemirror/base.mjs index f747071e..e56e9841 100644 --- a/src/codemirror/base.mjs +++ b/src/codemirror/base.mjs @@ -1,14 +1,13 @@ -import CodeMirror from "codemirror/lib/codemirror.js"; -import "codemirror/mode/css/css.js"; -import "codemirror/keymap/sublime.js"; -import "codemirror/addon/search/searchcursor.js"; -import "codemirror/addon/search/matchesonscrollbar.js"; -import "codemirror/addon/fold/foldcode.js"; -import "codemirror/addon/fold/foldgutter.js"; -import "codemirror/addon/fold/brace-fold.js"; -import "codemirror/addon/fold/indent-fold.js"; -import "codemirror/addon/fold/comment-fold.js"; -import "codemirror/addon/selection/active-line.js"; +import CodeMirror from 'codemirror/lib/codemirror.js'; +import 'codemirror/mode/css/css.js'; +import 'codemirror/keymap/sublime.js'; +import 'codemirror/addon/search/searchcursor.js'; +import 'codemirror/addon/search/matchesonscrollbar.js'; +import 'codemirror/addon/fold/foldcode.js'; +import 'codemirror/addon/fold/foldgutter.js'; +import 'codemirror/addon/fold/brace-fold.js'; +import 'codemirror/addon/fold/indent-fold.js'; +import 'codemirror/addon/fold/comment-fold.js'; +import 'codemirror/addon/selection/active-line.js'; window.CodeMirror = CodeMirror; - diff --git a/src/codemirror/edit.mjs b/src/codemirror/edit.mjs index 68eef6d7..c4602907 100644 --- a/src/codemirror/edit.mjs +++ b/src/codemirror/edit.mjs @@ -1,10 +1,10 @@ -import "./base.mjs"; -import "codemirror/mode/stylus/stylus.js"; -import "codemirror/addon/dialog/dialog.js"; -import "codemirror/addon/scroll/annotatescrollbar.js"; -import "codemirror/addon/comment/comment.js"; -import "codemirror/addon/edit/closebrackets.js"; -import "codemirror/addon/edit/matchbrackets.js"; -import "codemirror/addon/lint/lint.js"; -import "codemirror/addon/hint/show-hint.js"; -import "codemirror/addon/hint/css-hint.js"; +import './base.mjs'; +import 'codemirror/mode/stylus/stylus.js'; +import 'codemirror/addon/dialog/dialog.js'; +import 'codemirror/addon/scroll/annotatescrollbar.js'; +import 'codemirror/addon/comment/comment.js'; +import 'codemirror/addon/edit/closebrackets.js'; +import 'codemirror/addon/edit/matchbrackets.js'; +import 'codemirror/addon/lint/lint.js'; +import 'codemirror/addon/hint/show-hint.js'; +import 'codemirror/addon/hint/css-hint.js';