mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
chore(eslint): forbid modules importing from core (#556)
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
This commit is contained in:
parent
9503d62607
commit
eb794f3f85
24
.eslintrc
24
.eslintrc
@ -6,7 +6,8 @@
|
|||||||
"plugins": ["jsdoc"],
|
"plugins": ["jsdoc"],
|
||||||
"extends": [
|
"extends": [
|
||||||
"plugin:jsdoc/recommended",
|
"plugin:jsdoc/recommended",
|
||||||
"@nuxtjs/eslint-config-typescript"
|
"@nuxtjs/eslint-config-typescript",
|
||||||
|
"plugin:import/typescript"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
@ -15,7 +16,26 @@
|
|||||||
"jsdoc/require-jsdoc": "off",
|
"jsdoc/require-jsdoc": "off",
|
||||||
"jsdoc/require-param": "off",
|
"jsdoc/require-param": "off",
|
||||||
"jsdoc/require-returns": "off",
|
"jsdoc/require-returns": "off",
|
||||||
"jsdoc/require-param-type": "off"
|
"jsdoc/require-param-type": "off",
|
||||||
|
"import/no-restricted-paths": ["error", {
|
||||||
|
"zones": [
|
||||||
|
{
|
||||||
|
"target": "packages/nuxt3/src/!(core)/**/*",
|
||||||
|
"from": "packages/nuxt3/src/core",
|
||||||
|
"message": "core should not directly import from modules."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "packages/nuxt3/src/!(app)/**/*",
|
||||||
|
"from": "packages/nuxt3/src/app",
|
||||||
|
"message": "app should not directly import from modules."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "packages/nitro",
|
||||||
|
"from": "packages/!(nitro)/**/*",
|
||||||
|
"message": "nitro should not directly import other packages."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"jsdoc": {
|
"jsdoc": {
|
||||||
|
@ -3,8 +3,7 @@ import type { HookCallback } from 'hookable'
|
|||||||
import type { Compiler, Configuration, Stats } from 'webpack'
|
import type { Compiler, Configuration, Stats } from 'webpack'
|
||||||
import type { NuxtConfig, NuxtOptions } from '..'
|
import type { NuxtConfig, NuxtOptions } from '..'
|
||||||
import type { ModuleContainer } from '../module/container'
|
import type { ModuleContainer } from '../module/container'
|
||||||
import { NuxtTemplate } from '../types/nuxt'
|
import type { NuxtTemplate, Nuxt, NuxtApp } from '../types/nuxt'
|
||||||
import { Nuxt, NuxtApp } from './nuxt'
|
|
||||||
|
|
||||||
type HookResult = Promise<void> | void
|
type HookResult = Promise<void> | void
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): N
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaults.preset = input.preset || process.env.NITRO_PRESET || detectTarget() || 'server'
|
defaults.preset = input.preset || process.env.NITRO_PRESET || detectTarget() || 'server'
|
||||||
|
// eslint-disable-next-line import/namespace
|
||||||
let presetDefaults = PRESETS[defaults.preset] || tryImport(nuxtOptions.rootDir, defaults.preset)
|
let presetDefaults = PRESETS[defaults.preset] || tryImport(nuxtOptions.rootDir, defaults.preset)
|
||||||
if (!presetDefaults) {
|
if (!presetDefaults) {
|
||||||
throw new Error('Cannot resolve preset: ' + defaults.preset)
|
throw new Error('Cannot resolve preset: ' + defaults.preset)
|
||||||
|
@ -5,7 +5,7 @@ import { resolve, dirname } from 'pathe'
|
|||||||
import jiti from 'jiti'
|
import jiti from 'jiti'
|
||||||
import destr from 'destr'
|
import destr from 'destr'
|
||||||
import { splitByCase } from 'scule'
|
import { splitByCase } from 'scule'
|
||||||
import clipboardy from 'clipboardy'
|
import * as clipboardy from 'clipboardy'
|
||||||
import { defineNuxtCommand } from './index'
|
import { defineNuxtCommand } from './index'
|
||||||
|
|
||||||
export default defineNuxtCommand({
|
export default defineNuxtCommand({
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { createSSRApp, createApp, nextTick } from 'vue'
|
import { createSSRApp, createApp, nextTick } from 'vue'
|
||||||
import { createNuxt, applyPlugins, normalizePlugins, CreateOptions } from '#app'
|
import { createNuxtApp, applyPlugins, normalizePlugins, CreateOptions } from '#app'
|
||||||
import '#build/css'
|
import '#build/css'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import _plugins from '#build/plugins'
|
import _plugins from '#build/plugins'
|
||||||
@ -14,7 +14,7 @@ if (process.server) {
|
|||||||
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext'] = {}) {
|
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext'] = {}) {
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
const nuxt = createNuxt({ app, ssrContext })
|
const nuxt = createNuxtApp({ app, ssrContext })
|
||||||
|
|
||||||
await applyPlugins(nuxt, plugins)
|
await applyPlugins(nuxt, plugins)
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ if (process.client) {
|
|||||||
const isSSR = Boolean(window.__NUXT__?.serverRendered)
|
const isSSR = Boolean(window.__NUXT__?.serverRendered)
|
||||||
const app = isSSR ? createSSRApp(App) : createApp(App)
|
const app = isSSR ? createSSRApp(App) : createApp(App)
|
||||||
|
|
||||||
const nuxt = createNuxt({ app })
|
const nuxt = createNuxtApp({ app })
|
||||||
|
|
||||||
await applyPlugins(nuxt, plugins)
|
await applyPlugins(nuxt, plugins)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export interface CreateOptions {
|
|||||||
globalName?: NuxtApp['globalName']
|
globalName?: NuxtApp['globalName']
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNuxt (options: CreateOptions) {
|
export function createNuxtApp (options: CreateOptions) {
|
||||||
const nuxt: NuxtApp = {
|
const nuxt: NuxtApp = {
|
||||||
provide: undefined,
|
provide: undefined,
|
||||||
globalName: 'nuxt',
|
globalName: 'nuxt',
|
||||||
|
@ -18,6 +18,7 @@ export default defineNuxtPlugin((nuxt) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for (const name in Components) {
|
for (const name in Components) {
|
||||||
|
// eslint-disable-next-line import/namespace
|
||||||
nuxt.app.component(name, Components[name])
|
nuxt.app.component(name, Components[name])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user