Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to esm #373

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

module.exports = {
root: true,
env: {
Expand Down
16 changes: 8 additions & 8 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

- It's OK to have multiple small commits as you work on the PR - we will let GitHub automatically squash it before merging.

- Make sure `yarn test` passes. (see [development setup](#development-setup))
- Make sure `pnpm test` passes. (see [development setup](#development-setup))

- If adding new feature:

Expand All @@ -52,23 +52,23 @@

## Development Setup

You will need [Node.js](http://nodejs.org) and [Yarn](https://yarnpkg.com/en/)
You will need [Node.js](http://nodejs.org) and [pnpm](https://pnpm.io/)

After cloning the repo, run:

$ yarn
$ pnpm install

### Commonly used scirpt with Yarn
### Commonly used scirpt with `pnpm`

# lint source codes and docs
$ yarn lint
$ yarn lint:docs
$ pnpm lint
$ pnpm lint:docs

# run the vuepress
$ yarn docs
$ pnpm docs

# run the test suite
$ yarn test
$ pnpm test

There are some other scripts available in the `scripts` section of the `package.json` file.

Expand Down
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ about: Create a report to help us improve
<!--
Before posting the issue, please confirm that the problem you're getting
is not related with your code editor configuration.
To make sure it's not, run: yarn eslint src/your-file.vue
To make sure it's not, run: pnpm eslint src/your-file.vue
-->

**Tell us about your environment**
Expand Down Expand Up @@ -46,5 +46,3 @@ about: Create a report to help us improve
Please share a repository that can reproduce your issue.
If you don't share it, we will most likely add a comment asking you to share the repository.
-->


26 changes: 16 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16
- name: Enable corepack
run: corepack enable
- name: Install
run: yarn install
run: pnpm install
- name: Lint
run: yarn lint
run: pnpm lint
- name: Lint docs
run: yarn lint:docs
run: pnpm lint:docs
test:
name: 'Test for ESLint 8 on Node.js ${{ matrix.node }} OS: ${{matrix.os}}'
runs-on: ${{ matrix.os }}
Expand All @@ -38,14 +40,16 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Enable corepack
run: corepack enable
- name: Install
run: yarn install
run: pnpm install
- name: Test
run: yarn test
run: pnpm test
- name: Integration Test
run: |
yarn build
yarn test:integrations
pnpm build
pnpm test:integrations
test-for-eslint:
name: 'Test for ESLint ${{ matrix.eslint }} on ${{ matrix.node }} OS: ${{matrix.os}}'
runs-on: ${{ matrix.os }}
Expand All @@ -61,10 +65,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Enable corepack
run: corepack enable
- name: Install
run: yarn add eslint@${{ matrix.eslint }}
run: pnpm add eslint@${{ matrix.eslint }}
- name: Install ts-eslint v5
run: yarn add @typescript-eslint/parser@4 @typescript-eslint/eslint-plugin@4
run: pnpm add @typescript-eslint/parser@4 @typescript-eslint/eslint-plugin@4
if: matrix.eslint == 5
- name: Test
run: yarn test
run: pnpm test
6 changes: 6 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"eslint.validate": ["javascript", "typescript", "vue", "markdown"],
"eslint.alwaysShowStatus": true,
"eslint.packageManager": "yarn",
"eslint.run": "onSave",
"npm.packageManager": "yarn",
"editor.formatOnSave": true,
"eslint.packageManager": "pnpm",
// "eslint.run": "onSave",
"npm.packageManager": "pnpm",
// "editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
2 changes: 1 addition & 1 deletion lib/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import base from './configs/base'
import recommended from './configs/recommended'

export = {
export default {
base,
recommended
}
6 changes: 5 additions & 1 deletion lib/configs/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export = {
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)

export default {
parser: require.resolve('vue-eslint-parser'),
plugins: ['@intlify/vue-i18n'],
overrides: [
Expand Down
6 changes: 5 additions & 1 deletion lib/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/** DON'T EDIT THIS FILE; was created by scripts. */
export = {
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)

export default {
extends: [require.resolve('./base')],
parserOptions: {
ecmaVersion: 2018,
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import configs from './configs'
import rules from './rules'

export = {
export default {
configs,
rules
}
2 changes: 1 addition & 1 deletion lib/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import preferSfcLangAttr from './rules/prefer-sfc-lang-attr'
import sfcLocaleAttr from './rules/sfc-locale-attr'
import validMessageSyntax from './rules/valid-message-syntax'

export = {
export default {
'key-format-style': keyFormatStyle,
'no-deprecated-i18n-component': noDeprecatedI18nComponent,
'no-deprecated-i18n-place-attr': noDeprecatedI18nPlaceAttr,
Expand Down
4 changes: 2 additions & 2 deletions lib/rules/key-format-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const allowedCaseOptions = [
'snake_case',
'SCREAMING_SNAKE_CASE'
] as const
type CaseOption = typeof allowedCaseOptions[number]
type CaseOption = (typeof allowedCaseOptions)[number]

function create(context: RuleContext): RuleListener {
const filename = context.getFilename()
Expand Down Expand Up @@ -284,7 +284,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'layout',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-deprecated-i18n-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function create(context: RuleContext): RuleListener {
})
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-deprecated-i18n-place-attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function create(context: RuleContext): RuleListener {
})
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-deprecated-i18n-places-prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function create(context: RuleContext): RuleListener {
})
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-duplicate-keys-in-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-dynamic-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function create(context: RuleContext): RuleListener {
)
}

export = createRule({
export default createRule({
meta: {
type: 'suggestion',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-html-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-i18n-t-path-prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function create(context: RuleContext): RuleListener {
})
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-missing-keys-in-other-locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'layout',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-missing-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function checkCallExpression(
}
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-raw-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ function create(context: RuleContext): RuleListener {
})
}

export = createRule({
export default createRule({
meta: {
type: 'suggestion',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unknown-locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'suggestion',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-unused-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'suggestion',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/no-v-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function create(context: RuleContext): RuleListener {
})
}

export = createRule({
export default createRule({
meta: {
type: 'problem',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-linked-key-with-paren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'layout',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/prefer-sfc-lang-attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'suggestion',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/sfc-locale-attr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RuleContext, RuleListener } from '../types'
import { isI18nBlock, getAttribute } from '../utils/index'
import { createRule } from '../utils/rule'

export = createRule({
export default createRule({
meta: {
type: 'suggestion',
docs: {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/valid-message-syntax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ function create(context: RuleContext): RuleListener {
}
}

export = createRule({
export default createRule({
meta: {
type: 'layout',
docs: {
Expand Down
4 changes: 1 addition & 3 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as collectKeys from './utils/collect-keys'
import * as collectLinkedKeys from './utils/collect-linked-keys'
import * as defaultTimeouts from './utils/default-timeouts'
import * as getCwd from './utils/get-cwd'
import * as globSync from './utils/glob-sync'
import * as globUtils from './utils/glob-utils'
import * as ignoredPaths from './utils/ignored-paths'
import * as index from './utils/index'
Expand All @@ -18,15 +17,14 @@ import * as regexp from './utils/regexp'
import * as resourceLoader from './utils/resource-loader'
import * as rule from './utils/rule'

export = {
export default {
'cache-function': cacheFunction,
'cache-loader': cacheLoader,
casing,
'collect-keys': collectKeys,
'collect-linked-keys': collectLinkedKeys,
'default-timeouts': defaultTimeouts,
'get-cwd': getCwd,
'glob-sync': globSync,
'glob-utils': globUtils,
'ignored-paths': ignoredPaths,
index,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/casing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const allowedCaseOptions = [
* Return case checker
*/
export function getCasingChecker(
name: typeof allowedCaseOptions[number]
name: (typeof allowedCaseOptions)[number]
): (str: string) => boolean {
return checkersMap[name] || isPascalCase
}
Loading