Skip to content

Commit

Permalink
feat: migrated to new eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
manchenkoff committed May 29, 2024
1 parent 9b153ac commit b583cb7
Show file tree
Hide file tree
Showing 40 changed files with 2,115 additions and 1,251 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root = true

[*]
indent_size = 4
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
Expand Down
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

6 changes: 1 addition & 5 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ jobs:
- name: Install dependencies
run: ${{ env.install_command }}

- name: Run Prettier
run: |
${{ env.script_command }} fmt:check
- name: Run ESLint
run: |
${{ env.script_command }} lint
- name: Run TypeCheck
run: |
${{ env.script_command }} types
${{ env.script_command }} test:types
- name: Run tests
run: |
Expand Down
10 changes: 0 additions & 10 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// Enable ESlint flat config support
"eslint.experimental.useFlatConfig": true,
// Disable auto formatting on save
"editor.formatOnSave": false,
// Enable ESLint on save
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
}
17 changes: 17 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'

export default createConfigForNuxt({
features: {
tooling: true,
stylistic: true,
},
dirs: {
src: ['./playground'],
},
}).append({
rules: {
'vue/no-multiple-template-root': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
})
22 changes: 9 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
"lint": "eslint .",
"fmt": "prettier --write .",
"fmt:check": "prettier --check .",
"types": "nuxi typecheck",
"lint:fix": "eslint . --fix",
"test": "vitest run",
"test:watch": "vitest watch",
"validate": "npm run fmt:check && npm run lint && npm run types && npm run test",
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
"validate": "npm run lint && npm run test:types && npm run test",
"release": "npm run validate && npm run prepack && changelogen --release && npm publish && git push"
},
"dependencies": {
Expand All @@ -42,25 +41,22 @@
},
"devDependencies": {
"@nuxt/devtools": "latest",
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/module-builder": "^0.5.5",
"@nuxt/eslint-config": "^0.3.13",
"@nuxt/module-builder": "^0.7.0",
"@nuxt/schema": "^3.9.0",
"@nuxt/test-utils": "^3.9.0",
"@types/node": "^20.11.13",
"changelogen": "^0.5.5",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^9.3.0",
"h3": "^1.10.1",
"nuxi": "^3.10.0",
"nuxt": "^3.10.0",
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"typescript": "^5.4.5",
"vite": "^4.4.9",
"vitest": "^1.2.2",
"vue": "^3.3.4",
"vue-router": "^4.2.5",
"vue-tsc": "^1.8.26"
"vue-tsc": "^2.0.19"
},
"packageManager": "[email protected]"
}
}
44 changes: 22 additions & 22 deletions playground/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import type { NuxtApp } from '#app';
import type { FetchContext } from 'ofetch';
import type { ConsolaInstance } from 'consola';
import { defineAppConfig } from '#imports';
import type { FetchContext } from 'ofetch'
import type { ConsolaInstance } from 'consola'
import type { NuxtApp } from '#app'
import { defineAppConfig } from '#imports'

export default defineAppConfig({
sanctum: {
interceptors: {
onRequest: async (
app: NuxtApp,
ctx: FetchContext,
logger: ConsolaInstance
) => {
logger.debug('custom onRequest interceptor');
},
sanctum: {
interceptors: {
onRequest: async (
app: NuxtApp,
ctx: FetchContext,
logger: ConsolaInstance,
) => {
logger.debug('custom onRequest interceptor')
},

onResponse: async (
app: NuxtApp,
ctx: FetchContext,
logger: ConsolaInstance
) => {
logger.debug('custom onResponse interceptor');
},
},
onResponse: async (
app: NuxtApp,
ctx: FetchContext,
logger: ConsolaInstance,
) => {
logger.debug('custom onResponse interceptor')
},
},
});
},
})
6 changes: 3 additions & 3 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
73 changes: 44 additions & 29 deletions playground/error.vue
Original file line number Diff line number Diff line change
@@ -1,41 +1,56 @@
<script setup lang="ts">
import { useSanctumAuth } from '#imports';
import { useSanctumAuth } from '#imports'
interface ErrorProps {
error?: {
url: string;
statusCode: number;
statusMessage: string;
message: string;
description: string;
data?: any;
};
error?: {
url: string
statusCode: number
statusMessage: string
message: string
description: string
data?: any
}
}
const props = defineProps<ErrorProps>();
const props = defineProps<ErrorProps>()
const { isAuthenticated, logout } = useSanctumAuth();
const { isAuthenticated, logout } = useSanctumAuth()
</script>

<template>
<NuxtLoadingIndicator />

<h1>Nuxt - Laravel Sanctum application sample</h1>

<nav class="menu">
<NuxtLink to="/">Home</NuxtLink>
<NuxtLink to="/login">Login</NuxtLink>
<NuxtLink to="/logout">Logout</NuxtLink>
<NuxtLink to="/profile">Profile</NuxtLink>
<NuxtLink to="/welcome">Welcome</NuxtLink>

<button v-if="isAuthenticated" @click="logout">Logout</button>
</nav>

<hr />

<strong>Error</strong>
<p>{{ props.error }}</p>
<NuxtLoadingIndicator />

<h1>Nuxt - Laravel Sanctum application sample</h1>

<nav class="menu">
<NuxtLink to="/">
Home
</NuxtLink>
<NuxtLink to="/login">
Login
</NuxtLink>
<NuxtLink to="/logout">
Logout
</NuxtLink>
<NuxtLink to="/profile">
Profile
</NuxtLink>
<NuxtLink to="/welcome">
Welcome
</NuxtLink>

<button
v-if="isAuthenticated"
@click="logout"
>
Logout
</button>
</nav>

<hr>

<strong>Error</strong>
<p>{{ props.error }}</p>
</template>

<style scoped>
Expand Down
43 changes: 29 additions & 14 deletions playground/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
<script lang="ts" setup>
import { useSanctumAuth } from '#imports';
import { useSanctumAuth } from '#imports'
const { isAuthenticated, logout } = useSanctumAuth();
const { isAuthenticated, logout } = useSanctumAuth()
</script>

<template>
<NuxtLoadingIndicator />
<NuxtLoadingIndicator />

<h1>Nuxt - Laravel Sanctum application sample</h1>
<h1>Nuxt - Laravel Sanctum application sample</h1>

<nav class="menu">
<NuxtLink to="/">Home</NuxtLink>
<NuxtLink to="/login">Login</NuxtLink>
<NuxtLink to="/logout">Logout</NuxtLink>
<NuxtLink to="/profile">Profile</NuxtLink>
<NuxtLink to="/welcome">Welcome</NuxtLink>
<nav class="menu">
<NuxtLink to="/">
Home
</NuxtLink>
<NuxtLink to="/login">
Login
</NuxtLink>
<NuxtLink to="/logout">
Logout
</NuxtLink>
<NuxtLink to="/profile">
Profile
</NuxtLink>
<NuxtLink to="/welcome">
Welcome
</NuxtLink>

<button v-if="isAuthenticated" @click="logout">Logout</button>
</nav>
<button
v-if="isAuthenticated"
@click="logout"
>
Logout
</button>
</nav>

<hr />
<slot />
<hr>
<slot />
</template>

<style scoped>
Expand Down
61 changes: 34 additions & 27 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
export default defineNuxtConfig({
devtools: { enabled: true },
ssr: true,
typescript: {
strict: true,
typeCheck: true,
},
devtools: { enabled: true },
ssr: true,
typescript: {
strict: true,
typeCheck: true,
},

modules: ['../src/module'],
modules: ['../src/module'],

sanctum: {
baseUrl: 'http://localhost:80',
runtimeConfig: {
public: {
sanctum: {
logLevel: 5,
redirect: {
keepRequestedRoute: true,
onAuthOnly: '/login',
onGuestOnly: '/profile',
onLogin: '/welcome',
onLogout: '/logout',
},
endpoints: {
csrf: '/sanctum/csrf-cookie',
login: '/api/login',
logout: '/api/logout',
user: '/api/user',
},
globalMiddleware: {
allow404WithoutAuth: true,
enabled: false,
},
},
},
},

sanctum: {
baseUrl: 'http://localhost:80',
redirect: {
keepRequestedRoute: true,
onAuthOnly: '/login',
onGuestOnly: '/profile',
onLogin: '/welcome',
onLogout: '/logout',
},
endpoints: {
csrf: '/sanctum/csrf-cookie',
login: '/api/login',
logout: '/api/logout',
user: '/api/user',
},
globalMiddleware: {
allow404WithoutAuth: true,
enabled: false,
},
});
},
})
Loading

0 comments on commit b583cb7

Please sign in to comment.