From 11779801728074a514b3150c091ced8028779a74 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Wed, 28 Jun 2023 16:44:18 -0400 Subject: [PATCH] Fix basic eslint errors --- styles/.eslintrc.js | 39 ++++++++-- styles/package-lock.json | 128 ++++++++++++++++++++++++++++++++ styles/package.json | 1 + styles/src/buildThemes.ts | 10 +-- styles/src/styleTree/search.ts | 4 +- styles/src/styleTree/welcome.ts | 6 +- styles/src/types/element.ts | 2 +- styles/src/types/util.ts | 2 +- 8 files changed, 173 insertions(+), 19 deletions(-) diff --git a/styles/.eslintrc.js b/styles/.eslintrc.js index 40800d315c..4cb655c9da 100644 --- a/styles/.eslintrc.js +++ b/styles/.eslintrc.js @@ -1,8 +1,21 @@ module.exports = { - plugins: ["import"], - parser: "@typescript-eslint/parser", - parserOptions: { - sourceType: "module" + 'env': { + "node": true + }, + 'extends': [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended' + ], + 'parser': '@typescript-eslint/parser', + 'parserOptions': { + 'ecmaVersion': 'latest', + 'sourceType': 'module' + }, + 'plugins': [ + '@typescript-eslint', 'import' + ], + globals: { + module: true }, "settings": { "import/parsers": { @@ -14,11 +27,23 @@ module.exports = { } } }, - rules: { + 'rules': { + 'indent': [ + 'error', + 4 + ], + 'linebreak-style': [ + 'error', + 'unix' + ], + 'semi': [ + 'error', + 'never' + ], "import/no-restricted-paths": [ - warn, + 'error', { - zones: [ + 'zones': [ { "target": "./src/types/*", "from": "./src", diff --git a/styles/package-lock.json b/styles/package-lock.json index e5a761b2a2..b6f14480f5 100644 --- a/styles/package-lock.json +++ b/styles/package-lock.json @@ -25,6 +25,7 @@ "vitest": "^0.32.0" }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.60.1", "@typescript-eslint/parser": "^5.60.1", "@vitest/coverage-v8": "^0.32.0", "eslint": "^8.43.0", @@ -402,6 +403,46 @@ "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz", "integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==" }, + "node_modules/@types/semver": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.0.tgz", + "integrity": "sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==", + "dev": true + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.60.1.tgz", + "integrity": "sha512-KSWsVvsJsLJv3c4e73y/Bzt7OpqMCADUO846bHcuWYSYM19bldbAeDv7dYyV0jwkbMfJ2XdlzwjhXtuD7OY6bw==", + "dev": true, + "dependencies": { + "@eslint-community/regexpp": "^4.4.0", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/type-utils": "5.60.1", + "@typescript-eslint/utils": "5.60.1", + "debug": "^4.3.4", + "grapheme-splitter": "^1.0.4", + "ignore": "^5.2.0", + "natural-compare-lite": "^1.4.0", + "semver": "^7.3.7", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^5.0.0", + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@typescript-eslint/parser": { "version": "5.60.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.60.1.tgz", @@ -446,6 +487,33 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@typescript-eslint/type-utils": { + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.60.1.tgz", + "integrity": "sha512-vN6UztYqIu05nu7JqwQGzQKUJctzs3/Hg7E2Yx8rz9J+4LgtIDFWjjl1gm3pycH0P3mHAcEUBd23LVgfrsTR8A==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "5.60.1", + "@typescript-eslint/utils": "5.60.1", + "debug": "^4.3.4", + "tsutils": "^3.21.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/@typescript-eslint/types": { "version": "5.60.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.60.1.tgz", @@ -486,6 +554,54 @@ } } }, + "node_modules/@typescript-eslint/utils": { + "version": "5.60.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.60.1.tgz", + "integrity": "sha512-tiJ7FFdFQOWssFa3gqb94Ilexyw0JVxj6vBzaSpfN/8IhoKkDuSAenUKvsSHw2A/TMpJb26izIszTXaqygkvpQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@types/json-schema": "^7.0.9", + "@types/semver": "^7.3.12", + "@typescript-eslint/scope-manager": "5.60.1", + "@typescript-eslint/types": "5.60.1", + "@typescript-eslint/typescript-estree": "5.60.1", + "eslint-scope": "^5.1.1", + "semver": "^7.3.7" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@typescript-eslint/utils/node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, "node_modules/@typescript-eslint/visitor-keys": { "version": "5.60.1", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.60.1.tgz", @@ -2104,6 +2220,12 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, + "node_modules/grapheme-splitter": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", + "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "dev": true + }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -2972,6 +3094,12 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/natural-compare-lite": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", + "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", + "dev": true + }, "node_modules/next-tick": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz", diff --git a/styles/package.json b/styles/package.json index 19a77d4dbf..e21840e613 100644 --- a/styles/package.json +++ b/styles/package.json @@ -35,6 +35,7 @@ "tabWidth": 4 }, "devDependencies": { + "@typescript-eslint/eslint-plugin": "^5.60.1", "@typescript-eslint/parser": "^5.60.1", "@vitest/coverage-v8": "^0.32.0", "eslint": "^8.43.0", diff --git a/styles/src/buildThemes.ts b/styles/src/buildThemes.ts index 8d807d62f3..7d831ee42e 100644 --- a/styles/src/buildThemes.ts +++ b/styles/src/buildThemes.ts @@ -24,11 +24,11 @@ function clearThemes(themeDirectory: string) { function writeThemes(colorSchemes: ColorScheme[], outputDirectory: string) { clearThemes(outputDirectory) - for (let colorScheme of colorSchemes) { - let styleTree = snakeCase(app(colorScheme)) - let styleTreeJSON = JSON.stringify(styleTree, null, 2) - let tempPath = path.join(tempDirectory, `${colorScheme.name}.json`) - let outPath = path.join(outputDirectory, `${colorScheme.name}.json`) + for (const colorScheme of colorSchemes) { + const styleTree = snakeCase(app(colorScheme)) + const styleTreeJSON = JSON.stringify(styleTree, null, 2) + const tempPath = path.join(tempDirectory, `${colorScheme.name}.json`) + const outPath = path.join(outputDirectory, `${colorScheme.name}.json`) fs.writeFileSync(tempPath, styleTreeJSON) fs.renameSync(tempPath, outPath) console.log(`- ${outPath} created`) diff --git a/styles/src/styleTree/search.ts b/styles/src/styleTree/search.ts index b471e6cbda..9a86d1d558 100644 --- a/styles/src/styleTree/search.ts +++ b/styles/src/styleTree/search.ts @@ -3,8 +3,8 @@ import { withOpacity } from "../theme/color" import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" -export default function search(colorScheme: ColorScheme) { - let layer = colorScheme.highest +export default function search(colorScheme: ColorScheme): unknown { + const layer = colorScheme.highest // Search input const editor = { diff --git a/styles/src/styleTree/welcome.ts b/styles/src/styleTree/welcome.ts index 311ff6daff..3b3eeba53a 100644 --- a/styles/src/styleTree/welcome.ts +++ b/styles/src/styleTree/welcome.ts @@ -11,9 +11,9 @@ import { import { interactive } from "../element" export default function welcome(colorScheme: ColorScheme) { - let layer = colorScheme.highest + const layer = colorScheme.highest - let checkboxBase = { + const checkboxBase = { cornerRadius: 4, padding: { left: 3, @@ -30,7 +30,7 @@ export default function welcome(colorScheme: ColorScheme) { }, } - let interactive_text_size: TextProperties = { size: "sm" } + const interactive_text_size: TextProperties = { size: "sm" } return { pageWidth: 320, diff --git a/styles/src/types/element.ts b/styles/src/types/element.ts index 719fe38203..6f6bb91e58 100644 --- a/styles/src/types/element.ts +++ b/styles/src/types/element.ts @@ -1,4 +1,4 @@ -import { Clean } from "./util"; +import { Clean } from "./util" import * as zed from './zed' export type Text = Clean diff --git a/styles/src/types/util.ts b/styles/src/types/util.ts index 3fa2f0eb25..851acd4b18 100644 --- a/styles/src/types/util.ts +++ b/styles/src/types/util.ts @@ -1,6 +1,6 @@ export type Prettify = { [K in keyof T]: T[K]; -} & {}; +} & unknown; /** * Clean removes the [k: string]: unknown property from an object,