-
-
Notifications
You must be signed in to change notification settings - Fork 945
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web: all aboard the anti-if bus, according to tooling (#10220)
* web: fix esbuild issue with style sheets Getting ESBuild, Lit, and Storybook to all agree on how to read and parse stylesheets is a serious pain. This fix better identifies the value types (instances) being passed from various sources in the repo to the three *different* kinds of style processors we're using (the native one, the polyfill one, and whatever the heck Storybook does internally). Falling back to using older CSS instantiating techniques one era at a time seems to do the trick. It's ugly, but in the face of the aggressive styling we use to avoid Flashes of Unstyled Content (FLoUC), it's the logic with which we're left. In standard mode, the following warning appears on the console when running a Flow: ``` Autofocus processing was blocked because a document already has a focused element. ``` In compatibility mode, the following **error** appears on the console when running a Flow: ``` crawler-inject.js:1106 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. at initDomMutationObservers (crawler-inject.js:1106:18) at crawler-inject.js:1114:24 at Array.forEach (<anonymous>) at initDomMutationObservers (crawler-inject.js:1114:10) at crawler-inject.js:1549:1 initDomMutationObservers @ crawler-inject.js:1106 (anonymous) @ crawler-inject.js:1114 initDomMutationObservers @ crawler-inject.js:1114 (anonymous) @ crawler-inject.js:1549 ``` Despite this error, nothing seems to be broken and flows work as anticipated. * web: all-aboard the anti-if bus, according to tooling This commit revises a number of bugs `eslint` has been complaining about for awhile now. This is the lesser of two PRs that will address this issue, and in this case the two biggest problems were inappropriate conditionals (using a `switch` for a single comparison), unnecessarily named returns, empty returns. This brings our use of conditions in-line with the coding standards we _say_ we want in eslintrc! * web: better names and logic for comparing the dates of Xliff vs generated files * Missed one. * Fixed a redirect issue that was creating an empty file in the ./web folder
- Loading branch information
1 parent
c0063c1
commit 085ab3c
Showing
13 changed files
with
114 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { execFileSync } from "child_process"; | ||
import { ESLint } from "eslint"; | ||
import path from "path"; | ||
import process from "process"; | ||
|
||
// Code assumes this script is in the './web/scripts' folder. | ||
const projectRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], { | ||
encoding: "utf8", | ||
}).replace("\n", ""); | ||
process.chdir(path.join(projectRoot, "./web")); | ||
|
||
const eslintConfig = { | ||
overrideConfig: { | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:lit/recommended", | ||
"plugin:custom-elements/recommended", | ||
"plugin:storybook/recommended", | ||
"plugin:sonarjs/recommended", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: "module", | ||
}, | ||
plugins: ["@typescript-eslint", "lit", "custom-elements", "sonarjs"], | ||
rules: { | ||
"indent": "off", | ||
"linebreak-style": ["error", "unix"], | ||
"quotes": ["error", "double", { avoidEscape: true }], | ||
"semi": ["error", "always"], | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"sonarjs/cognitive-complexity": ["error", 9], | ||
"sonarjs/no-duplicate-string": "off", | ||
"sonarjs/no-nested-template-literals": "off", | ||
}, | ||
}, | ||
}; | ||
|
||
const updated = ["./src/", "./build.mjs", "./scripts/*.mjs"]; | ||
|
||
const eslint = new ESLint(eslintConfig); | ||
const results = await eslint.lintFiles(updated); | ||
const formatter = await eslint.loadFormatter("stylish"); | ||
const resultText = formatter.format(results); | ||
const errors = results.reduce((acc, result) => acc + result.errorCount, 0); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(resultText); | ||
process.exit(errors > 1 ? 1 : 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters