Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] eslint.config.js #568

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
configEmoji: [
['browser', '🔍'],
['internal', '🔐'],
['react', '⚛️']
['react', '⚛️'],
],
ruleDocSectionInclude: ['Rule Details', 'Version'],
};
}
21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

35 changes: 35 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const globals = require('globals')
const eslintPlugin = require('eslint-plugin-eslint-plugin')
const importPlugin = require('eslint-plugin-import')
const filenamesPlugin = require('eslint-plugin-filenames')
const i18nTextPlugin = require('eslint-plugin-i18n-text')
const recommendedGitHub = require('./lib/configs/recommended')

module.exports = [
...recommendedGitHub,
eslintPlugin.configs['flat/all'],
{
languageOptions: {
ecmaVersion: 13,
globals: {
...globals.es6,
...globals.node,
},
},
plugins: {
eslintPlugin,
importPlugin,
filenamesPlugin,
i18nTextPlugin,
},
rules: {
'importPlugin/extensions': 'off',
'importPlugin/no-commonjs': 'off',
'filenamesPlugin/match-regex': 'off',
'i18nTextPlugin/no-en': 'off',
'eslint-plugin/prefer-placeholders': 'off',
'eslint-plugin/test-case-shorthand-strings': 'off',
'eslint-plugin/require-meta-docs-url': 'off',
},
},
]
63 changes: 36 additions & 27 deletions lib/configs/browser.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
module.exports = {
env: {
browser: true,
},
plugins: ['github', 'escompat'],
extends: ['plugin:escompat/recommended'],
rules: {
'escompat/no-dynamic-imports': 'off',
'github/async-currenttarget': 'error',
'github/async-preventdefault': 'error',
'github/get-attribute': 'error',
'github/no-blur': 'error',
'github/no-dataset': 'error',
'github/no-innerText': 'error',
'github/no-inner-html': 'error',
'github/unescaped-html-literal': 'error',
'github/no-useless-passive': 'error',
'github/require-passive-events': 'error',
'github/prefer-observers': 'error',
'import/no-nodejs-modules': 'error',
'no-restricted-syntax': [
'error',
{
selector: "NewExpression[callee.name='URL'][arguments.length=1]",
message: 'Please pass in `window.location.origin` as the 2nd argument to `new URL()`',
const globals = require('globals')
const github = require('../../lib')
const importPlugin = require('eslint-plugin-import')
const escompatPlugin = require('eslint-plugin-escompat')

module.exports = [
escompatPlugin.configs['flat/recommended'],
{
languageOptions: {
globals: {
...globals.browser,
},
],
},
plugins: {github, importPlugin, escompatPlugin},
rules: {
'escompatPlugin/no-dynamic-imports': 'off',
'github/async-currenttarget': 'error',
'github/async-preventdefault': 'error',
'github/get-attribute': 'error',
'github/no-blur': 'error',
'github/no-dataset': 'error',
'github/no-innerText': 'error',
'github/no-inner-html': 'error',
'github/unescaped-html-literal': 'error',
'github/no-useless-passive': 'error',
'github/require-passive-events': 'error',
'github/prefer-observers': 'error',
'importPlugin/no-nodejs-modules': 'error',
'no-restricted-syntax': [
'error',
{
selector: "NewExpression[callee.name='URL'][arguments.length=1]",
message: 'Please pass in `window.location.origin` as the 2nd argument to `new URL()`',
},
],
},
},
}
]
18 changes: 11 additions & 7 deletions lib/configs/internal.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module.exports = {
plugins: ['github'],
rules: {
'github/authenticity-token': 'error',
'github/js-class-name': 'error',
'github/no-d-none': 'error',
const github = require('../../lib')

module.exports = [
{
plugins: {github},
rules: {
'github/authenticity-token': 'error',
'github/js-class-name': 'error',
'github/no-d-none': 'error',
},
},
}
]
111 changes: 59 additions & 52 deletions lib/configs/react.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,61 @@
module.exports = {
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['github', 'jsx-a11y'],
extends: ['plugin:jsx-a11y/recommended'],
rules: {
'jsx-a11y/role-supports-aria-props': 'off', // Override with github/a11y-role-supports-aria-props until https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/910 is resolved
'github/a11y-aria-label-is-well-formatted': 'error',
'github/a11y-no-visually-hidden-interactive-element': 'error',
'github/a11y-no-title-attribute': 'error',
'github/a11y-svg-has-accessible-name': 'error',
'github/a11y-role-supports-aria-props': 'error',
'jsx-a11y/no-aria-hidden-on-focusable': 'error',
'jsx-a11y/no-autofocus': 'off',
'jsx-a11y/anchor-ambiguous-text': [
'error',
{
words: ['this', 'more', 'read here', 'read more'],
},
],
'jsx-a11y/no-interactive-element-to-noninteractive-role': [
'error',
{
tr: ['none', 'presentation'],
td: ['cell'], // TODO: Remove once https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/937#issuecomment-1638128318 is addressed.
canvas: ['img'],
},
],
// Remove once https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/950 is shipped.
'jsx-a11y/no-noninteractive-element-to-interactive-role': [
'error',
{
ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
li: ['menuitem', 'menuitemradio', 'menuitemcheckbox', 'option', 'row', 'tab', 'treeitem'],
table: ['grid'],
td: ['gridcell'],
fieldset: ['radiogroup', 'presentation'],
const github = require('../../lib')
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y')

module.exports = [
jsxA11yPlugin.flatConfigs.recommended,
{
languageOptions: {
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
],
'jsx-a11y/no-redundant-roles': [
'error',
{
nav: ['navigation'], // default in eslint-plugin-jsx-a11y
tbody: ['rowgroup'],
thead: ['rowgroup'],
},
],
},
plugins: {github, jsxA11yPlugin},
rules: {
'jsxA11yPlugin/role-supports-aria-props': 'off', // Override with github/a11y-role-supports-aria-props until https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/910 is resolved
'github/a11y-aria-label-is-well-formatted': 'error',
'github/a11y-no-visually-hidden-interactive-element': 'error',
'github/a11y-no-title-attribute': 'error',
'github/a11y-svg-has-accessible-name': 'error',
'github/a11y-role-supports-aria-props': 'error',
'jsxA11yPlugin/no-aria-hidden-on-focusable': 'error',
'jsxA11yPlugin/no-autofocus': 'off',
'jsxA11yPlugin/anchor-ambiguous-text': [
'error',
{
words: ['this', 'more', 'read here', 'read more'],
},
],
'jsxA11yPlugin/no-interactive-element-to-noninteractive-role': [
'error',
{
tr: ['none', 'presentation'],
td: ['cell'], // TODO: Remove once https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/937#issuecomment-1638128318 is addressed.
canvas: ['img'],
},
],
// Remove once https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/950 is shipped.
'jsxA11yPlugin/no-noninteractive-element-to-interactive-role': [
'error',
{
ul: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
ol: ['listbox', 'menu', 'menubar', 'radiogroup', 'tablist', 'tree', 'treegrid'],
li: ['menuitem', 'menuitemradio', 'menuitemcheckbox', 'option', 'row', 'tab', 'treeitem'],
table: ['grid'],
td: ['gridcell'],
fieldset: ['radiogroup', 'presentation'],
},
],
'jsxA11yPlugin/no-redundant-roles': [
'error',
{
nav: ['navigation'], // default in eslint-plugin-jsx-a11y
tbody: ['rowgroup'],
thead: ['rowgroup'],
},
],
},
},
}
]
Loading
Loading