Skip to content

Commit

Permalink
chore: upgrade eslint (#407)
Browse files Browse the repository at this point in the history
* chore: upgrade eslint

* update

* fix
  • Loading branch information
kazupon authored Nov 7, 2024
1 parent 15eee8d commit 3bb6d2c
Show file tree
Hide file tree
Showing 51 changed files with 8,131 additions and 2,307 deletions.
3 changes: 1 addition & 2 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Hi! We are really excited that you are interested in contributing to `@intlify/b
- Submit a pull request to `main` branch of `@intlify/bundle-tools` repository !

## Development Setup

You will need [Node.js](http://nodejs.org) **version 12+**, and [Yarn v1](https://classic.yarnpkg.com/).

After cloning the repo, run:
Expand All @@ -20,7 +21,6 @@ After cloning the repo, run:
$ yarn # install the dependencies of the project
```


A high level overview of tools used:

- [TypeScript](https://www.typescriptlang.org/) as the development language
Expand All @@ -32,7 +32,6 @@ A high level overview of tools used:
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io/) for code formatting


## Scripts

### `yarn build`
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ packages/**/lib
coverage
tsconfig.json
dist
pnpm-lock.yaml
packages/**/examples/dist
packages/**/CHANGELOG.md
packages/rollup-plugin-vue-i18n/examples/composition/index.js
packages/rollup-plugin-vue-i18n/examples/global/index.js
packages/rollup-plugin-vue-i18n/examples/legacy/index.js
packages/rollup-plugin-vue-i18n/examples/legacy/index.js
6 changes: 3 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
semi: false
singleQuote: true
printWidth: 80
trailingComma: "none"
endOfLine: "auto"
arrowParens: "avoid"
trailingComma: 'none'
endOfLine: 'auto'
arrowParens: 'avoid'
7 changes: 0 additions & 7 deletions .yarnrc.yml

This file was deleted.

13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ The bundle tools for Vue I18n

## 📦 Packages

| Package | Bundler | Version (click for changelogs) | Status |
| ------------------------------------------------------------------ | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------ | :----- |
| [@intlify/unplugin-vue-i18n](packages/unplugin-vue-i18n) | vite / webpack | [![unplugin-vue-i18n version](https://img.shields.io/npm/v/@intlify/unplugin-vue-i18n.svg?label=%20&&color=yellow)](packages/unplugin-vue-i18n/CHANGELOG.md)| Stable |
| [@intlify/vite-plugin-vue-i18n](packages/vite-plugin-vue-i18n) | vite | [![vite-plugin-vue-i18n version](https://img.shields.io/npm/v/@intlify/vite-plugin-vue-i18n.svg?label=%20&&color=blueviolet)](packages/vite-plugin-vue-i18n/CHANGELOG.md) (**until Vite 3**)| Hot fix maintenance only |
| [@intlify/vue-i18n-loader](packages/vue-i18n-loader) | webpack | [![vue-i18n-loader version](https://img.shields.io/npm/v/@intlify/vue-i18n-loader.svg?label=%20&color=blue)](packages/vue-i18n-loader/CHANGELOG.md) (**for [email protected]**)| Hot fix maintenance only |
| [@intlify/rollup-plugin-vue-i18n](packages/rollup-plugin-vue-i18n) | rollup | [![rollup-plugin-vue-i18n version](https://img.shields.io/npm/v/@intlify/rollup-plugin-vue-i18n.svg?label=%20&color=red)](packages/rollup-plugin-vue-i18n/CHANGELOG.md)| Hot fix maintenance only |

| Package | Bundler | Version (click for changelogs) | Status |
| ------------------------------------------------------------------ | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------- |
| [@intlify/unplugin-vue-i18n](packages/unplugin-vue-i18n) | vite / webpack | [![unplugin-vue-i18n version](https://img.shields.io/npm/v/@intlify/unplugin-vue-i18n.svg?label=%20&&color=yellow)](packages/unplugin-vue-i18n/CHANGELOG.md) | Stable |
| [@intlify/vite-plugin-vue-i18n](packages/vite-plugin-vue-i18n) | vite | [![vite-plugin-vue-i18n version](https://img.shields.io/npm/v/@intlify/vite-plugin-vue-i18n.svg?label=%20&&color=blueviolet)](packages/vite-plugin-vue-i18n/CHANGELOG.md) (**until Vite 3**) | Hot fix maintenance only |
| [@intlify/vue-i18n-loader](packages/vue-i18n-loader) | webpack | [![vue-i18n-loader version](https://img.shields.io/npm/v/@intlify/vue-i18n-loader.svg?label=%20&color=blue)](packages/vue-i18n-loader/CHANGELOG.md) (**for [email protected]**) | Hot fix maintenance only |
| [@intlify/rollup-plugin-vue-i18n](packages/rollup-plugin-vue-i18n) | rollup | [![rollup-plugin-vue-i18n version](https://img.shields.io/npm/v/@intlify/rollup-plugin-vue-i18n.svg?label=%20&color=red)](packages/rollup-plugin-vue-i18n/CHANGELOG.md) | Hot fix maintenance only |

## 💪 Contribution

Expand Down
4 changes: 0 additions & 4 deletions TODO.md

This file was deleted.

63 changes: 63 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
defineConfig,
javascript,
prettier,
typescript
} from '@kazupon/eslint-config'
import path from 'node:path'

const __dirname = path.dirname(new URL(import.meta.url).pathname)

export default defineConfig(
javascript(),
typescript({
parserOptions: {
project: [
path.join(__dirname, './tsconfig.json'),
path.join(__dirname, './packages/unplugin-vue-i18n/tsconfig.json')
]
}
}),
prettier(),
{
name: 'ignores',
ignores: [
'packages/rollup-plugin-vue-i18n/*',
'packages/vite-plugin-vue-i18n/*',
'packages/vue-i18n-loader/*',
'packages/unplugin-vue-i18n/lib/*',
'packages/bundle-utils/lib/*',
'examples/*',
'**/test/fixtures/**',
'**/*.config.ts',
'**/dist/**',
'**/.eslint-config-inspector/**',
'**/tsconfig.json',
'**/*.yml',
'**/*.yaml',
'**/*.json',
'**/*.json5',
'**/*.jsonc',
'**/*.vue'
]
},
{
rules: {
'no-case-declarations': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off'
}
}
)
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
}
},
"devDependencies": {
"@eslint/js": "^9.14.0",
"@intlify/core-base": "next",
"@kazupon/eslint-config": "^0.18.0",
"@kazupon/lerna-changelog": "^4.3.0",
"@octokit/rest": "^20.0.0",
"@rollup/plugin-alias": "^3.1.5",
Expand All @@ -32,8 +34,7 @@
"@rollup/plugin-replace": "^2.4.2",
"@rollup/pluginutils": "^4.1.0",
"@types/debug": "^4.1.5",
"@types/eslint": "^8.56.10",
"@types/eslint-visitor-keys": "^1.0.0",
"@types/eslint": "^9.6.1",
"@types/js-yaml": "^4.0.3",
"@types/jsdom": "^16.2.5",
"@types/json5": "^2.2.0",
Expand All @@ -43,17 +44,13 @@
"@types/semver": "^7.3.6",
"@types/webpack": "^5.28.2",
"@types/webpack-merge": "^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-vue": "^5.1.4",
"@vue/compiler-sfc": "^3.2.25",
"babel-loader": "^8.2.2",
"chalk": "^5.3.0",
"debug": "^4.1.1",
"eslint": "^8.57.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.26.0",
"execa": "^5.1.1",
"get-port-please": "^3.1.2",
"jiti": "^2.4.0",
Expand All @@ -63,15 +60,16 @@
"minimist": "^1.2.8",
"npm-run-all2": "^7.0.1",
"opener": "^1.5.2",
"playwright": "^1.44.0",
"prettier": "^3.2.5",
"prompts": "^2.4.2",
"playwright": "^1.44.0",
"rollup": "^2.53.1",
"rollup-plugin-vue": "^6.0.0",
"serve": "^11.3.2",
"source-map": "0.6.1",
"tiny-glob": "^0.2.9",
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0",
"vite": "^5.4.10",
"vitest": "^2.1.4",
"vue": "^3.2.25",
Expand Down Expand Up @@ -122,12 +120,13 @@
"clean:webpack": "pnpm --filter @intlify/vue-i18n-loader clean",
"clean:unplugin": "pnpm --filter @intlify/unplugin-vue-i18n clean",
"coverage": "opener coverage/lcov-report/index.html",
"fix": "run-p lint:eslint:fix format:fix",
"format": "prettier --config .prettierrc --ignore-path .prettierignore '**/*.{js,json,html}'",
"format:fix": "pnpm format --write",
"lint": "run-p lint:eslint",
"lint:eslint": "eslint ./packages ./scripts --ext .ts",
"lint:eslint:fix": "pnpm lint:eslint --fix",
"fix": "run-p \"fix:* {@}\" --",
"fix:eslint": "eslint --flag unstable_ts_config . --fix",
"fix:prettier": "prettier . --write",
"dev:lint": "pnpx @eslint/config-inspector --config eslint.config.ts",
"lint": "run-p \"lint:* {@}\" --",
"lint:eslint": "eslint --flag unstable_ts_config .",
"lint:prettier": "prettier . --check",
"test": "pnpm test:unit && pnpm test:e2e",
"test:e2e": "pnpm check-install && vitest -c ./vitest.e2e.config.ts run",
"test:e2e:rollup": "pnpm --filter @intlify/rollup-plugin-vue-i18n test:e2e",
Expand Down
5 changes: 2 additions & 3 deletions packages/bundle-utils/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function advancePositionWithSource(
}

const DETECT_MESSAGE = `Detected HTML in '{msg}' message.`
const ON_ERROR_NOOP = () => {} // eslint-disable-line @typescript-eslint/no-empty-function
const ON_ERROR_NOOP = () => {}

function parsePath(path?: string[]): string {
return path ? path.join('.') : ''
Expand Down Expand Up @@ -371,11 +371,10 @@ export function mapLinesColumns(
})
})

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const generator = mergedMapGenerator as any
// const targetConsumer = inMapConsumer || resMapConsumer
const targetConsumer = inMapConsumer || resMapConsumer
// eslint-disable-next-line @typescript-eslint/no-explicit-any

;(targetConsumer as any).sources.forEach((sourceFile: string) => {
generator._sources.add(sourceFile)
const sourceContent = targetConsumer.sourceContentFor(sourceFile)
Expand Down
2 changes: 0 additions & 2 deletions packages/bundle-utils/src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export type InstalledPackage = 'vue-i18n' | 'petite-vue-i18n'

const _require = module.createRequire(import.meta.url)

// eslint-disable-next-line @typescript-eslint/ban-types
export function checkInstallPackage(
pkg: string,
debug: Function
Expand Down Expand Up @@ -55,7 +54,6 @@ export function getVueI18nVersion(
return 'unknown'
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function loadModule(moduleName: string, debug: Function): any {
try {
return _require(moduleName)
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-utils/src/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function generate(
// }
// prettier-ignore
const newMap = map
? mapLinesColumns((map as any).toJSON(), codeMaps, inSourceMap) || null // eslint-disable-line @typescript-eslint/no-explicit-any
? mapLinesColumns((map as any).toJSON(), codeMaps, inSourceMap) || null
: null
return {
ast,
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-utils/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function generate(
// prettier-ignore
const newMap =
map && !jit
? mapLinesColumns((map as any).toJSON(), codeMaps, inSourceMap) || null // eslint-disable-line @typescript-eslint/no-explicit-any
? mapLinesColumns((map as any).toJSON(), codeMaps, inSourceMap) || null
: null
return {
ast,
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-utils/src/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function generate(
const { code, map } = generator.context()
// prettier-ignore
const newMap = map
? mapLinesColumns((map as any).toJSON(), codeMaps, inSourceMap) || null // eslint-disable-line @typescript-eslint/no-explicit-any
? mapLinesColumns((map as any).toJSON(), codeMaps, inSourceMap) || null
: null
return {
ast,
Expand Down
26 changes: 12 additions & 14 deletions packages/bundle-utils/test/fixtures/codegen/complex.json5
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
{
hi: "hi there!",
hi: 'hi there!',
nested: {
hello: "hello world!",
hello: 'hello world!',
more: {
plural: "@.caml:{'no apples'} | {0} apple | {n} apples"
},
list: "hi, {0} !"
list: 'hi, {0} !'
},
// comment
"こんにちは": "こんにちは!",
"single-quote": "I don't know!",
emoji: "😺",
unicode: "\u0041",
"unicode-escape": "\\u0041",
"backslash-single-quote": "\\'",
"backslash-backslash": "\\\\",
errors: [
'ERROR1001', 'ERROR1002'
],
こんにちは: 'こんにちは!',
'single-quote': "I don't know!",
emoji: '😺',
unicode: '\u0041',
'unicode-escape': '\\u0041',
'backslash-single-quote': "\\'",
'backslash-backslash': '\\\\',
errors: ['ERROR1001', 'ERROR1002'],
complex: {
warnings: [
'NOTE: This is warning',
{
"named-waring": 'this is {type} warining'
'named-waring': 'this is {type} warining'
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions packages/bundle-utils/test/fixtures/codegen/complex.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
hi: hi there!
nested:
"hello": "hello world!"
'hello': 'hello world!'
more:
plural: "@.caml:{'no apples'} | {0} apple | {n} apples"
list: hi, {0} !
こんにちは: "こんにちは!"
こんにちは: 'こんにちは!'
single-quote: "I don't know!"
emoji: 😺
unicode: "\u0041"
Expand All @@ -17,4 +17,4 @@ errors:
complex:
warnings:
- 'NOTE: This is warning'
- named-waring: "this is {type} warining"
- named-waring: 'this is {type} warining'
6 changes: 3 additions & 3 deletions packages/bundle-utils/test/fixtures/codegen/complex.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
hi: hi there!
nested:
"hello": "hello world!"
'hello': 'hello world!'
more:
plural: "@.caml:{'no apples'} | {0} apple | {n} apples"
list: hi, {0} !
こんにちは: "こんにちは!"
こんにちは: 'こんにちは!'
single-quote: "I don't know!"
emoji: 😺
unicode: "\u0041"
Expand All @@ -17,4 +17,4 @@ errors:
complex:
warnings:
- 'NOTE: This is warning'
- named-waring: "this is {type} warining"
- named-waring: 'this is {type} warining'
Loading

0 comments on commit 3bb6d2c

Please sign in to comment.