Skip to content

Commit

Permalink
other: #217 configure linter formatter (#218)
Browse files Browse the repository at this point in the history
* other: #217 🔹 configure formatter

* other: #217 🔹 configure linter

* other: #217 🔹 configure lint staged
  • Loading branch information
ubugeeei authored Jan 3, 2024
1 parent e6a7ad5 commit abb9f68
Show file tree
Hide file tree
Showing 2,653 changed files with 70,455 additions and 69,889 deletions.
1 change: 1 addition & 0 deletions .eslintcache

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
temp
coverage
16 changes: 16 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { builtinModules } = require('node:module')

/**
* @type {import('eslint-define-config').ESLintConfig}
*/
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
},
plugins: ['import', '@typescript-eslint'],
rules: {
'no-debugger': 'error',
'sort-imports': ['error', { ignoreDeclarationSort: true }],
},
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
book/images
book/online-book/cache

dist
*.md
*.html
pnpm-lock.yaml
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"arrowParens": "avoid"
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lightningcss",
"nocheck",
"paren",
"Parens",
"RAWTEXT",
"RCDATA",
"tokei",
Expand All @@ -34,4 +35,4 @@
"@extensions": "lib"
},
"material-icon-theme.files.associations": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { helloChibivue } from "chibivue";
import { helloChibivue } from 'chibivue'

helloChibivue();
helloChibivue()
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ESNext",
"DOM"
],
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
Expand All @@ -18,12 +15,8 @@
"noImplicitReturns": true,
"skipLibCheck": true,
"paths": {
"chibivue": [
"../../packages"
],
"chibivue": ["../../packages"]
}
},
"include": [
"src"
]
}
"include": ["src"]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from "vite";
import { defineConfig } from 'vite'

export default defineConfig({
resolve: {
alias: {
chibivue: `${process.cwd()}/../../packages`,
},
},
});
})
2 changes: 1 addition & 1 deletion book/impls/00_introduction/010_project_setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"devDependencies": {
"@types/node": "^18.15.11"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const helloChibivue = () => {
console.log("Hello chibivue!");
};
console.log('Hello chibivue!')
}
20 changes: 5 additions & 15 deletions book/impls/00_introduction/010_project_setup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"lib": [
"DOM"
],
"lib": ["DOM"],
"strict": true,
"paths": {
"chibivue": [
"./packages"
]
"chibivue": ["./packages"]
},
"moduleResolution": "node",
"allowJs": true,
"esModuleInterop": true
},
"include": [
"packages/**/*.ts",
"examples/**/**.ts"
],
"exclude": [
"node_modules",
"dist"
]
}
"include": ["packages/**/*.ts", "examples/**/**.ts"],
"exclude": ["node_modules", "dist"]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createApp } from "chibivue";
import { createApp } from 'chibivue'

const app = createApp({
render() {
return "Hello world.";
return 'Hello world.'
},
});
})

app.mount("#app");
app.mount('#app')
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ESNext",
"DOM"
],
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
Expand All @@ -18,12 +15,8 @@
"noImplicitReturns": true,
"skipLibCheck": true,
"paths": {
"chibivue": [
"../../packages"
],
"chibivue": ["../../packages"]
}
},
"include": [
"src"
]
}
"include": ["src"]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from "vite";
import { defineConfig } from 'vite'

export default defineConfig({
resolve: {
alias: {
chibivue: `${process.cwd()}/../../packages`,
},
},
});
})
2 changes: 1 addition & 1 deletion book/impls/10_minimum_example/010_create_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"devDependencies": {
"@types/node": "^18.15.11"
}
}
}
18 changes: 9 additions & 9 deletions book/impls/10_minimum_example/010_create_app/packages/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
export type Options = {
render: () => string;
};
render: () => string
}

export type App = {
mount: (selector: string) => void;
};
mount: (selector: string) => void
}

export const createApp = (options: Options): App => {
return {
mount: (selector) => {
const root = document.querySelector(selector);
mount: selector => {
const root = document.querySelector(selector)
if (root) {
root.innerHTML = options.render();
root.innerHTML = options.render()
}
},
};
};
}
}
20 changes: 5 additions & 15 deletions book/impls/10_minimum_example/010_create_app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@
"compilerOptions": {
"target": "ES2020",
"module": "ES2020",
"lib": [
"DOM"
],
"lib": ["DOM"],
"strict": true,
"paths": {
"chibivue": [
"./packages"
]
"chibivue": ["./packages"]
},
"moduleResolution": "node",
"allowJs": true,
"esModuleInterop": true
},
"include": [
"packages/**/*.ts",
"examples/**/**.ts"
],
"exclude": [
"node_modules",
"dist"
]
}
"include": ["packages/**/*.ts", "examples/**/**.ts"],
"exclude": ["node_modules", "dist"]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createApp } from "chibivue";
import { createApp } from 'chibivue'

const app = createApp({
render() {
return "Hello world.";
return 'Hello world.'
},
});
})

app.mount("#app");
app.mount('#app')
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ESNext",
"DOM"
],
"lib": ["ESNext", "DOM"],
"moduleResolution": "Node",
"strict": true,
"resolveJsonModule": true,
Expand All @@ -18,12 +15,8 @@
"noImplicitReturns": true,
"skipLibCheck": true,
"paths": {
"chibivue": [
"../../packages"
],
"chibivue": ["../../packages"]
}
},
"include": [
"src"
]
}
"include": ["src"]
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineConfig } from "vite";
import { defineConfig } from 'vite'

export default defineConfig({
resolve: {
alias: {
chibivue: `${process.cwd()}/../../packages`,
},
},
});
})
2 changes: 1 addition & 1 deletion book/impls/10_minimum_example/010_create_app2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
"devDependencies": {
"@types/node": "^18.15.11"
}
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./runtime-dom";
export * from './runtime-dom'
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { Component } from "./component";
import { RootRenderFunction } from "./renderer";
import { Component } from './component'
import { RootRenderFunction } from './renderer'

export interface App<HostElement = any> {
mount(rootContainer: HostElement | string): void;
mount(rootContainer: HostElement | string): void
}

export type CreateAppFunction<HostElement> = (
rootComponent: Component
) => App<HostElement>;
rootComponent: Component,
) => App<HostElement>

export function createAppAPI<HostElement>(
render: RootRenderFunction<HostElement>
render: RootRenderFunction<HostElement>,
): CreateAppFunction<HostElement> {
return function createApp(rootComponent) {
const app: App = {
mount(rootContainer: HostElement) {
const message = rootComponent.render!();
render(message, rootContainer);
const message = rootComponent.render!()
render(message, rootContainer)
},
};
}

return app;
};
return app
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { ComponentOptions } from "./componentOptions";
import { ComponentOptions } from './componentOptions'

export type Component = ComponentOptions;
export type Component = ComponentOptions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type ComponentOptions = {
render?: Function;
};
render?: Function
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type { App, CreateAppFunction } from "./apiCreateApp";
export { createAppAPI } from "./apiCreateApp";
export type { App, CreateAppFunction } from './apiCreateApp'
export { createAppAPI } from './apiCreateApp'

export type { RendererOptions } from "./renderer";
export { createRenderer } from "./renderer";
export type { RendererOptions } from './renderer'
export { createRenderer } from './renderer'
Loading

0 comments on commit abb9f68

Please sign in to comment.