-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7529bf6
commit 21767c5
Showing
23 changed files
with
4,508 additions
and
4,546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": [ | ||
"@nuxtjs/eslint-config-typescript" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ node_modules | |
.DS_Store | ||
coverage | ||
dist | ||
sw.* | ||
.env |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
collectCoverageFrom: ['lib/**/*.js'], | ||
testEnvironment: 'node' | ||
preset: '@nuxt/test-utils', | ||
collectCoverageFrom: ['src/**'] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,29 +7,35 @@ | |
"contributors": [ | ||
"Ricardo Gobbo de Souza <[email protected]>" | ||
], | ||
"main": "lib/module.js", | ||
"main": "./dist/module.js", | ||
"types": "./dist/module.d.ts", | ||
"files": [ | ||
"lib" | ||
"dist" | ||
], | ||
"scripts": { | ||
"dev": "nuxt test/fixture", | ||
"lint": "eslint --ext .js,.vue .", | ||
"release": "yarn test && standard-version && git push --follow-tags && npm publish", | ||
"test": "yarn lint && jest" | ||
"build": "siroc build", | ||
"prepublishOnly": "yarn build", | ||
"dev": "nuxt dev test/fixture/basic", | ||
"lint": "eslint --ext .js,.ts,.vue .", | ||
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish", | ||
"test": "yarn lint && yarn jest" | ||
}, | ||
"dependencies": { | ||
"consola": "^2.15.3", | ||
"defu": "^6.0.0", | ||
"eslint-webpack-plugin": "^2.6.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "latest", | ||
"@commitlint/config-conventional": "latest", | ||
"@nuxtjs/eslint-config": "latest", | ||
"@nuxtjs/module-test-utils": "latest", | ||
"@babel/preset-typescript": "latest", | ||
"@nuxt/test-utils": "latest", | ||
"@nuxt/types": "latest", | ||
"@nuxtjs/eslint-config-typescript": "latest", | ||
"@types/jest": "latest", | ||
"@types/node": "latest", | ||
"eslint": "latest", | ||
"husky": "latest", | ||
"jest": "latest", | ||
"nuxt-edge": "latest", | ||
"nuxt": "latest", | ||
"siroc": "latest", | ||
"standard-version": "latest" | ||
}, | ||
"peerDependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { resolve } from 'path' | ||
import consola from 'consola' | ||
import { defu } from 'defu' | ||
import type { Module } from '@nuxt/types' | ||
import type { Options } from 'eslint-webpack-plugin' | ||
import { name, version } from '../package.json' | ||
import { moduleExists } from './utils' | ||
|
||
const logger = consola.withTag('nuxt:eslint') | ||
|
||
export interface ModuleOptions extends Partial<Options>{} | ||
|
||
const CONFIG_KEY = 'eslint' | ||
|
||
const nuxtModule: Module<ModuleOptions> = function (moduleOptions) { | ||
const DEFAULTS: ModuleOptions = { | ||
context: this.options.srcDir, | ||
eslintPath: 'eslint', | ||
extensions: ['js', 'ts', 'vue'], | ||
cache: true, | ||
lintDirtyModulesOnly: true | ||
} | ||
|
||
const options: ModuleOptions = defu( | ||
this.options[CONFIG_KEY], | ||
moduleOptions, | ||
DEFAULTS | ||
) | ||
|
||
if (!moduleExists(options.eslintPath)) { | ||
logger.warn( | ||
`The dependency \`${options.eslintPath}\` not found.`, | ||
'Please run `yarn add eslint --dev` or `npm install eslint --save-dev`' | ||
) | ||
return | ||
} | ||
|
||
const filesToWatch = [ | ||
'.eslintrc', | ||
'.eslintrc.json', | ||
'.eslintrc.yaml', | ||
'.eslintrc.yml', | ||
'.eslintrc.js' | ||
] | ||
|
||
this.options.watch = this.options.watch || [] | ||
this.options.watch.push(...filesToWatch.map(file => resolve(this.options.rootDir, file))) | ||
|
||
this.extendBuild((config, { isDev, isClient }) => { | ||
if (isDev && isClient) { | ||
const EslintPlugin = require('eslint-webpack-plugin') | ||
|
||
config.plugins.push(new EslintPlugin(options)) | ||
} | ||
}) | ||
} | ||
|
||
;(nuxtModule as any).meta = { name, version } | ||
|
||
declare module '@nuxt/types' { | ||
interface NuxtConfig { [CONFIG_KEY]?: ModuleOptions } // Nuxt 2.14+ | ||
interface Configuration { [CONFIG_KEY]?: ModuleOptions } // Nuxt 2.9 - 2.13 | ||
} | ||
|
||
export default nuxtModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function moduleExists (name) { | ||
try { | ||
return require.resolve(name) | ||
} catch (e) { | ||
return false | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { setupTest, get } from '@nuxt/test-utils' | ||
|
||
describe('dev', () => { | ||
setupTest({ | ||
fixture: 'fixture', | ||
server: true, | ||
config: { | ||
dev: true | ||
} | ||
}) | ||
|
||
test('render', async () => { | ||
const { body } = await get('/') | ||
expect(body).toContain('Works!') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
export default { | ||
rootDir: __dirname, | ||
buildModules: [ | ||
{ handler: require('../../') } | ||
modules: [ | ||
'../../src/module.ts' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
|
||
<script> | ||
export default { | ||
name: 'PageIndex' | ||
} | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { setupTest, get } from '@nuxt/test-utils' | ||
|
||
describe('prod', () => { | ||
setupTest({ | ||
fixture: 'fixture', | ||
server: true, | ||
config: { | ||
dev: false | ||
} | ||
}) | ||
|
||
test('render', async () => { | ||
const { body } = await get('/') | ||
expect(body).toContain('Works!') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.