Compare commits
	
		
			19 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 5d908028ca | ||
|  | 610d886afd | ||
|  | aefa76e48a | ||
|  | e787e9a647 | ||
|  | a3598d36d2 | ||
|  | 7b399a63db | ||
|  | bb09e1d6b4 | ||
|  | f97f7ef7de | ||
|  | 0a19d26da6 | ||
|  | ec494867f9 | ||
|  | 656f91ae61 | ||
|  | cdb02c8fa1 | ||
|  | 3f2f335e42 | ||
|  | 3ca0e7ea8b | ||
|  | 96dd9a1797 | ||
|  | 2db56ec8f0 | ||
|  | 6503a153d8 | ||
|  | 10306427d9 | ||
|  | e6cb79994e | 
| @@ -1,7 +1,7 @@ | ||||
| { | ||||
|   "type": "module", | ||||
|   "private": true, | ||||
|   "packageManager": "pnpm@8.3.0", | ||||
|   "packageManager": "pnpm@8.5.1", | ||||
|   "scripts": { | ||||
|     "build": "vite-ssg build", | ||||
|     "dev": "vite --port 3333 --open", | ||||
| @@ -15,48 +15,48 @@ | ||||
|     "up": "taze major -I" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@unocss/reset": "^0.51.4", | ||||
|     "@vueuse/core": "^10.0.2", | ||||
|     "@unocss/reset": "^0.52.1", | ||||
|     "@vueuse/core": "^10.1.2", | ||||
|     "@vueuse/head": "^1.1.26", | ||||
|     "nprogress": "^0.2.0", | ||||
|     "pinia": "^2.0.34", | ||||
|     "vue": "^3.2.47", | ||||
|     "vue-demi": "^0.14.0", | ||||
|     "pinia": "^2.1.3", | ||||
|     "vue": "^3.3.4", | ||||
|     "vue-demi": "^0.14.5", | ||||
|     "vue-i18n": "^9.2.2", | ||||
|     "vue-router": "^4.1.6" | ||||
|     "vue-router": "^4.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@antfu/eslint-config": "^0.38.4", | ||||
|     "@antfu/eslint-config": "^0.39.1", | ||||
|     "@iconify-json/carbon": "^1.1.16", | ||||
|     "@intlify/vite-plugin-vue-i18n": "^7.0.0", | ||||
|     "@types/markdown-it-link-attributes": "^3.0.1", | ||||
|     "@types/nprogress": "^0.2.0", | ||||
|     "@vitejs/plugin-vue": "^4.1.0", | ||||
|     "@vitejs/plugin-vue": "^4.2.3", | ||||
|     "@vue/test-utils": "^2.3.2", | ||||
|     "critters": "^0.0.16", | ||||
|     "cross-env": "^7.0.3", | ||||
|     "cypress": "^12.10.0", | ||||
|     "eslint": "^8.38.0", | ||||
|     "eslint-plugin-cypress": "^2.13.2", | ||||
|     "cypress": "^12.12.0", | ||||
|     "eslint": "^8.41.0", | ||||
|     "eslint-plugin-cypress": "^2.13.3", | ||||
|     "https-localhost": "^4.7.1", | ||||
|     "markdown-it-link-attributes": "^4.0.1", | ||||
|     "markdown-it-shiki": "^0.8.0", | ||||
|     "pnpm": "^8.3.0", | ||||
|     "shiki": "^0.14.1", | ||||
|     "taze": "^0.9.1", | ||||
|     "markdown-it-shiki": "^0.9.0", | ||||
|     "pnpm": "^8.5.1", | ||||
|     "shiki": "^0.14.2", | ||||
|     "taze": "^0.10.1", | ||||
|     "typescript": "^5.0.4", | ||||
|     "unocss": "^0.51.4", | ||||
|     "unplugin-auto-import": "^0.15.3", | ||||
|     "unocss": "^0.52.1", | ||||
|     "unplugin-auto-import": "^0.16.2", | ||||
|     "unplugin-vue-components": "^0.24.1", | ||||
|     "vite": "^4.2.2", | ||||
|     "vite-plugin-inspect": "^0.7.22", | ||||
|     "vite-plugin-pages": "^0.29.0", | ||||
|     "vite-plugin-pwa": "^0.14.7", | ||||
|     "vite": "^4.3.8", | ||||
|     "vite-plugin-inspect": "^0.7.26", | ||||
|     "vite-plugin-pages": "^0.30.1", | ||||
|     "vite-plugin-pwa": "^0.15.0", | ||||
|     "vite-plugin-vue-layouts": "^0.8.0", | ||||
|     "vite-plugin-vue-markdown": "^0.22.5", | ||||
|     "vite-plugin-vue-markdown": "^0.23.5", | ||||
|     "vite-ssg": "^0.22.2", | ||||
|     "vite-ssg-sitemap": "^0.4.3", | ||||
|     "vitest": "^0.30.1", | ||||
|     "vue-tsc": "^1.2.0" | ||||
|     "vite-ssg-sitemap": "^0.5.1", | ||||
|     "vitest": "^0.31.1", | ||||
|     "vue-tsc": "^1.6.5" | ||||
|   } | ||||
| } | ||||
|   | ||||
							
								
								
									
										10
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,12 +1,12 @@ | ||||
| { | ||||
|   "name": "@antfu/eslint-config-monorepo", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "private": true, | ||||
|   "packageManager": "pnpm@8.3.0", | ||||
|   "packageManager": "pnpm@8.5.1", | ||||
|   "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)", | ||||
|   "license": "MIT", | ||||
|   "scripts": { | ||||
|     "lint": "pnpm run stub && eslint .", | ||||
|     "lint": "pnpm -r run stub && eslint .", | ||||
|     "test": "pnpm -r run test", | ||||
|     "build": "pnpm -r run build", | ||||
|     "prepare": "pnpm -r run stub", | ||||
| @@ -15,9 +15,9 @@ | ||||
|   "devDependencies": { | ||||
|     "@antfu/eslint-config": "workspace:*", | ||||
|     "bumpp": "^9.1.0", | ||||
|     "eslint": "^8.38.0", | ||||
|     "eslint": "^8.41.0", | ||||
|     "eslint-plugin-antfu": "link:./packages/eslint-plugin-antfu", | ||||
|     "rimraf": "^5.0.0", | ||||
|     "rimraf": "^5.0.1", | ||||
|     "typescript": "^5.0.4" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -42,6 +42,8 @@ module.exports = { | ||||
|     '!.github', | ||||
|     '!.vitepress', | ||||
|     '!.vscode', | ||||
|     // force exclude | ||||
|     '.vitepress/cache', | ||||
|   ], | ||||
|   plugins: [ | ||||
|     'html', | ||||
| @@ -57,7 +59,7 @@ module.exports = { | ||||
|   }, | ||||
|   overrides: [ | ||||
|     { | ||||
|       files: ['*.json', '*.json5'], | ||||
|       files: ['*.json', '*.json5', '*.jsonc'], | ||||
|       parser: 'jsonc-eslint-parser', | ||||
|       rules: { | ||||
|         'jsonc/array-bracket-spacing': ['error', 'never'], | ||||
| @@ -189,6 +191,8 @@ module.exports = { | ||||
|         '@typescript-eslint/no-var-requires': 'off', | ||||
|         '@typescript-eslint/comma-dangle': 'off', | ||||
|         '@typescript-eslint/consistent-type-imports': 'off', | ||||
|         '@typescript-eslint/no-namespace': 'off', | ||||
|         '@typescript-eslint/no-require-imports': 'off', | ||||
|         'import/no-unresolved': 'off', | ||||
|         'unused-imports/no-unused-imports': 'off', | ||||
|         'unused-imports/no-unused-vars': 'off', | ||||
| @@ -198,6 +202,8 @@ module.exports = { | ||||
|         'no-undef': 'off', | ||||
|         'no-unused-expressions': 'off', | ||||
|         'no-unused-vars': 'off', | ||||
|         'antfu/no-cjs-exports': 'off', | ||||
|         'antfu/no-ts-export-equal': 'off', | ||||
|       }, | ||||
|     }, | ||||
|   ], | ||||
| @@ -253,6 +259,22 @@ module.exports = { | ||||
|         asyncArrow: 'always', | ||||
|       }, | ||||
|     ], | ||||
|     'no-restricted-globals': [ | ||||
|       'error', | ||||
|       { name: 'global', message: 'Use `globalThis` instead.' }, | ||||
|       { name: 'self', message: 'Use `globalThis` instead.' }, | ||||
|       { name: 'isNaN', message: 'Use `Number.isNaN` instead' }, | ||||
|       { name: 'isFinite', message: 'Use `Number.isFinite` instead' }, | ||||
|       { name: 'parseFloat', message: 'Use `Number.parseFloat` instead' }, | ||||
|       { name: 'parseInt', message: 'Use `Number.parseInt` instead' }, | ||||
|     ], | ||||
|     'no-restricted-properties': [ | ||||
|       'error', | ||||
|       { object: 'globalThis', property: 'isNaN', message: 'Use `Number.isNaN` instead' }, | ||||
|       { object: 'globalThis', property: 'isFinite', message: 'Use `Number.isFinite` instead' }, | ||||
|       { object: 'globalThis', property: 'parseFloat', message: 'Use `Number.parseFloat` instead' }, | ||||
|       { object: 'globalThis', property: 'parseInt', message: 'Use `Number.parseInt` instead' }, | ||||
|     ], | ||||
|  | ||||
|     // es6 | ||||
|     'no-var': 'error', | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@antfu/eslint-config-basic", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "description": "", | ||||
|   "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)", | ||||
|   "license": "MIT", | ||||
| @@ -23,18 +23,18 @@ | ||||
|     "eslint-plugin-eslint-comments": "^3.2.0", | ||||
|     "eslint-plugin-html": "^7.1.0", | ||||
|     "eslint-plugin-import": "^2.27.5", | ||||
|     "eslint-plugin-jsonc": "^2.7.0", | ||||
|     "eslint-plugin-jsonc": "^2.8.0", | ||||
|     "eslint-plugin-markdown": "^3.0.0", | ||||
|     "eslint-plugin-n": "^15.7.0", | ||||
|     "eslint-plugin-n": "^16.0.0", | ||||
|     "eslint-plugin-no-only-tests": "^3.1.0", | ||||
|     "eslint-plugin-promise": "^6.1.1", | ||||
|     "eslint-plugin-unicorn": "^46.0.0", | ||||
|     "eslint-plugin-unicorn": "^47.0.0", | ||||
|     "eslint-plugin-unused-imports": "^2.0.0", | ||||
|     "eslint-plugin-yml": "^1.5.0", | ||||
|     "jsonc-eslint-parser": "^2.2.0", | ||||
|     "yaml-eslint-parser": "^1.2.0" | ||||
|     "eslint-plugin-yml": "^1.7.0", | ||||
|     "jsonc-eslint-parser": "^2.3.0", | ||||
|     "yaml-eslint-parser": "^1.2.2" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^8.38.0" | ||||
|     "eslint": "^8.41.0" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@antfu/eslint-config-react", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "description": "", | ||||
|   "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)", | ||||
|   "license": "MIT", | ||||
| @@ -24,7 +24,7 @@ | ||||
|     "eslint-plugin-react-hooks": "^4.6.0" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^8.38.0", | ||||
|     "eslint": "^8.41.0", | ||||
|     "react": "^18.2.0", | ||||
|     "typescript": "^5.0.4" | ||||
|   } | ||||
|   | ||||
| @@ -72,6 +72,7 @@ module.exports = { | ||||
|     '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], | ||||
|     '@typescript-eslint/prefer-ts-expect-error': 'error', | ||||
|     '@typescript-eslint/no-require-imports': 'error', | ||||
|     '@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }], | ||||
|  | ||||
|     // Override JS | ||||
|     'no-useless-constructor': 'off', | ||||
| @@ -158,6 +159,8 @@ module.exports = { | ||||
|  | ||||
|     // antfu | ||||
|     'antfu/generic-spacing': 'error', | ||||
|     'antfu/no-cjs-exports': 'error', | ||||
|     'antfu/no-ts-export-equal': 'error', | ||||
|  | ||||
|     // off | ||||
|     '@typescript-eslint/consistent-indexed-object-style': 'off', | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@antfu/eslint-config-ts", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "description": "", | ||||
|   "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)", | ||||
|   "license": "MIT", | ||||
| @@ -18,11 +18,11 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@antfu/eslint-config-basic": "workspace:*", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.59.0", | ||||
|     "@typescript-eslint/parser": "^5.59.0", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.59.7", | ||||
|     "@typescript-eslint/parser": "^5.59.7", | ||||
|     "eslint-plugin-jest": "^27.2.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^8.38.0" | ||||
|     "eslint": "^8.41.0" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -36,6 +36,7 @@ module.exports = { | ||||
|     'vue/multi-word-component-names': 'off', | ||||
|     'vue/prefer-import-from-vue': 'off', | ||||
|     'vue/no-v-text-v-html-on-component': 'off', | ||||
|     'vue/no-dupe-keys': 'off', | ||||
|  | ||||
|     // reactivity transform | ||||
|     'vue/no-setup-props-destructure': 'off', | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@antfu/eslint-config-vue", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "description": "", | ||||
|   "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)", | ||||
|   "license": "MIT", | ||||
| @@ -17,10 +17,10 @@ | ||||
|   "dependencies": { | ||||
|     "@antfu/eslint-config-basic": "workspace:*", | ||||
|     "@antfu/eslint-config-ts": "workspace:*", | ||||
|     "eslint-plugin-vue": "^9.11.0", | ||||
|     "eslint-plugin-vue": "^9.14.0", | ||||
|     "local-pkg": "^0.4.3" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^8.38.0" | ||||
|     "eslint": "^8.41.0" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@antfu/eslint-config", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "description": "Anthony's ESLint config", | ||||
|   "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)", | ||||
|   "license": "MIT", | ||||
| @@ -17,21 +17,21 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@antfu/eslint-config-vue": "workspace:*", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.59.0", | ||||
|     "@typescript-eslint/parser": "^5.59.0", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.59.7", | ||||
|     "@typescript-eslint/parser": "^5.59.7", | ||||
|     "eslint-plugin-eslint-comments": "^3.2.0", | ||||
|     "eslint-plugin-html": "^7.1.0", | ||||
|     "eslint-plugin-import": "^2.27.5", | ||||
|     "eslint-plugin-jsonc": "^2.7.0", | ||||
|     "eslint-plugin-n": "^15.7.0", | ||||
|     "eslint-plugin-jsonc": "^2.8.0", | ||||
|     "eslint-plugin-n": "^16.0.0", | ||||
|     "eslint-plugin-promise": "^6.1.1", | ||||
|     "eslint-plugin-unicorn": "^46.0.0", | ||||
|     "eslint-plugin-vue": "^9.11.0", | ||||
|     "eslint-plugin-yml": "^1.5.0", | ||||
|     "jsonc-eslint-parser": "^2.2.0", | ||||
|     "yaml-eslint-parser": "^1.2.0" | ||||
|     "eslint-plugin-unicorn": "^47.0.0", | ||||
|     "eslint-plugin-vue": "^9.14.0", | ||||
|     "eslint-plugin-yml": "^1.7.0", | ||||
|     "jsonc-eslint-parser": "^2.3.0", | ||||
|     "yaml-eslint-parser": "^1.2.2" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^8.38.0" | ||||
|     "eslint": "^8.41.0" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "eslint-plugin-antfu", | ||||
|   "version": "0.38.5", | ||||
|   "version": "0.39.4", | ||||
|   "license": "MIT", | ||||
|   "homepage": "https://github.com/antfu/eslint-config", | ||||
|   "main": "./dist/index.cjs", | ||||
| @@ -16,11 +16,11 @@ | ||||
|     "prepublishOnly": "nr build" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@typescript-eslint/utils": "^5.59.0" | ||||
|     "@typescript-eslint/utils": "^5.59.7" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/node": "^18.15.11", | ||||
|     "@types/node": "^20.2.3", | ||||
|     "unbuild": "^1.2.1", | ||||
|     "vitest": "^0.30.1" | ||||
|     "vitest": "^0.31.1" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -3,6 +3,8 @@ import ifNewline from './rules/if-newline' | ||||
| import importDedupe from './rules/import-dedupe' | ||||
| import preferInlineTypeImport from './rules/prefer-inline-type-import' | ||||
| import topLevelFunction from './rules/top-level-function' | ||||
| import noTsExportEqual from './rules/no-ts-export-equal' | ||||
| import noCjsExports from './rules/no-cjs-exports' | ||||
|  | ||||
| export default { | ||||
|   rules: { | ||||
| @@ -11,5 +13,7 @@ export default { | ||||
|     'prefer-inline-type-import': preferInlineTypeImport, | ||||
|     'generic-spacing': genericSpacing, | ||||
|     'top-level-function': topLevelFunction, | ||||
|     'no-cjs-exports': noCjsExports, | ||||
|     'no-ts-export-equal': noTsExportEqual, | ||||
|   }, | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,28 @@ | ||||
| import { RuleTester } from '@typescript-eslint/utils/dist/ts-eslint' | ||||
| import { it } from 'vitest' | ||||
| import rule, { RULE_NAME } from './no-cjs-exports' | ||||
|  | ||||
| const valids = [ | ||||
|   { code: 'export = {}', filename: 'test.ts' }, | ||||
|   { code: 'exports.a = {}', filename: 'test.js' }, | ||||
|   { code: 'module.exports.a = {}', filename: 'test.js' }, | ||||
| ] | ||||
|  | ||||
| const invalids = [ | ||||
|   { code: 'exports.a = {}', filename: 'test.ts' }, | ||||
|   { code: 'module.exports.a = {}', filename: 'test.ts' }, | ||||
| ] | ||||
|  | ||||
| it('runs', () => { | ||||
|   const ruleTester: RuleTester = new RuleTester({ | ||||
|     parser: require.resolve('@typescript-eslint/parser'), | ||||
|   }) | ||||
|  | ||||
|   ruleTester.run(RULE_NAME, rule, { | ||||
|     valid: valids, | ||||
|     invalid: invalids.map(i => ({ | ||||
|       ...i, | ||||
|       errors: [{ messageId: 'noCjsExports' }], | ||||
|     })), | ||||
|   }) | ||||
| }) | ||||
							
								
								
									
										41
									
								
								packages/eslint-plugin-antfu/src/rules/no-cjs-exports.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								packages/eslint-plugin-antfu/src/rules/no-cjs-exports.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| import { createEslintRule } from '../utils' | ||||
|  | ||||
| export const RULE_NAME = 'no-cjs-exports' | ||||
| export type MessageIds = 'noCjsExports' | ||||
| export type Options = [] | ||||
|  | ||||
| export default createEslintRule<Options, MessageIds>({ | ||||
|   name: RULE_NAME, | ||||
|   meta: { | ||||
|     type: 'problem', | ||||
|     docs: { | ||||
|       description: 'Do not use CJS exports', | ||||
|       recommended: false, | ||||
|     }, | ||||
|     schema: [], | ||||
|     messages: { | ||||
|       noCjsExports: 'Use ESM export instead', | ||||
|     }, | ||||
|   }, | ||||
|   defaultOptions: [], | ||||
|   create: (context) => { | ||||
|     const extension = context.getFilename().split('.').pop() | ||||
|     if (!['ts', 'tsx', 'mts', 'cts'].includes(extension)) | ||||
|       return {} | ||||
|  | ||||
|     return { | ||||
|       'MemberExpression[object.name="exports"]': function (node) { | ||||
|         context.report({ | ||||
|           node, | ||||
|           messageId: 'noCjsExports', | ||||
|         }) | ||||
|       }, | ||||
|       'MemberExpression[object.name="module"][property.name="exports"]': function (node) { | ||||
|         context.report({ | ||||
|           node, | ||||
|           messageId: 'noCjsExports', | ||||
|         }) | ||||
|       }, | ||||
|     } | ||||
|   }, | ||||
| }) | ||||
| @@ -0,0 +1,26 @@ | ||||
| import { RuleTester } from '@typescript-eslint/utils/dist/ts-eslint' | ||||
| import { it } from 'vitest' | ||||
| import rule, { RULE_NAME } from './no-ts-export-equal' | ||||
|  | ||||
| const valids = [ | ||||
|   { code: 'export default {}', filename: 'test.ts' }, | ||||
|   { code: 'export = {}', filename: 'test.js' }, | ||||
| ] | ||||
|  | ||||
| const invalids = [ | ||||
|   { code: 'export = {}', filename: 'test.ts' }, | ||||
| ] | ||||
|  | ||||
| it('runs', () => { | ||||
|   const ruleTester: RuleTester = new RuleTester({ | ||||
|     parser: require.resolve('@typescript-eslint/parser'), | ||||
|   }) | ||||
|  | ||||
|   ruleTester.run(RULE_NAME, rule, { | ||||
|     valid: valids, | ||||
|     invalid: invalids.map(i => ({ | ||||
|       ...i, | ||||
|       errors: [{ messageId: 'noTsExportEqual' }], | ||||
|     })), | ||||
|   }) | ||||
| }) | ||||
							
								
								
									
										35
									
								
								packages/eslint-plugin-antfu/src/rules/no-ts-export-equal.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								packages/eslint-plugin-antfu/src/rules/no-ts-export-equal.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| import { createEslintRule } from '../utils' | ||||
|  | ||||
| export const RULE_NAME = 'no-ts-export-equal' | ||||
| export type MessageIds = 'noTsExportEqual' | ||||
| export type Options = [] | ||||
|  | ||||
| export default createEslintRule<Options, MessageIds>({ | ||||
|   name: RULE_NAME, | ||||
|   meta: { | ||||
|     type: 'problem', | ||||
|     docs: { | ||||
|       description: 'Do not use `exports =`', | ||||
|       recommended: false, | ||||
|     }, | ||||
|     schema: [], | ||||
|     messages: { | ||||
|       noTsExportEqual: 'Use ESM `export default` instead', | ||||
|     }, | ||||
|   }, | ||||
|   defaultOptions: [], | ||||
|   create: (context) => { | ||||
|     const extension = context.getFilename().split('.').pop() | ||||
|     if (!['ts', 'tsx', 'mts', 'cts'].includes(extension)) | ||||
|       return {} | ||||
|  | ||||
|     return { | ||||
|       TSExportAssignment(node) { | ||||
|         context.report({ | ||||
|           node, | ||||
|           messageId: 'noTsExportEqual', | ||||
|         }) | ||||
|       }, | ||||
|     } | ||||
|   }, | ||||
| }) | ||||
							
								
								
									
										665
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										665
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user