Skip to content

Commit

Permalink
Next.js 向けのルールを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
susisu committed Oct 6, 2024
1 parent d8bd720 commit acf6da7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ function config(options, configs) {
},
]
: []),
...(next
? [
{
files: ['**/*.{js,jsx,cjs,mjs}', '**/*.{ts,tsx,cts,mts}'],
extends: [
{
rules: {
...nextPlugin.configs.recommended.rules,
...(next === 'strict' ? { rules: nextPlugin.configs['core-web-vitals'].rules } : {}),
},
},
],
rules: rules.next,
},
]
: []),
{
files: ['**/*.{ts,tsx,cts,mts}'],
extends: [
Expand Down
2 changes: 2 additions & 0 deletions lib/rules/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
'use strict';

const javascript = require('./javascript.js');
const next = require('./next.js');
const react = require('./react.js');
const typescript = require('./typescript.js');

const rules = {
javascript,
next,
react,
typescript,
};
Expand Down
26 changes: 26 additions & 0 deletions lib/rules/next.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

// ref. https://github.com/vercel/next.js/tree/canary/packages/eslint-config-next

/** @type {import('eslint').Linter.RulesRecord} */
const rules = {
'import/no-anonymous-default-export': 'warn',
'react/jsx-no-target-blank': 'off',
'react/no-unknown-property': 'off',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'jsx-a11y/alt-text': [
'warn',
{
elements: ['img'],
img: ['Image'],
},
],
'jsx-a11y/aria-props': 'warn',
'jsx-a11y/aria-proptypes': 'warn',
'jsx-a11y/aria-unsupported-elements': 'warn',
'jsx-a11y/role-has-required-aria-props': 'warn',
'jsx-a11y/role-supports-aria-props': 'warn',
};

module.exports = rules;

0 comments on commit acf6da7

Please sign in to comment.