Pass eslint

This commit is contained in:
eight04 2021-12-12 23:38:17 +08:00
parent 92573307cd
commit 63e48099ad
8 changed files with 48 additions and 42 deletions

View File

@ -1,2 +0,0 @@
vendor/
vendor-overwrites/

2
.gitignore vendored
View File

@ -4,5 +4,7 @@ pull_locales_login.rb
node_modules/ node_modules/
yarn.lock yarn.lock
*.zip *.zip
*.log
*.swp
.eslintcache .eslintcache
.transifexrc .transifexrc

2
dist/edit.html vendored
View File

@ -21,7 +21,7 @@
<script src="edit/codemirror-themes.js"></script> <!-- must precede base.js --> <script src="edit/codemirror-themes.js"></script> <!-- must precede base.js -->
<script src="edit/base.js"></script> <script src="edit/base.js"></script>
<script src="codemirror/base.js"></script><script src="codemirror/edit.js"></script> <!-- codemirror-edit --> <script src="codemirror/base.js"></script><script src="codemirror/edit.js"></script> <!-- codemirror-edit -->
<script src="vendor-overwrites/codemirror-addon/match-highlighter.js"></script> <script src="vendor-overwrites/codemirror-addon/match-highlighter.js"></script>
<script src="vendor/lz-string-unsafe/lz-string-unsafe.min.js"></script> <script src="vendor/lz-string-unsafe/lz-string-unsafe.min.js"></script>

View File

@ -5,6 +5,7 @@
/* global prefs */ /* global prefs */
/* global preinit */ /* global preinit */
/* global t */// localization.js /* global t */// localization.js
/* global requireOrdered */// polyfill
'use strict'; 'use strict';
let cm; let cm;
@ -39,7 +40,7 @@ setTimeout(() => !cm && showSpinner($('#header')), 200);
} }
const scriptsReady = requireOrdered( const scriptsReady = requireOrdered(
/* global CodeMirror */ /* global CodeMirror */
["/codemirror/base.js"] // codemirror-base ["/codemirror/base.js"] // codemirror-base
).then(() => require([ ).then(() => require([
'/vendor/codemirror/keymap/emacs', '/vendor/codemirror/keymap/emacs',
'/vendor/codemirror/keymap/vim', // TODO: load conditionally '/vendor/codemirror/keymap/vim', // TODO: load conditionally

View File

@ -57,5 +57,11 @@
}, },
"webExt": { "webExt": {
"sourceDir": "dist" "sourceDir": "dist"
} },
"eslintIgnore": [
"dist/vendor/**",
"dist/vendor-overwrites/**",
"dist/chunks/*",
"dist/codemirror/*"
]
} }

View File

@ -1,19 +1,19 @@
import cjs from "rollup-plugin-cjs-es"; import cjs from 'rollup-plugin-cjs-es';
import resolve from "@rollup/plugin-node-resolve"; import resolve from '@rollup/plugin-node-resolve';
import iife from "rollup-plugin-iife"; import iife from 'rollup-plugin-iife';
import { terser } from "rollup-plugin-terser"; import {terser} from 'rollup-plugin-terser';
import output from "rollup-plugin-write-output"; import output from 'rollup-plugin-write-output';
import escapeRe from 'escape-string-regexp'; import escapeRe from 'escape-string-regexp';
export default { export default {
input: { input: {
"codemirror/base": "src/codemirror/base.mjs", 'codemirror/base': 'src/codemirror/base.mjs',
"codemirror/edit": "src/codemirror/edit.mjs" 'codemirror/edit': 'src/codemirror/edit.mjs',
}, },
output: { output: {
dir: "dist", dir: 'dist',
chunkFileNames: 'chunks/[name]-[hash].js' chunkFileNames: 'chunks/[name]-[hash].js',
}, },
plugins: [ plugins: [
resolve(), resolve(),
@ -24,17 +24,17 @@ export default {
{ {
test: /codemirror\/edit\.js/, test: /codemirror\/edit\.js/,
target: 'dist/edit.html', target: 'dist/edit.html',
handle: (content, {htmlScripts}) => replaceLine(content, '<!-- codemirror-edit -->', htmlScripts) handle: (content, {htmlScripts}) => replaceLine(content, '<!-- codemirror-edit -->', htmlScripts),
}, },
{ {
test: /codemirror\/base\.js/, test: /codemirror\/base\.js/,
target: 'dist/install-usercss/install-usercss.js', target: 'dist/install-usercss/install-usercss.js',
handle: (content, {scripts}) => replaceLine(content, '// codemirror-base', 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) { function resolvePath(base) {
@ -46,5 +46,5 @@ function resolvePath(base) {
} }
function replaceLine(content, marker, repl) { function replaceLine(content, marker, repl) {
return content.replace(new RegExp(`.*${escapeRe(marker)}`), `${repl} ${marker}`); return content.replace(new RegExp(`\\S.*${escapeRe(marker)}`), `${repl} ${marker}`);
} }

View File

@ -1,14 +1,13 @@
import CodeMirror from "codemirror/lib/codemirror.js"; import CodeMirror from 'codemirror/lib/codemirror.js';
import "codemirror/mode/css/css.js"; import 'codemirror/mode/css/css.js';
import "codemirror/keymap/sublime.js"; import 'codemirror/keymap/sublime.js';
import "codemirror/addon/search/searchcursor.js"; import 'codemirror/addon/search/searchcursor.js';
import "codemirror/addon/search/matchesonscrollbar.js"; import 'codemirror/addon/search/matchesonscrollbar.js';
import "codemirror/addon/fold/foldcode.js"; import 'codemirror/addon/fold/foldcode.js';
import "codemirror/addon/fold/foldgutter.js"; import 'codemirror/addon/fold/foldgutter.js';
import "codemirror/addon/fold/brace-fold.js"; import 'codemirror/addon/fold/brace-fold.js';
import "codemirror/addon/fold/indent-fold.js"; import 'codemirror/addon/fold/indent-fold.js';
import "codemirror/addon/fold/comment-fold.js"; import 'codemirror/addon/fold/comment-fold.js';
import "codemirror/addon/selection/active-line.js"; import 'codemirror/addon/selection/active-line.js';
window.CodeMirror = CodeMirror; window.CodeMirror = CodeMirror;

View File

@ -1,10 +1,10 @@
import "./base.mjs"; import './base.mjs';
import "codemirror/mode/stylus/stylus.js"; import 'codemirror/mode/stylus/stylus.js';
import "codemirror/addon/dialog/dialog.js"; import 'codemirror/addon/dialog/dialog.js';
import "codemirror/addon/scroll/annotatescrollbar.js"; import 'codemirror/addon/scroll/annotatescrollbar.js';
import "codemirror/addon/comment/comment.js"; import 'codemirror/addon/comment/comment.js';
import "codemirror/addon/edit/closebrackets.js"; import 'codemirror/addon/edit/closebrackets.js';
import "codemirror/addon/edit/matchbrackets.js"; import 'codemirror/addon/edit/matchbrackets.js';
import "codemirror/addon/lint/lint.js"; import 'codemirror/addon/lint/lint.js';
import "codemirror/addon/hint/show-hint.js"; import 'codemirror/addon/hint/show-hint.js';
import "codemirror/addon/hint/css-hint.js"; import 'codemirror/addon/hint/css-hint.js';