1.0.5 • Published 7 months ago

nuxt-eslint-globals v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

ESLint Globals

npm version npm downloads

Nuxt

Nuxt module that creates an eslint globals file for Nuxt auto-imports

All auto-imported functions from Vue, Nuxt, h3, Nitro, and third-party modules will be included. Additionally, exports from your project's components, composables, and server/utils directories will be added.

Quick Setup

  1. Add nuxt-eslint-globals dependency to your project
# Using pnpm
pnpm add -D nuxt-eslint-globals

# Using yarn
yarn add --dev nuxt-eslint-globals

# Using npm
npm install --save-dev nuxt-eslint-globals
  1. Add nuxt-eslint-globals to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-eslint-globals'
  ]
})

That's it! The next time you run the dev command, the module will create a file named .eslint.globals.cjs in your project's build directory (.nuxt).

All auto-imported functions from Vue, Nuxt, h3, Nitro, and third-party modules will be included. Additionally, exports from your project's components, composables, and server/utils directories will be added.

Usage

Once the module creates the ESLint globals file, you can reference it in your .eslintrc:

{
  "extends": [
    ".nuxt/.eslint.globals.cjs"
  ]
}

Options

The module accepts three optional settings:

  • custom: an array of strings representing globals you want to add to the .eslint.globals.cjs file in addition to the ones the module adds automatically
  • outputType: (one of 'cjs', 'es', 'ts', or 'json'. Default is 'cjs'.) A string representing the type of module you would like to produce. This will affect the file's extension as well as the type of export within the file (of course, 'json' will just produce the JSON string).
  • outputDir: the directory, relative to the project's root, where you want the .eslint.globals.cjs file to be located. If none is provided it will go in the build directory.

You can add options in nuxt.config either by using array format for the module registration:

modules: [
  ['nuxt-eslint-globals', {outputType: 'json', custom: ['fooo', 'barrrr']}]
]

…or adding an eslintGlobals property to the config object:

modules: [
  'nuxt-eslint-globals'
],
eslintGlobals: {
  custom: ['fooo', 'barrrr'],
  outputType: 'json',
},

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release
1.0.5

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago