eslint-config-xo-next 0.1.0 → 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/index.d.ts +5 -10
- package/index.js +19 -32
- package/package.json +8 -10
- package/readme.md +43 -46
package/index.d.ts
CHANGED
|
@@ -8,19 +8,14 @@ export type Options = {
|
|
|
8
8
|
*/
|
|
9
9
|
config?: 'core-web-vitals' | 'recommended';
|
|
10
10
|
/**
|
|
11
|
-
Which jsx-a11y configuration to use
|
|
12
|
-
|
|
13
|
-
@see {@link https://github.com/vercel/next.js/blob/v16.2.10/packages/eslint-config-next/src/index.ts#L72-L83}
|
|
14
|
-
@see {@link https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules}
|
|
15
|
-
|
|
16
|
-
@default 'next'
|
|
17
|
-
*/
|
|
18
|
-
jsxA11yConfig?: 'next' | 'recommended' | 'strict';
|
|
19
|
-
/**
|
|
20
11
|
The root directory of the Next.js application
|
|
21
12
|
|
|
22
13
|
@see {@link https://nextjs.org/docs/app/api-reference/config/eslint#specifying-a-root-directory-within-a-monorepo}
|
|
23
14
|
*/
|
|
24
15
|
rootDir?: string | string[];
|
|
16
|
+
/**
|
|
17
|
+
Enable Tailwind CSS v3 or v4 syntax
|
|
18
|
+
*/
|
|
19
|
+
tailwind?: 3 | 4;
|
|
25
20
|
};
|
|
26
|
-
export default function
|
|
21
|
+
export default function xoNext(options?: Options): Linter.Config[];
|
package/index.js
CHANGED
|
@@ -1,48 +1,25 @@
|
|
|
1
1
|
import nextPlugin from '@next/eslint-plugin-next';
|
|
2
|
-
import jsxa11y from 'eslint-plugin-jsx-a11y';
|
|
3
2
|
import globals from 'globals';
|
|
4
3
|
import ow from 'ow';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
'jsx-a11y/alt-text': 'warn',
|
|
8
|
-
'jsx-a11y/aria-props': 'warn',
|
|
9
|
-
'jsx-a11y/aria-proptypes': 'warn',
|
|
10
|
-
'jsx-a11y/aria-unsupported-elements': 'warn',
|
|
11
|
-
'jsx-a11y/role-has-required-aria-props': 'warn',
|
|
12
|
-
'jsx-a11y/role-supports-aria-props': 'warn',
|
|
13
|
-
},
|
|
14
|
-
recommended: jsxa11y.configs.recommended.rules,
|
|
15
|
-
strict: jsxa11y.configs.strict.rules,
|
|
16
|
-
};
|
|
17
|
-
export default function eslintConfigXoNext(options) {
|
|
4
|
+
import { tailwind3, tailwind4 } from 'tailwind-csstree';
|
|
5
|
+
export default function xoNext(options) {
|
|
18
6
|
ow(options, ow.optional.object.exactShape({
|
|
19
7
|
config: ow.optional.string.oneOf(['core-web-vitals', 'recommended']),
|
|
20
|
-
jsxA11yConfig: ow.optional.string.oneOf([
|
|
21
|
-
'next',
|
|
22
|
-
'recommended',
|
|
23
|
-
'strict',
|
|
24
|
-
]),
|
|
25
8
|
// eslint-disable-next-line unicorn/max-nested-calls
|
|
26
9
|
rootDir: ow.optional.any(ow.string, ow.array.ofType(ow.string)),
|
|
10
|
+
tailwind: ow.optional.number.oneOf([3, 4]),
|
|
27
11
|
}));
|
|
28
|
-
let jsxA11yRules = jsxA11yConfigs.next;
|
|
29
|
-
if (options?.jsxA11yConfig === 'recommended') {
|
|
30
|
-
jsxA11yRules = jsxA11yConfigs.recommended;
|
|
31
|
-
}
|
|
32
|
-
else if (options?.jsxA11yConfig === 'strict') {
|
|
33
|
-
jsxA11yRules = jsxA11yConfigs.strict;
|
|
34
|
-
}
|
|
35
12
|
const config = [
|
|
36
13
|
// Our own version of eslint-config-next's 'next' config object:
|
|
37
14
|
{
|
|
38
|
-
name: '
|
|
15
|
+
name: 'xo-next',
|
|
39
16
|
// Use next's files
|
|
40
17
|
files: ['**/*.{js,jsx,mjs,ts,tsx,mts,cts}'],
|
|
41
18
|
plugins: {
|
|
42
19
|
// - Omit next's react and react-hooks plugins to use xo-react's
|
|
43
20
|
// - Omit next's import plugin to use xo's import-x plugin
|
|
21
|
+
// - Omit next's jsx-a11y plugin to use xo-react's jsx-a11y-x plugin
|
|
44
22
|
'@next/next': nextPlugin,
|
|
45
|
-
'jsx-a11y': jsxa11y,
|
|
46
23
|
},
|
|
47
24
|
languageOptions: {
|
|
48
25
|
// Omit next's parser (babel) to use xo's parser (default)
|
|
@@ -57,11 +34,12 @@ export default function eslintConfigXoNext(options) {
|
|
|
57
34
|
},
|
|
58
35
|
settings: {
|
|
59
36
|
// Omit next's react and import/* settings
|
|
60
|
-
'jsx-a11y': {
|
|
37
|
+
'jsx-a11y-x': {
|
|
61
38
|
components: {
|
|
62
39
|
// eslint-config-next maps Image to img at the (jsx-a11y/alt-text)
|
|
63
40
|
// rule level. We map it at the settings level so that it works with
|
|
64
|
-
// all jsx-a11y rule configurations.
|
|
41
|
+
// all jsx-a11y-x rule configurations.
|
|
42
|
+
// https://github.com/es-tooling/eslint-plugin-jsx-a11y-x/tree/v0.2.0#component-mapping
|
|
65
43
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
66
44
|
Image: 'img',
|
|
67
45
|
},
|
|
@@ -71,9 +49,9 @@ export default function eslintConfigXoNext(options) {
|
|
|
71
49
|
},
|
|
72
50
|
},
|
|
73
51
|
rules: {
|
|
74
|
-
// Omit next's import, react, and react-hooks rules to use xo-react's
|
|
52
|
+
// Omit next's a11y, import, react, and react-hooks rules to use xo-react's
|
|
75
53
|
...nextPlugin.configs[options?.config ?? 'core-web-vitals'].rules,
|
|
76
|
-
|
|
54
|
+
'n/file-extension-in-import': 'off',
|
|
77
55
|
},
|
|
78
56
|
},
|
|
79
57
|
// Omit next's 'next/typescript' config object to use xo's TypeScript parsing
|
|
@@ -82,5 +60,14 @@ export default function eslintConfigXoNext(options) {
|
|
|
82
60
|
ignores: ['.next/**', 'out/**', 'build/**', 'next-env.d.ts'],
|
|
83
61
|
},
|
|
84
62
|
];
|
|
63
|
+
if (options?.tailwind !== undefined) {
|
|
64
|
+
config.push({
|
|
65
|
+
name: 'xo-next/tailwind',
|
|
66
|
+
files: ['**/*.css'],
|
|
67
|
+
languageOptions: {
|
|
68
|
+
customSyntax: options.tailwind === 3 ? tailwind3 : tailwind4,
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
85
72
|
return config;
|
|
86
73
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-xo-next",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "ESLint shareable config for
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "ESLint shareable config for Next.js to be used with eslint-config-xo-react",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:patrik-csak/eslint-config-xo-next",
|
|
7
7
|
"author": "Patrik Csak <p@trikcsak.com> (https://patrikcsak.com)",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"packageManager": {
|
|
25
25
|
"name": "npm",
|
|
26
|
-
"version": "
|
|
26
|
+
"version": "11.16 - 12"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
@@ -47,27 +47,25 @@
|
|
|
47
47
|
"xo"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
51
50
|
"globals": "^17.7.0",
|
|
52
|
-
"ow": "^3.1.1"
|
|
51
|
+
"ow": "^3.1.1",
|
|
52
|
+
"tailwind-csstree": "^0.4.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@eslint/compat": "^2.1.0",
|
|
56
55
|
"@eslint/config-inspector": "^3.0.4",
|
|
57
56
|
"@next/eslint-plugin-next": "^16.2.10",
|
|
58
57
|
"@tsconfig/node22": "^22.0.5",
|
|
59
58
|
"@tsconfig/strictest": "^2.0.8",
|
|
60
|
-
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
61
59
|
"@types/node": "^24.13.2",
|
|
62
60
|
"eslint": "^10.6.0",
|
|
63
|
-
"eslint-config-xo": "^
|
|
64
|
-
"eslint-config-xo-react": "^0.
|
|
61
|
+
"eslint-config-xo": "^4.0.0",
|
|
62
|
+
"eslint-config-xo-react": "^0.32.0",
|
|
65
63
|
"typescript": "^6.0.3"
|
|
66
64
|
},
|
|
67
65
|
"peerDependencies": {
|
|
68
66
|
"@next/eslint-plugin-next": "^16.0.0",
|
|
69
67
|
"eslint": "^10.0.0",
|
|
70
|
-
"eslint-config-xo-react": "0.
|
|
68
|
+
"eslint-config-xo-react": "^0.32.0"
|
|
71
69
|
},
|
|
72
70
|
"peerDependenciesMeta": {
|
|
73
71
|
"eslint-config-xo-react": {
|
package/readme.md
CHANGED
|
@@ -1,61 +1,38 @@
|
|
|
1
1
|
# eslint-config-xo-next
|
|
2
2
|
|
|
3
|
-
ESLint [shareable config](http://eslint.org/docs/developer-guide/shareable-configs.html) for
|
|
3
|
+
ESLint [shareable config](http://eslint.org/docs/developer-guide/shareable-configs.html) for [Next.js](https://nextjs.org) to be used with [eslint-config-xo-react](https://github.com/xojs/eslint-config-xo-react)
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- Eliminates ESLint plugin and parser conflicts
|
|
8
|
-
- Combines
|
|
9
|
-
-
|
|
7
|
+
- Eliminates ESLint plugin and parser conflicts from using ESLint 10 with `eslint-config-next` and `eslint-config-xo-react`
|
|
8
|
+
- Combines Next.js's [`@next/next`](https://nextjs.org/docs/app/api-reference/config/eslint#rules) rules with `eslint-config-xo-react`'s stricter [`eslint-plugin-jsx-a11y-x`](https://github.com/es-tooling/eslint-plugin-jsx-a11y-x), [`@eslint-react/eslint-plugin`](https://github.com/Rel1cx/eslint-react), and [`eslint-plugin-react-hooks`](https://github.com/react/react/tree/HEAD/packages/eslint-plugin-react-hooks) rules
|
|
9
|
+
- Supports Tailwind CSS syntax
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
|
-
`eslint-config-xo-next` requires you to install `@next/eslint-plugin-next` as a direct dependency so its version can be kept in sync with your app’s other Next.js dependencies, e.g. when running `npx @next/codemod upgrade`
|
|
14
|
-
|
|
15
|
-
> [!NOTE]
|
|
16
|
-
> `@eslint/compat` is necessary until `eslint-plugin-react` supports ESLint v10
|
|
17
|
-
|
|
18
13
|
```sh
|
|
19
14
|
npm install --save-dev \
|
|
20
|
-
@eslint/compat \
|
|
21
15
|
@next/eslint-plugin-next \
|
|
16
|
+
eslint-config-xo \
|
|
17
|
+
eslint-config-xo-react \
|
|
22
18
|
eslint-config-xo-next
|
|
23
19
|
```
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Spread the config in your XO configuration file:
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
// xo.config.js
|
|
31
|
-
|
|
32
|
-
import {fixupConfigRules} from '@eslint/compat';
|
|
33
|
-
import xoNext from 'eslint-config-xo-next';
|
|
34
|
-
import xoReact from 'eslint-config-xo-react';
|
|
21
|
+
`eslint-config-xo-next` requires you to install `@next/eslint-plugin-next` as a direct dependency so its version can be kept in sync with your app’s other Next.js dependencies
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
...xoNext(),
|
|
38
|
-
...fixupConfigRules(xoReact()),
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
export default xoConfig;
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Or, if you’re using XO [without the `xo` CLI](https://github.com/xojs/xo#without-the-xo-cli), spread the config in your ESLint configuration file:
|
|
23
|
+
## Usage
|
|
45
24
|
|
|
46
25
|
```js
|
|
47
26
|
// eslint.config.js
|
|
48
|
-
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import xoNext from 'eslint-config-xo-next';
|
|
52
|
-
import xoReact from 'eslint-config-xo-react';
|
|
27
|
+
import eslintConfigXo from 'eslint-config-xo';
|
|
28
|
+
import eslintConfigXoNext from 'eslint-config-xo-next';
|
|
29
|
+
import eslintConfigXoReact from 'eslint-config-xo-react';
|
|
53
30
|
import {defineConfig} from 'eslint/config';
|
|
54
31
|
|
|
55
32
|
export default defineConfig([
|
|
56
|
-
...
|
|
57
|
-
...
|
|
58
|
-
...
|
|
33
|
+
...eslintConfigXo(),
|
|
34
|
+
...eslintConfigXoReact(),
|
|
35
|
+
...eslintConfigXoNext(),
|
|
59
36
|
]);
|
|
60
37
|
```
|
|
61
38
|
|
|
@@ -72,15 +49,14 @@ Which of the [Next.js ESLint configurations](https://nextjs.org/docs/app/api-ref
|
|
|
72
49
|
...xoNext({config: 'recommended'})
|
|
73
50
|
```
|
|
74
51
|
|
|
75
|
-
####
|
|
52
|
+
#### tailwind
|
|
76
53
|
|
|
77
|
-
Type: `
|
|
78
|
-
Default: `'next'`
|
|
54
|
+
Type: `3 | 4`
|
|
79
55
|
|
|
80
|
-
|
|
56
|
+
Enable support for Tailwind CSS v3 or v4 syntax
|
|
81
57
|
|
|
82
58
|
```js
|
|
83
|
-
...xoNext({
|
|
59
|
+
...xoNext({tailwind: 4})
|
|
84
60
|
```
|
|
85
61
|
|
|
86
62
|
#### rootDir
|
|
@@ -93,8 +69,29 @@ Where to find your Next.js application if Next.js isn’t installed in your root
|
|
|
93
69
|
...xoNext({rootDir: 'packages/my-app/'})
|
|
94
70
|
```
|
|
95
71
|
|
|
96
|
-
##
|
|
72
|
+
## Use with [XO](https://github.com/xojs/xo)
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
npm install --save-dev \
|
|
76
|
+
@next/eslint-plugin-next \
|
|
77
|
+
eslint-config-xo-react \
|
|
78
|
+
eslint-config-xo-next
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
// xo.config.js
|
|
83
|
+
import xoNext from 'eslint-config-xo-next';
|
|
84
|
+
import xoReact from 'eslint-config-xo-react';
|
|
85
|
+
import {defineConfig} from 'eslint/config';
|
|
86
|
+
|
|
87
|
+
const xoConfig = defineConfig([
|
|
88
|
+
...xoReact(),
|
|
89
|
+
...xoNext(),
|
|
90
|
+
]);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## FAQ
|
|
94
|
+
|
|
95
|
+
### How is this different from [eslint-config-xo-nextjs](https://github.com/tusbar/eslint-config-xo-nextjs)?
|
|
97
96
|
|
|
98
|
-
-
|
|
99
|
-
- [eslint-config-xo-react](https://github.com/xojs/eslint-config-xo-react) - ESLint shareable config for React to be used with eslint-config-xo
|
|
100
|
-
- [XO](https://github.com/xojs/xo)
|
|
97
|
+
This config acts as a minimal compatibility layer between Next.js's and XO's configs instead of wrapping them. With this config, you install your own version of `@next/eslint-plugin-next` so that its version matches your project's `next` and `@next/*` dependencies, and you install your own versions of `eslint-config-xo` (or `xo`) and `eslint-config-xo-react` so that you can update them without waiting for this plugin to update them.
|