Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
update axe-reled endO nuxt.config.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdmaster committed Nov 23, 2021
1 parent baa6f28 commit 4155c70
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module.exports = {
plugins: ['tsdoc', 'simple-import-sort', 'vue', 'nuxt'],
plugins: ['tsdoc', 'simple-import-sort', 'vue', 'nuxt', '@typescript-eslint'],
extends: [
'prettier',
'plugin:prettier/recommended',
'plugin:nuxt/recommended',
'plugin:vue/recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
'vue/max-attributes-per-line': 0 /* off */,
Expand All @@ -31,5 +32,6 @@ module.exports = {
patterns: ['./', '../'],
},
],
'@typescript-eslint/no-explicit-any': 1,
},
}
24 changes: 15 additions & 9 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs'
import path from 'path'
// eslint-disable-next-line no-restricted-imports
import i18n from './nuxt-i18n.config'
// @ts-ignore
// eslint-disable-next-line no-unused-vars
import { Settings } from '@/types/cardRoutesSettings'
const environment = process.env.NODE_ENV || 'development'
const cardData = JSON.parse(
Expand Down Expand Up @@ -86,12 +86,12 @@ const config = {
*/
plugins: [
{
src: '@/plugins/vue-chart.ts',
ssr: true,
src: '@/plugins/vue-chart',
mode: 'server',
},
{
src: '@/plugins/axe',
ssr: true,
mode: 'server',
},
],
/*
Expand Down Expand Up @@ -160,7 +160,9 @@ const config = {
},
build: {
filenames: {
chunk: ({ isDev }) => (isDev ? '[name].js' : '[id].[contenthash].js'),
chunk: ({
isDev /* eslint-disable-line @typescript-eslint/no-explicit-any */,
}) => (isDev ? '[name].js' : '[id].[contenthash].js'),
},
loaders: {
sass: {
Expand Down Expand Up @@ -192,7 +194,9 @@ const config = {
},
},
},
extend(config) {
extend(
config
) /* eslint-disable-line @typescript-eslint/no-explicit-any */ {
// default externals option is undefined
config.externals = [{ moment: 'moment' }]
},
Expand Down Expand Up @@ -220,12 +224,12 @@ const config = {
fallback: true,
routes() {
const locales = ['en', 'zh-cn', 'zh-tw', 'ko', 'ja-basic']
const pages = cardData.map((v) => {
return v.path
})
/* eslint-disable @typescript-eslint/no-explicit-any */
const pages = cardData.map((v) => v.path)
const localizedPages = locales
.map((locale) => pages.map((page) => `/${locale}${page}`))
.reduce((a, b) => [...a, ...b], [])
/* eslint-enable @typescript-eslint/no-explicit-any */
return [...pages, ...localizedPages]
},
},
Expand All @@ -247,6 +251,7 @@ const config = {
},
},
router: {
/* eslint-disable @typescript-eslint/no-explicit-any */
extendRoutes(routes) {
routes.forEach((route) => {
if (
Expand All @@ -258,6 +263,7 @@ const config = {
}
})
},
/* eslint-enable @typescript-eslint/no-explicit-any */
},
}

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
"@types/chart.js": "2.9.34",
"@types/lodash": "4.14.177",
"@types/node": "16.11.9",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"core-js": "3.19.1",
"danger": "10.7.1",
"eslint": "8.3.0",
Expand Down
11 changes: 7 additions & 4 deletions plugins/axe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axe from 'axe-core'
import Vue from 'nuxt'
const AXE_LOCALE_JA = () =>
import('axe-core/locales/ja.json').then((value) => {
return value.default
Expand All @@ -7,9 +8,10 @@ const AXE_LOCALE_JA = () =>
const NODE_ENV = process.env.NODE_ENV
const VUE_AXE = process.env.VUE_AXE

const VueAxe: Vue.NuxtConfig[] = [axe]
if (NODE_ENV === 'development' && VUE_AXE === 'true') {
/* Vue.use( */
;[axe].forEach((config) => {
/* eslint-disable @typescript-eslint/no-explicit-any */
for (const config of VueAxe) {
config.locale = AXE_LOCALE_JA
config.rules = [
{
Expand All @@ -20,7 +22,8 @@ if (NODE_ENV === 'development' && VUE_AXE === 'true') {
},
]
config.clearConsoleOnUpdate = false
})
/* eslint-enable @typescript-eslint/no-explicit-any */
}
}

export default axe
export default VueAxe
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@
anymatch "^3.0.0"
source-map "^0.6.0"

"@typescript-eslint/eslint-plugin@^5.1.0":
"@typescript-eslint/eslint-plugin@5.4.0", "@typescript-eslint/eslint-plugin@^5.1.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.4.0.tgz#05e711a2e7b68342661fde61bccbd1531c19521a"
integrity sha512-9/yPSBlwzsetCsGEn9j24D8vGQgJkOTr4oMLas/w886ZtzKIs1iyoqFrwsX2fqYEeUwsdBpC21gcjRGo57u0eg==
Expand All @@ -2072,7 +2072,7 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/parser@^5.1.0":
"@typescript-eslint/parser@^5.1.0", "@typescript-eslint/parser@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.4.0.tgz#3aa83ce349d66e39b84151f6d5464928044ca9e3"
integrity sha512-JoB41EmxiYpaEsRwpZEYAJ9XQURPFer8hpkIW9GiaspVLX8oqbqNM8P4EP8HOZg96yaALiLEVWllA2E8vwsIKw==
Expand Down

0 comments on commit 4155c70

Please sign in to comment.