Skip to content

Commit

Permalink
chore: apply eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
hannoeru committed Mar 13, 2022
1 parent f9a4c57 commit 54ef34f
Show file tree
Hide file tree
Showing 40 changed files with 388 additions and 283 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "@hannoeru"
"extends": "@hannoeru",
"rules": {
"react/function-component-definition": "off"
}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

lint:
runs-on: ubuntu-latest
name: "Lint: node-16, ubuntu-latest"
name: 'Lint: node-16, ubuntu-latest'
steps:
- name: Checkout repo
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish Package
on:
push:
tags:
- "v*"
- 'v*'

jobs:
publish-npm:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
}
77 changes: 39 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ npm install solid-app-router
Add to your `vite.config.js`:

```js
import Pages from "vite-plugin-pages";
import Pages from 'vite-plugin-pages'

export default {
plugins: [
// ...
Pages(),
],
};
}
```

## Overview
Expand All @@ -67,13 +67,13 @@ module in your application.
### Vue

```js
import { createRouter } from "vue-router";
import routes from "~pages";
import { createRouter } from 'vue-router'
import routes from '~pages'

const router = createRouter({
// ...
routes,
});
})
```

**Type**
Expand All @@ -89,8 +89,8 @@ const router = createRouter({

```js
import {
useRoutes,
BrowserRouter as Router,
useRoutes,
} from 'react-router-dom'

import routes from '~react-pages'
Expand Down Expand Up @@ -118,19 +118,20 @@ ReactDOM.render(

**experimental**

```js
```tsx
import { render } from 'solid-js/web'
import { Router, useRoutes } from 'solid-app-router'
import routes from '~solid-pages'

const Routes = useRoutes(routes)

render(
() => (
<Router>
<Routes />
</Router>
),
() => {
const Routes = useRoutes(routes)
return (
<Router>
<Routes />
</Router>
)
},
document.getElementById('root') as HTMLElement,
)
```
Expand All @@ -149,15 +150,15 @@ plugin:

```js
// vite.config.js
import Pages from "vite-plugin-pages";
import Pages from 'vite-plugin-pages'

export default {
plugins: [
Pages({
dirs: "src/views"
dirs: 'src/views',
}),
],
};
}
```

### dirs
Expand Down Expand Up @@ -200,13 +201,13 @@ export default {
plugins: [
Pages({
dirs: [
{ dir: "src/pages", baseRoute: "" },
{ dir: "src/features/**/pages", baseRoute: "features" },
{ dir: "src/admin/pages", baseRoute: "admin" },
{ dir: 'src/pages', baseRoute: '' },
{ dir: 'src/features/**/pages', baseRoute: 'features' },
{ dir: 'src/admin/pages', baseRoute: 'admin' },
],
}),
],
};
}
```

### extensions
Expand Down Expand Up @@ -242,10 +243,10 @@ src/pages/
export default {
plugins: [
Pages({
exclude: ["**/components/*.vue"],
exclude: ['**/components/*.vue'],
}),
],
};
}
```

### importMode
Expand All @@ -269,11 +270,11 @@ export default {
Pages({
importMode(path) {
// Load about page synchronously, all other pages are async.
return path.includes("about") ? "sync" : "async";
return path.includes('about') ? 'sync' : 'async'
},
}),
],
};
}
```

### routeBlockLang
Expand Down Expand Up @@ -316,20 +317,20 @@ export default {
plugins: [
Pages({
extendRoute(route, parent) {
if (route.path === "/") {
if (route.path === '/') {
// Index is unauthenticated.
return route;
return route
}

// Augment the route with meta that indicates that the route requires authentication.
return {
...route,
meta: { auth: true },
};
}
},
}),
],
};
}
```

### onRoutesGenerated
Expand Down Expand Up @@ -472,18 +473,18 @@ will result in this routes configuration:
```json5
[
{
path: '/users',
component: '/src/pages/users.vue',
children: [
"path": "/users",
"component": "/src/pages/users.vue",
"children": [
{
path: '',
component: '/src/pages/users/index.vue',
name: 'users'
"path": "",
"component": "/src/pages/users/index.vue",
"name": "users"
},
{
path: ':id',
component: '/src/pages/users/[id].vue',
name: 'users-id'
"path": ":id",
"component": "/src/pages/users/[id].vue",
"name": "users-id"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/react/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import {
useRoutes,
BrowserRouter as Router,
useRoutes,
} from 'react-router-dom'

import './index.css'
Expand Down
4 changes: 1 addition & 3 deletions examples/react/src/pages/blog/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { useParams } from 'react-router-dom'
const Component: React.FC = () => {
const { id } = useParams()
return (
<>
<p>blog/[id].tsx: { id }</p>
</>
<p>blog/[id].tsx: { id }</p>
)
}

Expand Down
2 changes: 1 addition & 1 deletion examples/remix-style/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import {
useRoutes,
BrowserRouter as Router,
useRoutes,
} from 'react-router-dom'

import './index.css'
Expand Down
2 changes: 1 addition & 1 deletion examples/remix-style/src/pages/__marketing/product.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
const Component: React.FC = () => {
return (
<div>
<p>__marketing/product.tsx</p>
<p>__marketing/product.tsx</p>
</div>
)
}
Expand Down
4 changes: 1 addition & 3 deletions examples/remix-style/src/pages/blog/$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { useParams } from 'react-router-dom'
const Component: React.FC = () => {
const { id } = useParams()
return (
<>
<p>blog/$id.tsx: { id }</p>
</>
<p>blog/$id.tsx: { id }</p>
)
}

Expand Down
4 changes: 1 addition & 3 deletions examples/remix-style/src/pages/blog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import React from 'react'

const Component: React.FC = () => {
return (
<>
<p>blog/index.tsx</p>
</>
<p>blog/index.tsx</p>
)
}

Expand Down
10 changes: 6 additions & 4 deletions examples/solid/src/admin/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function Index() {
return <>
<p>/admin/index.tsx</p>
<p>located in features /admin/pages folder</p>
</>
return (
<>
<p>/admin/index.tsx</p>
<p>located in features /admin/pages folder</p>
</>
)
}
10 changes: 6 additions & 4 deletions examples/solid/src/features/admin/pages/admin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function Admin() {
return <>
<p>features/admin/pages/admin.tsx</p>
<p>located in features/admin/pages folder</p>
</>
return (
<>
<p>features/admin/pages/admin.tsx</p>
<p>located in features/admin/pages folder</p>
</>
)
}
10 changes: 6 additions & 4 deletions examples/solid/src/features/dashboard/pages/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function Dashboard() {
return <>
<p>features/dashboard/pages/dashboard.tsx</p>
<p>located in features/dashboard/pages folder</p>
</>
return (
<>
<p>features/dashboard/pages/dashboard.tsx</p>
<p>located in features/dashboard/pages folder</p>
</>
)
}
10 changes: 6 additions & 4 deletions examples/solid/src/features/dashboard/pages/welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default function Welcome() {
return <>
<p>features/dashboard/pages/welcome.tsx</p>
<p>located in features/dashboard/pages folder</p>
</>
return (
<>
<p>features/dashboard/pages/welcome.tsx</p>
<p>located in features/dashboard/pages folder</p>
</>
)
}
15 changes: 8 additions & 7 deletions examples/solid/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { render } from 'solid-js/web'
import { Router, useRoutes } from 'solid-app-router'
import routes from '~solid-pages'

const Routes = useRoutes(routes)

render(
() => (
<Router>
<Routes />
</Router>
),
() => {
const Routes = useRoutes(routes)
return (
<Router>
<Routes />
</Router>
)
},
document.getElementById('root') as HTMLElement,
)
4 changes: 1 addition & 3 deletions examples/solid/src/pages/[...all].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export default function All() {
return <>
<div>...all route</div>
</>
return <div>...all route</div>
}
10 changes: 6 additions & 4 deletions examples/solid/src/pages/[sensor].tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Outlet } from 'solid-app-router'

export default function SensorLayout() {
return <>
nested dynamic view:
<Outlet />
</>
return (
<>
nested dynamic view:
<Outlet />
</>
)
}
6 changes: 2 additions & 4 deletions examples/solid/src/pages/[sensor]/current.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useParams } from 'solid-app-router'

export default function Current() {
const { sensor } = useParams < {sensor: string}>()
return <>
<p>/{ sensor}/current.tsx</p>
</>
const { sensor } = useParams < { sensor: string }>()
return <p>/{sensor}/current.tsx</p>
}
Loading

0 comments on commit 54ef34f

Please sign in to comment.