Skip to content

Commit

Permalink
build: 修改 package.json,项目默认为 ES Module
Browse files Browse the repository at this point in the history
- 升级 eslint,并使用 @antfu/eslint-config
- 移除 prettier
- 升级 stylelint 及相关依赖
- 修改 .mjs 文件为 .js
  • Loading branch information
1zumii committed Apr 19, 2024
1 parent 93d4da6 commit b85bc25
Show file tree
Hide file tree
Showing 37 changed files with 9,661 additions and 7,236 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

65 changes: 0 additions & 65 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Generate Release Notes
run: |
./.github/workflows/release-notes.mjs ${{ env.RELEASE_VERSION }}
./.github/workflows/release-notes.js ${{ env.RELEASE_VERSION }}
cat notes-${{ env.RELEASE_VERSION }}.md
- name: Create Release for Tag
Expand Down
8 changes: 0 additions & 8 deletions .prettierrc.js

This file was deleted.

7 changes: 3 additions & 4 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module.exports = {
/** @type {import('stylelint').Config} */
export default {
extends: [
'stylelint-config-standard',
'stylelint-config-rational-order',
'stylelint-config-prettier', // 排除与 prettier 冲突的 rule
],
plugins: ['stylelint-declaration-block-no-ignored-properties'],
// https://stylelint.docschina.org/user-guide/rules/
rules: {
indentation: 4,
'no-empty-source': null,
'max-empty-lines': 2,
'no-duplicate-selectors': null,
'at-rule-no-unknown': null,
'comment-empty-line-before': null,
Expand All @@ -22,6 +20,7 @@ module.exports = {
'property-no-vendor-prefix': null,
'keyframes-name-pattern': null,
'value-no-vendor-prefix': null,
'import-notation': null,
},
// https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-14.md
overrides: [
Expand Down
6 changes: 6 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"words": [
"unref",
"cascader"
]
}
11 changes: 5 additions & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"stylelint.vscode-stylelint",
"dbaeumer.vscode-eslint",
]
}
"recommendations": [
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint"
]
}
49 changes: 27 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
{
// 防止编辑器内置linter与插件冲突设置
"css.validate": false,
"less.validate": false,
"stylelint.validate": ["less"],
// 每次保存的时候将代码按 eslint 格式进行修复
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit"
},
// json 文件按 prettier 规范格式化
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// md 文件按 prettier 规范格式化
"[md]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"prettier.printWidth": 180,
"cSpell.words": ["unref"]
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.fixAll.stylelint": "explicit", // stylelint
"source.organizeImports": "never"
},
// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"gql",
"graphql"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ import {CloseCircleFilled} from '@fesjs/fes-design/icon';

| Github Issue | Fes.js开源运营小助手 |
| --- | --- |
| [@fesjs/fes-design](../../issues) | <img src="https://cos-1254145788.cos.ap-guangzhou.myqcloud.com/WechatIMG104.jpeg" height="250"/>
| [@fesjs/fes-design](../../issues) | <img src="https://cos-1254145788.cos.ap-guangzhou.myqcloud.com/WechatIMG104.jpeg" height="250"/>
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// for jest
module.exports = {
export default {
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
plugins: ['@vue/babel-plugin-jsx'],
};
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
export default { extends: ['@commitlint/config-conventional'] };
9 changes: 5 additions & 4 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path from 'path';
import { withPwa } from '@vite-pwa/vitepress';
import vueJsx from '@vitejs/plugin-vue-jsx';
import path from 'node:path';
import process from 'node:process';
import { defineConfig } from 'vitepress';
import { withPwa } from '@vite-pwa/vitepress';
import { getProjectRootDir } from '../../scripts/utils.mjs';
import { genComponentDocWatch } from '../../scripts/genComponentDoc.mjs';
import { genComponentDocWatch } from '../../scripts/genComponentDoc.js';
import { getProjectRootDir } from '../../scripts/utils.js';
import { navbar, sidebar } from './configs/index';
import { pwa } from './pwa';

Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/configs/navbar/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type DefaultTheme } from 'vitepress';
import { getPackageJsonVersion } from '../../../../scripts/utils.mjs';
import type { DefaultTheme } from 'vitepress';
import { getPackageJsonVersion } from '../../../../scripts/utils.js';

const currentVersion = getPackageJsonVersion();

Expand Down
3 changes: 0 additions & 3 deletions docs/package.json

This file was deleted.

61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import config from '@antfu/eslint-config';

export default config({
stylistic: {
indent: 4,
quotes: 'single',
semi: true,
},
ignores: [
'!docs/.vitepress',
'!docs/.vitepress/**',
'es',
'**/es/**',
'lib',
'**/lib/**',
'dist',
'**/dist/**',
'empty.ts',
'**/empty.ts/**',
'docs/.vitepress/vueTheme',
'docs/.vitepress/vueTheme/**',
],
vue: true,
typescript: {
// parserOptions: {
// // https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file
// project: './tsconfig.eslint.json',
// // https://typescript-eslint.io/linting/troubleshooting/#i-use-a-framework-like-vue-that-requires-custom-file-extensions-and-i-get-errors-like-you-should-add-parseroptionsextrafileextensions-to-your-config
// extraFileExtensions: ['.vue'],
// },
tsconfigPath: './tsconfig.eslint.json',
},
rules: {
'curly': ['error', 'all'],
'antfu/top-level-function': ['off'],
'style/brace-style': ['error', '1tbs'],
'style/arrow-parens': ['error', 'always'],
'vue/block-order': ['error', {
order: [['script', 'template'], 'style'],
}],
'ts/consistent-type-definitions': ['off'],
'ts/consistent-type-imports': ['error', {
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
}],

// TODO: need discuss
'vue/attribute-hyphenation': ['off'],
'vue/v-on-event-hyphenation': ['off'],
},
}, {
files: ['**/*.json'],
rules: {
'jsonc/indent': ['error', 2],
},
}, {
files: ['**/*.yml'],
rules: {
'yaml/indent': ['error', 2],
},
});
File renamed without changes.
Loading

0 comments on commit b85bc25

Please sign in to comment.