diff --git a/package.json b/package.json index 08e5fe890..64bc5788d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "scripts": { "prepare": "husky install", "dev": "pnpm --dir ./packages/vant dev", - "lint": "pnpm --dir ./packages/vant lint", + "lint": "eslint ./packages/**/src ./packages/**/test --ext .js,.ts,.tsx,.vue,.mjs,.cjs", "test": "pnpm --dir ./packages/vant test", "test:watch": "pnpm --dir ./packages/vant test:watch", "test:update": "pnpm --dir ./packages/vant test:update", diff --git a/packages/vant-cli/.eslintrc b/packages/vant-cli/.eslintrc deleted file mode 100644 index d0707a444..000000000 --- a/packages/vant-cli/.eslintrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": ["@vant"] -} diff --git a/packages/vant-eslint-config/jest.config.js b/packages/vant-eslint-config/jest.config.js deleted file mode 100644 index bee5b03fe..000000000 --- a/packages/vant-eslint-config/jest.config.js +++ /dev/null @@ -1,4 +0,0 @@ -/** @type {import('@jest/types').Config.InitialOptions} */ -module.exports = { - resolver: '/jest.resolver.js', -}; diff --git a/packages/vant-eslint-config/jest.resolver.js b/packages/vant-eslint-config/jest.resolver.js deleted file mode 100644 index 7e1be25fa..000000000 --- a/packages/vant-eslint-config/jest.resolver.js +++ /dev/null @@ -1,13 +0,0 @@ -// https://github.com/facebook/jest/issues/9771#issuecomment-871585234 -const resolver = require('enhanced-resolve').create.sync({ - conditionNames: ['require', 'node', 'default'], - extensions: ['.js', '.json', '.node', '.ts', '.tsx'], -}); - -module.exports = function (request, options) { - // list global module that must be resolved by defaultResolver here - if (['fs', 'http', 'path'].includes(request)) { - return options.defaultResolver(request, options); - } - return resolver(options.basedir, request); -}; diff --git a/packages/vant-eslint-config/test/.eslintrc b/packages/vant-eslint-config/test/.eslintrc deleted file mode 100644 index 8d53de665..000000000 --- a/packages/vant-eslint-config/test/.eslintrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "root": true, - "extends": ["../index"] -} diff --git a/packages/vant-eslint-config/test/index.spec.js b/packages/vant-eslint-config/test/index.spec.js deleted file mode 100644 index cdaa095a7..000000000 --- a/packages/vant-eslint-config/test/index.spec.js +++ /dev/null @@ -1,39 +0,0 @@ -const { ESLint } = require('eslint'); -const path = require('path'); - -const eslint = new ESLint(); - -async function lintProject(name) { - const projectPath = path.resolve(__dirname, name); - const filesToLint = path.resolve(projectPath, '**'); - const rest = await eslint.lintFiles(filesToLint); - const ruleId = []; - rest.forEach((res) => - res.messages.forEach((msg) => { - if (ruleId.indexOf(msg.ruleId) < 0) { - ruleId.push(msg.ruleId); - } - }) - ); - return ruleId; -} - -test('a vue project should pass lint', async () => { - const rest = await lintProject('vue'); - - expect([ - 'no-const-assign', - '@typescript-eslint/no-unused-vars', - 'no-undef', - ]).toEqual(rest); -}); - -test('a vue-tsx project should pass lint', async () => { - const rest = await lintProject('vue-tsx'); - - expect([ - '@typescript-eslint/no-unused-vars', - 'vue/no-ref-as-operand', - '@typescript-eslint/no-empty-interface', - ]).toEqual(rest); -}); diff --git a/packages/vant-eslint-config/test/vue-tsx/app.tsx b/packages/vant-eslint-config/test/vue-tsx/app.tsx deleted file mode 100644 index 485e6cc41..000000000 --- a/packages/vant-eslint-config/test/vue-tsx/app.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { defineComponent } from 'vue'; - -export default defineComponent({ - name: 'App', - setup() { - return () => ( - <> -

App

- - ); - }, -}); diff --git a/packages/vant-eslint-config/test/vue-tsx/index.tsx b/packages/vant-eslint-config/test/vue-tsx/index.tsx deleted file mode 100644 index c83ae9d68..000000000 --- a/packages/vant-eslint-config/test/vue-tsx/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { defineComponent, ref } from 'vue'; -import App from './app'; - -const h2 = 1; - -export default defineComponent({ - name: 'Index', - setup() { - const count = ref(0); - - count++; - count + 1; - 1 + count; - - return () => ( - <> -

About

- - - - ); - }, -}); diff --git a/packages/vant-eslint-config/test/vue-tsx/main.ts b/packages/vant-eslint-config/test/vue-tsx/main.ts deleted file mode 100644 index fa0ebf3c5..000000000 --- a/packages/vant-eslint-config/test/vue-tsx/main.ts +++ /dev/null @@ -1 +0,0 @@ -interface Foo {} diff --git a/packages/vant-eslint-config/test/vue-tsx/tsconfig.json b/packages/vant-eslint-config/test/vue-tsx/tsconfig.json deleted file mode 100644 index c7a2083e1..000000000 --- a/packages/vant-eslint-config/test/vue-tsx/tsconfig.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "compilerOptions": { - "target": "esnext", - "module": "esnext", - "strict": true, - "jsx": "preserve", - "importHelpers": true, - "moduleResolution": "node", - "experimentalDecorators": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "sourceMap": true, - "baseUrl": ".", - "lib": ["esnext", "dom", "dom.iterable", "scripthost"] - }, - "include": ["**/*.ts", "**/*.tsx", "**/*.vue"], - "exclude": ["node_modules"] -} diff --git a/packages/vant-eslint-config/test/vue/index.vue b/packages/vant-eslint-config/test/vue/index.vue deleted file mode 100644 index 7fd5fe0d4..000000000 --- a/packages/vant-eslint-config/test/vue/index.vue +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/packages/vant-eslint-config/test/vue/main.js b/packages/vant-eslint-config/test/vue/main.js deleted file mode 100644 index c1e450fc9..000000000 --- a/packages/vant-eslint-config/test/vue/main.js +++ /dev/null @@ -1,2 +0,0 @@ -const a = b + 1; -export default a;