@tommy-mitchell/eslint-config-xo 0.7.0 → 1.0.0-0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tommy-mitchell/eslint-config-xo",
3
- "version": "0.7.0",
3
+ "version": "1.0.0-0",
4
4
  "description": "Personal config for XO.",
5
5
  "keywords": [
6
6
  "nodejs",
@@ -14,40 +14,41 @@
14
14
  "url": "https://tommymitchell.io"
15
15
  },
16
16
  "sideEffects": false,
17
+ "type": "module",
17
18
  "files": [
18
- "dprint.js",
19
- "index.js",
20
- "react.js",
21
- "tailwind.js"
19
+ "src"
22
20
  ],
21
+ "exports": {
22
+ "types": "./src/index.d.ts",
23
+ "default": "./src/index.js"
24
+ },
23
25
  "scripts": {
24
26
  "format": "dprint fmt && xo --fix",
25
27
  "lint": "xo",
26
28
  "test": "ava"
27
29
  },
28
30
  "dependencies": {
29
- "eslint-config-xo-react": "^0.27.0",
30
- "eslint-plugin-dprint-integration": "^0.3.0",
31
- "eslint-plugin-jsx-a11y": "^6.9.0",
32
- "eslint-plugin-perfectionist": "^3.2.0",
33
- "eslint-plugin-react": "^7.35.0",
34
- "eslint-plugin-react-hooks": "^4.6.2",
35
- "eslint-plugin-react-refresh": "^0.4.9",
36
- "eslint-plugin-readable-tailwind": "^1.7.0",
31
+ "eslint-plugin-jsx-a11y": "^6.10.2",
32
+ "eslint-plugin-perfectionist": "^4.7.0",
33
+ "eslint-plugin-react-refresh": "^0.4.18",
34
+ "eslint-plugin-readable-tailwind": "^1.9.0",
37
35
  "eslint-plugin-simple-import-sort": "^12.1.1",
38
36
  "eslint-plugin-sort-react-dependency-arrays": "^1.0.0",
39
- "eslint-plugin-tailwindcss": "^3.17.4"
37
+ "eslint-plugin-tailwindcss": "^3.18.0"
40
38
  },
41
39
  "devDependencies": {
42
- "@tommy-mitchell/dprint-config": "^0.2.0",
43
- "ava": "^6.1.3",
40
+ "@stylistic/eslint-plugin": "^3.0.1",
41
+ "@tommy-mitchell/dprint-config": "^0.4.0",
42
+ "ava": "^6.2.0",
44
43
  "dprint": "0.x",
45
- "execa": "^9.3.0",
46
- "xo": "0.x"
44
+ "eslint-plugin-react": "^7.37.4",
45
+ "execa": "^9.5.2",
46
+ "tempy": "^3.1.0",
47
+ "xo": "npm:@spence-s/flat-xo@latest"
47
48
  },
48
49
  "peerDependencies": {
49
50
  "dprint": "0.x",
50
- "react": "18.x",
51
+ "react": "19.x",
51
52
  "tailwindcss": "3.x",
52
53
  "xo": "0.x"
53
54
  },
@@ -63,6 +64,9 @@
63
64
  }
64
65
  },
65
66
  "engines": {
66
- "node": "^18.18 || ^20.8 || >=21"
67
+ "node": "^18.20 || ^20.10 || >=21"
68
+ },
69
+ "ava": {
70
+ "timeout": "30s"
67
71
  }
68
72
  }
package/readme.md CHANGED
@@ -5,7 +5,7 @@ Personal config for [`XO`](https://github.com/xojs/xo). Recommended to be used w
5
5
  ## Install
6
6
 
7
7
  ```sh
8
- npm install --save-dev @tommy-mitchell/eslint-config-xo xo @tommy-mitchell/dprint-config dprint
8
+ npm install --save-dev @tommy-mitchell/eslint-config-xo xo
9
9
  ```
10
10
 
11
11
  <details>
@@ -13,49 +13,47 @@ npm install --save-dev @tommy-mitchell/eslint-config-xo xo @tommy-mitchell/dprin
13
13
  <p>
14
14
 
15
15
  ```sh
16
- yarn add --dev @tommy-mitchell/eslint-config-xo xo @tommy-mitchell/dprint-config dprint
16
+ yarn add --dev @tommy-mitchell/eslint-config-xo xo
17
17
  ```
18
18
 
19
19
  </p>
20
20
  </details>
21
21
 
22
- ### Peer Dependencies
23
-
24
- - [xo](https://github.com/xojs/xo) - JavaScript/TypeScript linter (ESLint wrapper) with great defaults.
25
- - [dprint](https://github.com/dprint/dprint) (*Optional*) - Pluggable and configurable code formatting platform written in Rust.
26
- - [react](https://react.dev) (*Optional*) - The library for web and native user interfaces.
27
- - [tailwindcss](https://tailwindcss.com) (*Optional*) - A utility-first CSS framework for rapid UI development.
28
-
29
- ## Usage
30
-
31
- Add to the `extends` section of your `XO` config:
22
+ <details>
23
+ <summary>With dprint</summary>
24
+ <p>
32
25
 
33
- ```jsonc
34
- "extends": ["@tommy-mitchell/xo"],
26
+ ```sh
27
+ npm install --save-dev @tommy-mitchell/eslint-config-xo xo @tommy-mitchell/dprint-config dprint
35
28
  ```
36
29
 
37
- ### dprint
38
-
39
- ```jsonc
40
- "extends": ["@tommy-mitchell/xo", "@tommy-mitchell/xo/dprint"],
30
+ ```sh
31
+ yarn add --dev @tommy-mitchell/eslint-config-xo xo @tommy-mitchell/dprint-config dprint
41
32
  ```
42
33
 
43
- ### React
34
+ </p>
35
+ </details>
44
36
 
45
- ```jsonc
46
- "extends": ["@tommy-mitchell/xo", "@tommy-mitchell/xo/react"],
47
- ```
37
+ ### Peer Dependencies
48
38
 
49
- #### React + dprint
39
+ - [xo](https://github.com/xojs/xo) - JavaScript/TypeScript linter (ESLint wrapper) with great defaults.
40
+ - [dprint](https://github.com/dprint/dprint) (*Optional*) - Pluggable and configurable code formatting platform written in Rust.
41
+ - [react](https://react.dev) (*Optional*) - The library for web and native user interfaces.
42
+ - [tailwindcss](https://tailwindcss.com) (*Optional*) - A utility-first CSS framework for rapid UI development.
50
43
 
51
- ```jsonc
52
- "extends": ["@tommy-mitchell/xo", "@tommy-mitchell/xo/react", "@tommy-mitchell/xo/dprint"],
53
- ```
44
+ ## Usage (Flat Config)
54
45
 
55
- ### Tailwind CSS
46
+ ```js
47
+ // xo.config.js
48
+ import * as configs from "@tommy-mitchell/eslint-config-xo";
56
49
 
57
- ```jsonc
58
- "extends": ["@tommy-mitchell/xo", "@tommy-mitchell/xo/tailwind"],
50
+ export default [
51
+ ...configs.xo,
52
+ ...configs.react, // If using React
53
+ ...configs.tailwind, // If using Tailwind CSS
54
+ ...configs.dprint, // If using dprint (must be last to override stylistic rules)
55
+ // Plus any overrides
56
+ ]
59
57
  ```
60
58
 
61
59
  ### VS Code
@@ -66,6 +64,19 @@ Add the following to your `settings.json`:
66
64
  "xo.enable": true,
67
65
  "xo.format.enable": true,
68
66
  "xo.overrideSeverity": "warn",
67
+ "xo.debounce": 100,
68
+ ```
69
+
70
+ If formatting with `dprint`:
71
+
72
+ ```jsonc
73
+ "[javascript][javascriptreact][typescript][typescriptreact]": {
74
+ "editor.formatOnSave": true,
75
+ "editor.defaultFormatter": "dprint.dprint",
76
+ "editor.codeActionsOnSave": {
77
+ "source.fixAll": "explicit", // Will run lint autofixes
78
+ },
79
+ },
69
80
  ```
70
81
 
71
82
  ## Related
package/src/dprint.js ADDED
@@ -0,0 +1,22 @@
1
+ import stylistic from "@stylistic/eslint-plugin";
2
+
3
+ // TODO: eslint unicorn rule proposal
4
+ const allowedRules = new Set(["padding-line-between-statements"]);
5
+ const disabledRules = Object.fromEntries(
6
+ Object.keys(stylistic.rules)
7
+ .filter(rule => !allowedRules.has(rule))
8
+ .map(rule => [`@stylistic/${rule}`, "off"]),
9
+ );
10
+
11
+ export default [
12
+ {
13
+ rules: {
14
+ "arrow-body-style": "off",
15
+ "curly": "off",
16
+ "no-arrow-condition": "off",
17
+ "no-comma-dangle": "off",
18
+ },
19
+ },
20
+ stylistic.configs["disable-legacy"],
21
+ { rules: disabledRules },
22
+ ];
package/src/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { FlatXoConfig } from "xo";
2
+
3
+ export declare const dprint: FlatXoConfig;
4
+ export declare const react: FlatXoConfig;
5
+ export declare const tailwind: FlatXoConfig;
6
+ export declare const xo: FlatXoConfig;
package/src/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { default as dprint } from "./dprint.js";
2
+ export { default as react } from "./react.js";
3
+ export { default as tailwind } from "./tailwind.js";
4
+ export { default as xo } from "./xo.js";
package/src/react.js ADDED
@@ -0,0 +1,52 @@
1
+ import jsxA11y from "eslint-plugin-jsx-a11y";
2
+ import react from "eslint-plugin-react";
3
+ import reactRefresh from "eslint-plugin-react-refresh";
4
+ import sortReactDependencyArrays from "eslint-plugin-sort-react-dependency-arrays";
5
+
6
+ const configs = [
7
+ react.configs.flat["jsx-runtime"],
8
+ jsxA11y.flatConfigs.recommended,
9
+ ];
10
+
11
+ export default [...configs, {
12
+ plugins: {
13
+ "react-refresh": reactRefresh,
14
+ "sort-react-dependency-arrays": sortReactDependencyArrays,
15
+ },
16
+ rules: {
17
+ "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
18
+ "react/no-array-index-key": "warn",
19
+ "simple-import-sort/imports": ["error", {
20
+ groups: [[
21
+ String.raw`^\u0000`,
22
+ "^node:",
23
+ "^react",
24
+ "^react-dom",
25
+ String.raw`^@?\w`,
26
+ "^",
27
+ String.raw`^\.`,
28
+ String.raw`^.+\.s?css$`,
29
+ ]],
30
+ }],
31
+ "sort-react-dependency-arrays/sort": "error",
32
+ "unicorn/filename-case": ["error", {
33
+ cases: {
34
+ camelCase: true,
35
+ kebabCase: true,
36
+ pascalCase: true,
37
+ },
38
+ }],
39
+ },
40
+ }, {
41
+ files: "**/*.{ts,cts,mts,tsx}",
42
+ rules: {
43
+ "perfectionist/sort-interfaces": ["error", {
44
+ customGroups: { callback: "on*" },
45
+ groups: ["unknown", "callback"],
46
+ }],
47
+ "perfectionist/sort-object-types": ["error", {
48
+ customGroups: { callback: "on*" },
49
+ groups: ["unknown", "callback"],
50
+ }],
51
+ },
52
+ }];
@@ -1,11 +1,12 @@
1
- "use strict";
1
+ import eslintPluginReadableTailwind from "eslint-plugin-readable-tailwind";
2
+ import tailwind from "eslint-plugin-tailwindcss";
2
3
 
3
- module.exports = {
4
- extends: ["plugin:tailwindcss/recommended"],
5
- plugins: ["readable-tailwind"],
4
+ export default [...tailwind.configs["flat/recommended"], {
5
+ plugins: {
6
+ "readable-tailwind": eslintPluginReadableTailwind,
7
+ },
6
8
  rules: {
7
9
  "readable-tailwind/multiline": ["warn", {
8
- group: "newLine",
9
10
  indent: "tab",
10
11
  preferSingleLine: true,
11
12
  printWidth: 120,
@@ -18,4 +19,4 @@ module.exports = {
18
19
  callees: ["classnames", "clsx", "ctl", "cva", "tv", "tva", "tw", "twMerge", "cn", "cnx"],
19
20
  }],
20
21
  },
21
- };
22
+ }];
package/src/xo.js ADDED
@@ -0,0 +1,71 @@
1
+ import perfectionist from "eslint-plugin-perfectionist";
2
+ import simpleImportSort from "eslint-plugin-simple-import-sort";
3
+
4
+ export default [{
5
+ plugins: {
6
+ perfectionist,
7
+ "simple-import-sort": simpleImportSort,
8
+ },
9
+ rules: {
10
+ // https://github.com/xojs/eslint-config-xo/blob/v0.44.0/index.js#L304
11
+ "capitalized-comments": "off",
12
+ "import-x/extensions": "off",
13
+ "import-x/order": "off",
14
+ // https://github.com/xojs/eslint-config-xo/blob/v0.44.0/index.js#L186
15
+ "no-warning-comments": ["warn", { decoration: ["/", "*"] }],
16
+ "object-shorthand": "off",
17
+ "perfectionist/sort-array-includes": "error",
18
+ "perfectionist/sort-maps": "error",
19
+ // maybe: perfectionist/sort-modules
20
+ "perfectionist/sort-objects": "error",
21
+ "perfectionist/sort-sets": "error",
22
+ // TODO: doesn't play nice with unicorn/switch-case-braces: https://github.com/azat-io/eslint-plugin-perfectionist/issues/54#issuecomment-2268283085
23
+ "perfectionist/sort-switch-case": "error",
24
+ "simple-import-sort/exports": "error",
25
+ "simple-import-sort/imports": ["error", {
26
+ groups: [[String.raw`^\u0000`, "^node:", String.raw`^@?\w`, "^", String.raw`^\.`]],
27
+ }],
28
+ "unicorn/prefer-regexp-test": "off",
29
+ "unicorn/prevent-abbreviations": "off",
30
+ },
31
+ settings: {
32
+ perfectionist: {
33
+ partitionByComment: "(group) *",
34
+ type: "natural",
35
+ },
36
+ },
37
+ }, {
38
+ files: "**/*.{ts,cts,mts,tsx}",
39
+ rules: {
40
+ // https://github.com/xojs/eslint-config-xo-typescript/blob/v2.0.0/index.js#L384
41
+ "@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
42
+ // https://github.com/xojs/eslint-config-xo-typescript/blob/v2.0.0/index.js#L707
43
+ "@typescript-eslint/prefer-regexp-exec": "off",
44
+ "perfectionist/sort-enums": ["error", { forceNumericSort: true }],
45
+ "perfectionist/sort-heritage-clauses": "error",
46
+ "perfectionist/sort-interfaces": "error",
47
+ "perfectionist/sort-intersection-types": "error",
48
+ "perfectionist/sort-object-types": "error",
49
+ "perfectionist/sort-union-types": ["error", { groups: ["unknown", "keyword", "nullish"] }],
50
+ },
51
+ settings: {
52
+ n: { typescriptExtensionMap: [[".ts", ".ts"], [".tsx", ".tsx"]] },
53
+ },
54
+ }, {
55
+ files: "test/**/*.*",
56
+ rules: {
57
+ "simple-import-sort/imports": ["error", {
58
+ groups: [[String.raw`^\u0000`, "^node:", "^ava", String.raw`^@?\w`, "^", String.raw`^\.`]],
59
+ }],
60
+ },
61
+ }, {
62
+ files: [
63
+ "**/xo.config.js",
64
+ "**/xo.config.ts",
65
+ "**/eslint.config.js",
66
+ "**/eslint.config.ts",
67
+ ],
68
+ rules: {
69
+ "import-x/no-anonymous-default-export": "off",
70
+ },
71
+ }];
package/dprint.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- extends: ["plugin:dprint-integration/disable-conflict"],
5
- overrides: [{
6
- files: "**/*.{ts,cts,mts,tsx}",
7
- rules: {
8
- "@typescript-eslint/object-curly-spacing": "off",
9
- "@typescript-eslint/space-infix-ops": "off",
10
- },
11
- }],
12
- };
package/index.js DELETED
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- plugins: ["perfectionist", "simple-import-sort"],
5
- settings: {
6
- perfectionist: {
7
- partitionByComment: "(group) *",
8
- type: "natural",
9
- },
10
- },
11
- rules: {
12
- // https://github.com/xojs/eslint-config-xo/blob/v0.44.0/index.js#L304
13
- "capitalized-comments": "off",
14
- "import/extensions": "off",
15
- "import/order": "off",
16
- // https://github.com/xojs/eslint-config-xo/blob/v0.44.0/index.js#L186
17
- "no-warning-comments": ["warn", { decoration: ["/", "*"] }],
18
- "object-shorthand": "off",
19
- "perfectionist/sort-array-includes": "error",
20
- "perfectionist/sort-maps": "error",
21
- "perfectionist/sort-objects": "error",
22
- // TODO: doesn't play nice with unicorn/switch-case-braces: https://github.com/azat-io/eslint-plugin-perfectionist/issues/54#issuecomment-2268283085
23
- "perfectionist/sort-switch-case": "error",
24
- "simple-import-sort/exports": "error",
25
- "simple-import-sort/imports": ["error", {
26
- groups: [["^\\u0000", "^node:", "^@?\\w", "^", "^\\."]],
27
- }],
28
- "unicorn/prefer-regexp-test": "off",
29
- "unicorn/prevent-abbreviations": "off",
30
- },
31
- overrides: [{
32
- files: "**/*.{ts,cts,mts,tsx}",
33
- settings: {
34
- n: { typescriptExtensionMap: [[".ts", ".ts"], [".tsx", ".tsx"]] },
35
- },
36
- rules: {
37
- // https://github.com/xojs/eslint-config-xo-typescript/blob/v2.0.0/index.js#L384
38
- "@typescript-eslint/no-confusing-void-expression": ["error", { ignoreArrowShorthand: true }],
39
- // https://github.com/xojs/eslint-config-xo-typescript/blob/v2.0.0/index.js#L707
40
- "@typescript-eslint/prefer-regexp-exec": "off",
41
- "perfectionist/sort-enums": ["error", { forceNumericSort: true }],
42
- "perfectionist/sort-interfaces": "error",
43
- "perfectionist/sort-intersection-types": "error",
44
- "perfectionist/sort-object-types": "error",
45
- "perfectionist/sort-union-types": ["error", { groups: ["unknown", "keyword", "nullish"] }],
46
- },
47
- }, {
48
- files: "test/**/*.*",
49
- rules: {
50
- "simple-import-sort/imports": ["error", {
51
- groups: [["^\\u0000", "^node:", "^ava", "^@?\\w", "^", "^\\."]],
52
- }],
53
- },
54
- }],
55
- };
package/react.js DELETED
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- extends: [
5
- "xo-react",
6
- "plugin:react/jsx-runtime",
7
- "plugin:jsx-a11y/recommended",
8
- ],
9
- plugins: ["react-refresh", "sort-react-dependency-arrays"],
10
- rules: {
11
- "react/no-array-index-key": "warn",
12
- "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
13
- "simple-import-sort/imports": ["error", {
14
- groups: [["^\\u0000", "^node:", "^react", "^react-dom", "^@?\\w", "^", "^\\.", "^.+\\.s?css$"]],
15
- }],
16
- "sort-react-dependency-arrays/sort": "error",
17
- "unicorn/filename-case": ["error", {
18
- cases: {
19
- camelCase: true,
20
- kebabCase: true,
21
- pascalCase: true,
22
- },
23
- }],
24
- },
25
- overrides: [{
26
- files: ["src/constants/**/*.{ts,cts,mts,tsx}", "**/constants.{ts,cts,mts,tsx}"],
27
- rules: {
28
- "@typescript-eslint/naming-convention": "off",
29
- },
30
- }, {
31
- files: "**/*.{ts,cts,mts,tsx}",
32
- rules: {
33
- "perfectionist/sort-interfaces": ["error", {
34
- customGroups: { callback: "on*" },
35
- groups: ["unknown", "callback"],
36
- }],
37
- "perfectionist/sort-object-types": ["error", {
38
- customGroups: { callback: "on*" },
39
- groups: ["unknown", "callback"],
40
- }],
41
- },
42
- }],
43
- };