Skip to content

Commit

Permalink
Update eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed Nov 16, 2023
1 parent 03507be commit 4d807c9
Show file tree
Hide file tree
Showing 145 changed files with 1,433 additions and 1,363 deletions.
50 changes: 45 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "no-only-tests", "eslint-comments"],
"plugins": ["@typescript-eslint", "no-only-tests", "eslint-comments", "@nothing-but"],
"ignorePatterns": ["node_modules", "dist", "scripts", "examples"],
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": ".",
"sourceType": "module"
},
"rules": {
"prefer-const": "warn",
/*
forgot to remove/implement
*/
"no-console": "warn",
"no-debugger": "warn",
"prefer-const": "warn",
"require-await": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
Expand All @@ -20,10 +24,46 @@
"caughtErrorsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
"@typescript-eslint/no-unnecessary-condition": "warn",
"@typescript-eslint/no-unnecessary-qualifier": "warn",
"@typescript-eslint/no-unnecessary-type-arguments": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "warn",
"@typescript-eslint/no-useless-empty-export": "warn",
"no-only-tests/no-only-tests": "warn",
"eslint-comments/no-unused-disable": "warn"
"@typescript-eslint/no-empty-function": "warn",
"no-empty": "warn",
"@typescript-eslint/no-unused-expressions": [
"warn",
{"allowShortCircuit": true, "allowTernary": true}
],
"eslint-comments/no-unused-disable": "warn",
/*
code style | readability
*/
// to many voids
// "@typescript-eslint/explicit-function-return-type": [
// "warn",
// {
// "allowExpressions": true,
// "allowTypedFunctionExpressions": true,
// "allowHigherOrderFunctions": true,
// "allowDirectConstAssertionInArrowFunctions": true,
// "allowConciseArrowFunctionExpressionsStartingWithVoid": true,
// "allowIIFEs": true
// }
// ],
/*
prevent unexpected behavior
*/
"@typescript-eslint/ban-types": "warn",
"@typescript-eslint/switch-exhaustiveness-check": "warn",
"no-fallthrough": ["warn", {"allowEmptyCase": true}],
// "@nothing-but/no-ignored-return": "warn",
// "@nothing-but/no-return-to-void": "warn",
/*
tests
*/
"no-only-tests/no-only-tests": "warn"
}
}
36 changes: 18 additions & 18 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"trailingComma": "all",
"tabWidth": 4,
"printWidth": 100,
"semi": false,
"singleQuote": true,
"useTabs": false,
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"plugins": ["prettier-plugin-organize-imports"],
"overrides": [
{
"files": "*.yml",
"options": {
"tabWidth": 2
}
}
]
"trailingComma": "all",
"tabWidth": 4,
"printWidth": 100,
"semi": false,
"singleQuote": true,
"useTabs": false,
"arrowParens": "avoid",
"bracketSpacing": false,
"endOfLine": "lf",
"plugins": ["prettier-plugin-organize-imports"],
"overrides": [
{
"files": "*.yml",
"options": {
"tabWidth": 2
}
}
]
}
28 changes: 14 additions & 14 deletions examples/sandbox/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {
Show,
Suspense,
} from 'solid-js'
import { createMutable } from 'solid-js/store'
import {createMutable} from 'solid-js/store'
import Recursive from './Recursive'
import { ThemeExample } from './Theme'
import {ThemeExample} from './Theme'
import Todos from './Todos'

const doMediumCalc = () => {
Array.from({ length: 1000000 }, (_, i) => i).sort(() => Math.random() - 5)
Array.from({length: 1000000}, (_, i) => i).sort(() => Math.random() - 5)
}

let setRootCount: Setter<number>
Expand Down Expand Up @@ -48,7 +48,7 @@ createRoot(dispose => {
}, undefined)
})

const Button = (props: { text: string; onClick: VoidFunction }) => {
const Button = (props: {text: string; onClick: VoidFunction}) => {
const text = createMemo(() => <span>{props.text}</span>)
return (
<button aria-label={props.text} onClick={props.onClick}>
Expand All @@ -62,7 +62,7 @@ const PassChildren: ParentComponent = props => props.children
const Article: Component = () => {
const state = createMutable({
count: 0,
other: { name: 'article' },
other: {name: 'article'},
content: {
title: 'A cool headline for testing :)',
body: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem odio culpa vel vitae? Quis deleniti soluta rem velit necessitatibus? ',
Expand All @@ -76,7 +76,7 @@ const Article: Component = () => {
await new Promise(r => setTimeout(r, 1000))
return `Article ${c}`
},
{ name: 'resource' },
{name: 'resource'},
)

return (
Expand Down Expand Up @@ -106,11 +106,11 @@ const DynamicSpreadParent = () => {
a: 1,
b: 2,
c: 3,
style: { width: '160px', height: '30px', background: '#fcb', color: 'black' },
style: {width: '160px', height: '30px', background: '#fcb', color: 'black'},
textContent: 'Before Change',
onclick: () =>
setProps({
style: { width: '160px', height: '30px', background: '#eba', color: 'black' },
style: {width: '160px', height: '30px', background: '#eba', color: 'black'},
textContent: 'After Change',
d: 4,
e: 5,
Expand All @@ -127,7 +127,7 @@ const Broken: Component = () => {
const App: Component = () => {
const [count, setCount] = createSignal(0)
const [showEven, setShowEven] = createSignal(false)
const fnSig = createSignal({ fn: () => {} }, { equals: (a, b) => a.fn === b.fn })
const fnSig = createSignal({fn: () => {}}, {equals: (a, b) => a.fn === b.fn})
const nullSig = createSignal(null)
const symbolSig = createSignal(Symbol('hello-symbol'))
const [header, setHeader] = createSignal(
Expand Down Expand Up @@ -155,10 +155,10 @@ const App: Component = () => {
return count()
},
undefined,
{ name: 'very-long-name-that-will-definitely-not-have-enough-space-to-render' },
{name: 'very-long-name-that-will-definitely-not-have-enough-space-to-render'},
)

createComputed(() => {}, undefined, { name: 'frozen' })
createComputed(() => {}, undefined, {name: 'frozen'})
createRenderEffect(() => {})

const Bold: ParentComponent = props => <b>{props.children}</b>
Expand All @@ -174,7 +174,7 @@ const App: Component = () => {
<Button onClick={() => setCount(p => ++p)} text={`Count: ${count()}`} />
<Button onClick={() => setCount(p => ++p)} text={`Count: ${count()}`} />
</header>
<div style={{ height: '1rem', 'margin-top': '1rem' }}>
<div style={{height: '1rem', 'margin-top': '1rem'}}>
<Show when={showEven()}>
{createComponent(() => {
return <Bold>{count()} is even!</Bold>
Expand Down Expand Up @@ -213,10 +213,10 @@ const App: Component = () => {
<button onClick={() => disposeOuterRoot()}>Dispose OUTSIDE_ROOT</button>
<Article />
<Todos />
<div style={{ margin: '24px' }}>
<div style={{margin: '24px'}}>
<CountingComponent />
</div>
<div style={{ margin: '24px' }}>
<div style={{margin: '24px'}}>
<ThemeExample />
</div>
<Recursive />
Expand Down
2 changes: 1 addition & 1 deletion examples/sandbox/src/DevtoolsOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { attachDevtoolsOverlay } from '@solid-devtools/overlay'
import {attachDevtoolsOverlay} from '@solid-devtools/overlay'

declare global {
interface Window {
Expand Down
2 changes: 1 addition & 1 deletion examples/sandbox/src/Overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Show, lazy } from 'solid-js'
import {Show, lazy} from 'solid-js'
const DevtoolsOverlay = lazy(() => import('./DevtoolsOverlay'))

export function Overlay() {
Expand Down
14 changes: 7 additions & 7 deletions examples/sandbox/src/Recursive.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, createContext, For, mergeProps, splitProps, useContext } from 'solid-js'
import { createStore } from 'solid-js/store'
import {Component, createContext, For, mergeProps, splitProps, useContext} from 'solid-js'
import {createStore} from 'solid-js/store'

type NodeType = {
id: number
Expand All @@ -14,7 +14,7 @@ interface genNodePathInterface {
parentsPath?: Array<number>
accessKey?: string
}
function genNodePath({ nodeId, parentsPath = [], accessKey = 'children' }: genNodePathInterface) {
function genNodePath({nodeId, parentsPath = [], accessKey = 'children'}: genNodePathInterface) {
let path = parentsPath.concat(nodeId)
let nodePath: Array<Function | string> = []
path.forEach(id => {
Expand Down Expand Up @@ -77,17 +77,17 @@ const Recursive: Component = props => {
{
id: 0,
children: [
{ id: 1, children: [{ id: 2, children: [] }] },
{ id: 3, children: [] },
{id: 1, children: [{id: 2, children: []}]},
{id: 3, children: []},
],
},
])

const addNode = (nodeId: number, parentsPath: number[]) => {
setData(
// @ts-ignore
...genNodePath({ nodeId, parentsPath }),
(children: any) => [...children, { id: ++id, children: [] }],
...genNodePath({nodeId, parentsPath}),
(children: any) => [...children, {id: ++id, children: []}],
)
}

Expand Down
8 changes: 4 additions & 4 deletions examples/sandbox/src/Theme.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, createContext, ParentComponent, useContext } from 'solid-js'
import { createStore } from 'solid-js/store'
import {Component, createContext, ParentComponent, useContext} from 'solid-js'
import {createStore} from 'solid-js/store'

export type ThemeContextState = {
readonly color: string
Expand Down Expand Up @@ -39,7 +39,7 @@ export const ThemeProvider: ParentComponent<{
const changeTitle = (title: string) => setTheme('title', title)

return (
<ThemeContext.Provider value={[theme, { changeColor, changeTitle }]}>
<ThemeContext.Provider value={[theme, {changeColor, changeTitle}]}>
{props.children}
</ThemeContext.Provider>
)
Expand All @@ -48,7 +48,7 @@ export const ThemeProvider: ParentComponent<{
export const useTheme = () => useContext(ThemeContext)

export const ThemeExample: Component = props => {
const [theme, { changeColor }] = useTheme()
const [theme, {changeColor}] = useTheme()

return (
<>
Expand Down
14 changes: 7 additions & 7 deletions examples/sandbox/src/Todos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
For,
Show,
} from 'solid-js'
import { createStore, produce, SetStoreFunction, Store, unwrap } from 'solid-js/store'
import {createStore, produce, SetStoreFunction, Store, unwrap} from 'solid-js/store'

export function createLocalStore<T extends object>(
name: string,
init: T,
): [Store<T>, SetStoreFunction<T>] {
const localState = localStorage.getItem(name)
// const localState = undefined
const [state, setState] = createStore<T>(localState ? JSON.parse(localState) : init, { name })
const [state, setState] = createStore<T>(localState ? JSON.parse(localState) : init, {name})
createEffect(() => localStorage.setItem(name, JSON.stringify(state)))
return [state, setState]
}
Expand All @@ -25,7 +25,7 @@ export function removeIndex<T>(array: readonly T[], index: number): T[] {
return [...array.slice(0, index), ...array.slice(index + 1)]
}

type TodoItem = { title: string; done: boolean }
type TodoItem = {title: string; done: boolean}

const Todo: Component<{
done: boolean
Expand Down Expand Up @@ -59,7 +59,7 @@ const Todos: Component = () => {
other: {
name: 'todos',
get newTitle() {
return { value: newTitle() }
return {value: newTitle()}
},
countOuter: {
countInner: {
Expand All @@ -69,7 +69,7 @@ const Todos: Component = () => {
},
})

const valuesInASignal = createMemo(() => ({ values: todos.values }))
const valuesInASignal = createMemo(() => ({values: todos.values}))

// @ts-ignore
setTodos('other', 'else', unwrap(todos.values))
Expand Down Expand Up @@ -103,7 +103,7 @@ const Todos: Component = () => {
<Show when={true} keyed>
{v => {
createRoot(d => {
createEffect(newTitle, undefined, { name: 'newTitle effect' })
createEffect(newTitle, undefined, {name: 'newTitle effect'})
})
return (
<form onSubmit={addTodo}>
Expand All @@ -120,7 +120,7 @@ const Todos: Component = () => {
</Show>
<For each={todos.values}>
{(todo, i) => {
createEffect(i, undefined, { name: 'todo index' })
createEffect(i, undefined, {name: 'todo index'})
return (
<Todo
{...todo}
Expand Down
6 changes: 3 additions & 3 deletions examples/sandbox/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from 'solid-js/web'
import {render} from 'solid-js/web'
import App from './App'
import { Overlay } from './Overlay'
import { ThemeProvider } from './Theme'
import {Overlay} from './Overlay'
import {ThemeProvider} from './Theme'

import 'uno.css'

Expand Down
6 changes: 3 additions & 3 deletions examples/sandbox/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import devtools from 'solid-devtools/vite'
import { presetTypography } from 'unocss'
import {presetTypography} from 'unocss'
import Unocss from 'unocss/vite'
import { defineConfig } from 'vite'
import {defineConfig} from 'vite'
import Inspect from 'vite-plugin-inspect'
import solid from 'vite-plugin-solid'

Expand All @@ -20,7 +20,7 @@ export default defineConfig(mode => {
componentLocation: true,
},
}),
solid({ hot: true, dev: true }),
solid({hot: true, dev: true}),
Unocss({
presets: [presetTypography()],
}),
Expand Down
8 changes: 4 additions & 4 deletions examples/start/src/components/comment.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, For, Show } from 'solid-js'
import { A } from 'solid-start'
import { IComment } from '~/types'
import {Component, For, Show} from 'solid-js'
import {A} from 'solid-start'
import {IComment} from '~/types'
import Toggle from './toggle'

const Comment: Component<{ comment: IComment }> = props => {
const Comment: Component<{comment: IComment}> = props => {
return (
<li class="comment">
<div class="by">
Expand Down
Loading

0 comments on commit 4d807c9

Please sign in to comment.