Skip to content

Commit

Permalink
fix: eslint and prettier
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Dec 5, 2023
1 parent 51be898 commit d219301
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 89 deletions.
3 changes: 0 additions & 3 deletions .prettierrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { factory } from '@zolplay/prettier-config'

export default factory({ tailwindcss: false })
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ module.exports = {
### Prettier

```js
// .prettierrc.js
// .prettierrc.mjs
import config from '@zolplay/prettier-config'

module.exports = {
...require('@zolplay/prettier-config'),
// your configurations
}
export default config

// or
import { factory } from '@zolplay/prettier-config'

export default factory({ tailwindcss:true,importSort:true })
```

## IDE Settings
Expand Down
13 changes: 3 additions & 10 deletions packages/eslint-config-basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
'plugin:jsonc/recommended-with-jsonc',
'plugin:yml/standard',
'plugin:markdown/recommended',
'prettier',
],
ignorePatterns: [
'*.min.*',
Expand Down Expand Up @@ -46,14 +45,7 @@ module.exports = {
'.vitepress/cache',
'.turbo',
],
plugins: [
'html',
'unicorn',
'antfu',
'no-only-tests',
'unused-imports',
'prettier',
],
plugins: ['html', 'unicorn', 'antfu', 'no-only-tests', 'unused-imports'],
settings: {
'import/resolver': {
node: { extensions: ['.js', '.mjs'] },
Expand Down Expand Up @@ -215,14 +207,15 @@ module.exports = {
},
],
rules: {
'prettier/prettier': 'error',
// import
'import/first': 'error',
'import/no-mutable-exports': 'error',
'import/no-unresolved': 'off',
'import/no-absolute-path': 'off',
'import/newline-after-import': 'off',

'comma-dangle': 0,

'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'warn',
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"lint": "eslint . --config=index.js"
},
"dependencies": {
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-antfu": "^0.39.7",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-html": "^7.1.0",
Expand All @@ -18,7 +17,6 @@
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unicorn": "^47.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
Expand All @@ -32,4 +30,4 @@
"peerDependencies": {
"eslint": ">=7.4.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"peerDependencies": {
"eslint": ">=7.4.0"
}
}
}
48 changes: 24 additions & 24 deletions packages/prettier/base.mjs
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { createRequire } from 'node:module'
import { createRequire } from "node:module";

const require = createRequire(import.meta.url)
const require = createRequire(import.meta.url);

export const baseConfig = {
tabWidth: 2,
printWidth: 80,
semi: false,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'always',
endOfLine: 'lf',
trailingComma: "all",
arrowParens: "always",
endOfLine: "lf",

jsxSingleQuote: false,

useTabs: false,

plugins: [
require.resolve('prettier-package-json'),
require.resolve('prettier-plugin-autocorrect'),
require.resolve('prettier-plugin-sh'),
require.resolve("prettier-package-json"),
require.resolve("prettier-plugin-autocorrect"),
require.resolve("prettier-plugin-sh"),
],

importOrder: [
'react',
'<THIRD_PARTY_MODULES>',
'<TYPES>',
'<TYPES>^[.]',
'',
"react",
"<THIRD_PARTY_MODULES>",
"<TYPES>",
"<TYPES>^[.]",
"",

'^@(.*)/(.*)$',
'',
'^~/(.*)$',
'',
'^@/(.*)$',
'',
'^[./]',
'',
'^(?!.*[.]css$)[./].*$',
'.css$',
"^@(.*)/(.*)$",
"",
"^~/(.*)$",
"",
"^@/(.*)$",
"",
"^[./]",
"",
"^(?!.*[.]css$)[./].*$",
".css$",
],
}
};
1 change: 1 addition & 0 deletions packages/prettier/index.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRequire } from 'node:module'

import { baseConfig } from './base.mjs'

const require = createRequire(import.meta.url)
Expand Down
4 changes: 4 additions & 0 deletions packages/prettier/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface PrettierConfigOptions {
tailwindcss?: boolean;
importSort?: boolean;
}
44 changes: 1 addition & 43 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d219301

Please sign in to comment.