@phaicom/eslint-config 0.1.4 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,27 +1,116 @@
1
1
  # `@phaicom/eslint-config`
2
2
 
3
- phaicom's ESLint configuration.
3
+ Personal ESLint configuration preset.
4
4
 
5
- - Based on [antfu/eslint-config](https://github.com/antfu/eslint-config).
6
- - Enable all unicorn config.
7
- - Forced to always use curly.
8
- - Modified rules including unicorn, stylistic, Vue, etc.
9
- - Integrated with [eslint-plugin-readable-tailwind](https://github.com/schoero/eslint-plugin-readable-tailwind).
5
+ Features:
6
+ - Built on [antfu/eslint-config](https://github.com/antfu/eslint-config)
7
+ - Enforces curly brackets for all blocks
8
+ - Custom rule sets for unicorn, stylistic, and Vue
9
+ - Tailwind support with [eslint-plugin-readable-tailwind](https://github.com/schoero/eslint-plugin-readable-tailwind)
10
10
 
11
- ## Usage with tailwind
12
- Start by install **eslint-plugin-readable-tailwind**
11
+ ## Usage
13
12
 
13
+ 1. Install the package:
14
14
  ```bash
15
- pnpm install -D eslint-plugin-readable-tailwind@beta
15
+ pnpm i -D @phaicom/eslint-config
16
16
  ```
17
17
 
18
- And set the **tailwind** flag to true.
18
+ 2. Create `eslint.config.mjs` in your project root:
19
+ ```js
20
+ // eslint.config.mjs
21
+ import configs from '@phaicom/eslint-config'
22
+
23
+ export default configs()
24
+ ```
25
+
26
+ 3. Configure VS Code:
27
+ - Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
28
+ - Add the following settings to `.vscode/settings.json`:
29
+
30
+ ```jsonc
31
+ {
32
+ // Disable the default formatter, use eslint instead
33
+ "prettier.enable": false,
34
+ "editor.formatOnSave": false,
35
+
36
+ // Auto fix
37
+ "editor.codeActionsOnSave": {
38
+ "source.fixAll.eslint": "explicit",
39
+ "source.organizeImports": "never"
40
+ },
41
+
42
+ // Silent the stylistic rules in you IDE, but still auto fix them
43
+ "eslint.rules.customizations": [
44
+ { "rule": "style/*", "severity": "off", "fixable": true },
45
+ { "rule": "format/*", "severity": "off", "fixable": true },
46
+ { "rule": "*-indent", "severity": "off", "fixable": true },
47
+ { "rule": "*-spacing", "severity": "off", "fixable": true },
48
+ { "rule": "*-spaces", "severity": "off", "fixable": true },
49
+ { "rule": "*-order", "severity": "off", "fixable": true },
50
+ { "rule": "*-dangle", "severity": "off", "fixable": true },
51
+ { "rule": "*-newline", "severity": "off", "fixable": true },
52
+ { "rule": "*quotes", "severity": "off", "fixable": true },
53
+ { "rule": "*semi", "severity": "off", "fixable": true }
54
+ ],
55
+
56
+ // Enable eslint for all supported languages
57
+ "eslint.validate": [
58
+ "javascript",
59
+ "javascriptreact",
60
+ "typescript",
61
+ "typescriptreact",
62
+ "vue",
63
+ "html",
64
+ "markdown",
65
+ "json",
66
+ "jsonc",
67
+ "yaml",
68
+ "toml",
69
+ "xml",
70
+ "gql",
71
+ "graphql",
72
+ "astro",
73
+ "svelte",
74
+ "css",
75
+ "less",
76
+ "scss",
77
+ "pcss",
78
+ "postcss"
79
+ ]
80
+ }
81
+ ```
82
+
83
+ ## Disable base rules
84
+ You can disable the base rules by setting `phaicom: false`:
19
85
 
20
86
  ```js
21
- import phaicom from '@phaicom/eslint-config'
87
+ // eslint.config.mjs
88
+ import configs from '@phaicom/eslint-config'
22
89
 
23
- export default phaicom({
90
+ export default configs({
91
+ phaicom: false,
92
+ })
93
+ ```
94
+
95
+ ## Tailwind Support
96
+ To enable Tailwind support and enforce consistent class ordering:
97
+
98
+ 1. Install the required plugin:
99
+ ```bash
100
+ pnpm i -D eslint-plugin-readable-tailwind@beta
101
+ ```
102
+
103
+ 2. Enable Tailwind support in your config:
104
+ ```js
105
+ // eslint.config.mjs
106
+ import configs from '@phaicom/eslint-config'
107
+
108
+ export default configs({
24
109
  tailwind: true,
25
110
  })
26
111
  ```
27
- The rest of the config you can refer to https://github.com/antfu/eslint-config
112
+
113
+ This will enforce consistent ordering of Tailwind classes for better readability.
114
+ ## Additional Configurations
115
+
116
+ For other configuration options like TypeScript, Vue, React, Prettier, and more, please refer to [antfu/eslint-config](https://github.com/antfu/eslint-config).
package/dist/index.d.ts CHANGED
@@ -4,7 +4,11 @@ type EslintConfigReturn = ReturnType<typeof antfu>;
4
4
  type UserConfigParams = Parameters<typeof antfu>[1];
5
5
  interface OptionsConfig extends OptionsConfig$1, TypedFlatConfigItem {
6
6
  /**
7
- *
7
+ * Used phaicom's base rules:
8
+ * @default true
9
+ */
10
+ phaicom?: boolean;
11
+ /**
8
12
  * Used recommended rules:
9
13
  * @see https://github.com/schoero/eslint-plugin-readable-tailwind
10
14
  * @default false
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
1
  // src/index.ts
2
2
  import antfu from "@antfu/eslint-config";
3
- import pluginReadableTailwind from "eslint-plugin-readable-tailwind";
4
3
 
5
- // src/base.ts
6
- var baseConfig = {
4
+ // src/configs/base.ts
5
+ var base = {
7
6
  name: "phaicom/base",
8
7
  rules: {
9
8
  "curly": ["error", "all"],
@@ -36,7 +35,7 @@ var baseConfig = {
36
35
  "node/prefer-global/process": "off"
37
36
  }
38
37
  };
39
- var vueConfig = {
38
+ var vue = {
40
39
  name: "phaicom/vue",
41
40
  rules: {
42
41
  // vue rule customizations
@@ -48,41 +47,44 @@ var vueConfig = {
48
47
  "vue/singleline-html-element-content-newline": "off"
49
48
  }
50
49
  };
50
+ var phaicom = { base, vue };
51
+ var base_default = phaicom;
51
52
 
52
- // src/index.ts
53
- var eslintConfig = ({ tailwind = false, ...options }, ...configs) => {
54
- if (tailwind) {
55
- const baseFiles = ["**/*.js"];
56
- const frameworkExtensions = {
57
- typescript: ["ts"],
58
- react: ["jsx", options.typescript && "tsx"],
59
- solid: ["jsx", options.typescript && "tsx"],
60
- vue: ["vue"],
61
- astro: ["astro"],
62
- svelte: ["svelte"]
63
- };
64
- const files = [
65
- ...baseFiles,
66
- ...Object.entries(frameworkExtensions).filter(([framework]) => options[framework]).flatMap(([, exts]) => exts.filter(Boolean).map((ext) => `**/*.${ext}`))
67
- ];
68
- configs.unshift({
53
+ // src/configs/tailwind.ts
54
+ import { interopDefault } from "@antfu/eslint-config";
55
+ async function tailwind() {
56
+ const [
57
+ pluginTailwind
58
+ ] = await Promise.all([
59
+ interopDefault(import("eslint-plugin-readable-tailwind"))
60
+ ]);
61
+ return [
62
+ {
69
63
  name: "phaicom/tailwind",
70
- files,
71
64
  plugins: {
72
- "readable-tailwind": pluginReadableTailwind
65
+ "readable-tailwind": pluginTailwind
73
66
  },
74
67
  rules: {
75
68
  // enable all recommended rules to error
76
- ...pluginReadableTailwind.configs.error.rules
69
+ ...pluginTailwind.configs.error.rules
77
70
  }
78
- });
79
- }
80
- const userConfigs = [
81
- baseConfig,
82
- ...options.vue ? [vueConfig] : []
71
+ }
83
72
  ];
84
- options.unicorn = true;
85
- return antfu(options, ...userConfigs, ...configs);
73
+ }
74
+
75
+ // src/index.ts
76
+ var eslintConfig = ({ phaicom: enablePhaicom = true, tailwind: enableTailwind = false, ...options }, ...configs) => {
77
+ if (enableTailwind) {
78
+ configs.push(tailwind());
79
+ }
80
+ if (enablePhaicom) {
81
+ options.unicorn = true;
82
+ configs.push(base_default.base);
83
+ if (options.vue) {
84
+ configs.push(base_default.vue);
85
+ }
86
+ }
87
+ return antfu(options, ...configs);
86
88
  };
87
89
  var index_default = eslintConfig;
88
90
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@phaicom/eslint-config",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.2.1",
5
5
  "description": "Phaicom's config based on @antfu/eslint-config",
6
6
  "author": "Reawpai Chunsoi <reawpai.chunsoi@gmail.com> (https://github.com/phaicom)",
7
7
  "license": "MIT",