From 638202d643f6837ae87f7a7b77fd6e45fa5e0ced Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Wed, 3 Nov 2021 15:50:40 -0700 Subject: [PATCH] chore: upgrade eslint config --- .eslintignore | 4 +- .eslintrc.json | 21 +-- .gitignore | 128 ++---------------- .lintstagedrc | 5 - .lintstagedrc.json | 5 + packages/runtime/src/dom/hydrate.ts | 3 + packages/runtime/src/html/dynamic-tag.ts | 1 + packages/runtime/src/html/writer.ts | 2 + packages/translator/src/analyze/references.ts | 1 + packages/translator/src/util/runtime.ts | 1 + 10 files changed, 37 insertions(+), 134 deletions(-) delete mode 100644 .lintstagedrc create mode 100644 .lintstagedrc.json diff --git a/.eslintignore b/.eslintignore index 5f450134b..181a39ff4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,6 @@ -*actual* -*expected* +.vscode .nyc_output node_modules coverage dist +__snapshots__ diff --git a/.eslintrc.json b/.eslintrc.json index 968552699..a0a4b6761 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,20 +2,14 @@ "root": true, "extends": ["eslint:recommended", "prettier"], "parserOptions": { - "ecmaVersion": 2018, "sourceType": "module", - "ecmaFeatures": { - "jsx": false - } - }, - "rules": { - "no-console": "off" + "impliedStrict": true }, "env": { - "browser": true, "node": true, - "es6": true, - "mocha": true + "mocha": true, + "es2020": true, + "browser": true }, "overrides": [ { @@ -27,13 +21,12 @@ "prettier" ], "rules": { - "no-prototype-builtins": "off", - "no-constant-condition": "off", - "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-var-requires": "off" + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-namespace": "off" } } ] diff --git a/.gitignore b/.gitignore index 51ac21c81..361505dd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,117 +1,19 @@ -### Project ### -*.marko.js -*actual* +# Editor +*.sublime* +.vscode + +# OSX +*.DS_Store + +# NPM +node_modules +npm-debug.log + +# Build dist +*.actual.* *.tsbuildinfo -### Node ### -# Logs -logs -*.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage +# Coverage .nyc_output - -# Dependency directories -node_modules - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn -.yarn-integrity - -# Npm -package-lock.json - -# dotenv environment variables file -.env -.env.test - -### Git ### -# Created by git for backups. To disable backups in Git: -# $ git config --global mergetool.keepBackup false -*.orig - -# Created by git when using merge tools for conflicts -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* -*_BACKUP_*.txt -*_BASE_*.txt -*_LOCAL_*.txt -*_REMOTE_*.txt - -### OS ### - -# Linux -*~ -.fuse_hidden* -.directory -.Trash-* -.nfs* - -# Mac -.DS_Store -.AppleDouble -.LSOverride -._* -Icon - -# Windows -*[Tt]humbs*.db* -[Dd]esktop.ini -*.stackdump -*.lnk - -### EDITOR ### - -# VisualStudioCode -.vscode -.history - -# JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -*.iml -*.ipr -*.iws -modules.xml -.idea - -# SublimeText -*.cache -*.sublime-* -Package Control.* -oscrypto-ca-bundle.crt - -# TextMate -*.tmproj -*.tmproject -tmtags - -# Vim -*.swp -*.vim -.netrwhist +coverage diff --git a/.lintstagedrc b/.lintstagedrc deleted file mode 100644 index c64d72821..000000000 --- a/.lintstagedrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "*.{json,md}": ["prettier --write"], - "*.{js,ts}": ["eslint --fix", "prettier --write"], - "./{,packages/*/}package.json": ["fixpack"] -} diff --git a/.lintstagedrc.json b/.lintstagedrc.json new file mode 100644 index 000000000..eda6e7032 --- /dev/null +++ b/.lintstagedrc.json @@ -0,0 +1,5 @@ +{ + "*.ts": ["eslint --fix", "prettier --write"], + "*{.js,.json,.md,.yml,rc}": ["prettier --write"], + "./{,packages/*/}package.json": ["fixpack"] +} diff --git a/packages/runtime/src/dom/hydrate.ts b/packages/runtime/src/dom/hydrate.ts index b136b18eb..83a039058 100644 --- a/packages/runtime/src/dom/hydrate.ts +++ b/packages/runtime/src/dom/hydrate.ts @@ -69,6 +69,7 @@ export function init(runtimeId = "M" /* [a-zA-Z0-9]+ */) { const token = nodeValue[runtimeLength]; const data = nodeValue.slice(runtimeLength + 1); if (token === HydrateSymbols.SCOPE_OFFSET) { + // eslint-disable-next-line no-constant-condition if ("MARKO_DEBUG") { const [offset, scopeId, index] = data.split(" "); if (scopeId !== currentScope[ScopeOffsets.ID]) { @@ -93,6 +94,7 @@ export function init(runtimeId = "M" /* [a-zA-Z0-9]+ */) { } currentScope[ScopeOffsets.START_NODE] = currentNode; } else if (token === HydrateSymbols.SCOPE_END) { + // eslint-disable-next-line no-constant-condition if ("MARKO_DEBUG") { if (data !== currentScope[ScopeOffsets.ID]) { throw new Error("SCOPE_END_MISMATCH: " + nodeValue); @@ -101,6 +103,7 @@ export function init(runtimeId = "M" /* [a-zA-Z0-9]+ */) { currentScope[ScopeOffsets.END_NODE] = currentNode; currentOffset = stack.pop() as number; currentScope = scopeLookup.get(stack.pop() as string)!; + // eslint-disable-next-line no-constant-condition } else if ("MARKO_DEBUG") { throw new Error("MALFORMED MARKER: " + nodeValue); } diff --git a/packages/runtime/src/html/dynamic-tag.ts b/packages/runtime/src/html/dynamic-tag.ts index a8eab511a..e2a68f31e 100644 --- a/packages/runtime/src/html/dynamic-tag.ts +++ b/packages/runtime/src/html/dynamic-tag.ts @@ -64,6 +64,7 @@ export function dynamicTag( : { renderBody, ...input } : input ); + // eslint-disable-next-line no-constant-condition } else if ("MARKO_DEBUG") { throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`); } diff --git a/packages/runtime/src/html/writer.ts b/packages/runtime/src/html/writer.ts index 0ee6b9913..c7322f236 100644 --- a/packages/runtime/src/html/writer.ts +++ b/packages/runtime/src/html/writer.ts @@ -247,6 +247,7 @@ const lastIndex = new WeakMap(); export function markScopeOffset(index: number, scope: Scope) { const offset = index - (lastIndex.get(scope) || 0); lastIndex.set(scope, index); + // eslint-disable-next-line no-constant-condition if ("MARKO_DEBUG") { return `; let curAccessor = accessor; + // eslint-disable-next-line no-constant-condition while (true) { const parentPath = curPath.parentPath!; diff --git a/packages/translator/src/util/runtime.ts b/packages/translator/src/util/runtime.ts index 23f73acaa..de4f4bd75 100644 --- a/packages/translator/src/util/runtime.ts +++ b/packages/translator/src/util/runtime.ts @@ -47,6 +47,7 @@ function getRuntime( function getRuntimePath(path: t.NodePath, output: string) { const { optimize } = getMarkoOpts(path); return `@marko/runtime-fluurt/${ + // eslint-disable-next-line no-constant-condition "MARKO_SRC" ? "src" : optimize ? "dist" : "dist/debug" }/${output}`; }