Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2174e40

Browse filesBrowse files
committed
feat: move to esm-only
Moves the repo to be of `type: "module"` (i.e. ESM). ESLint already uses a dynamic import to load plugins, so this will only affect CommonJS users with flat config in Node <20.
1 parent def8cea commit 2174e40
Copy full SHA for 2174e40

File tree

Expand file treeCollapse file tree

75 files changed

+338
-243
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

75 files changed

+338
-243
lines changed

‎.eslint-doc-generatorrc.js

Copy file name to clipboardExpand all lines: .eslint-doc-generatorrc.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @type {import('eslint-doc-generator').GenerateOptions} */
2-
module.exports = {
2+
export default {
33
configEmoji: [
44
['browser', '🔍'],
55
['internal', '🔐'],

‎eslint.config.js

Copy file name to clipboardExpand all lines: eslint.config.js
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
const globals = require('globals')
2-
const eslintPlugin = require('eslint-plugin-eslint-plugin')
3-
const importPlugin = require('eslint-plugin-import')
4-
const i18nTextPlugin = require('eslint-plugin-i18n-text')
5-
const recommendedGitHub = require('./lib/configs/flat/recommended')
6-
const {fixupPluginRules} = require('@eslint/compat')
1+
import globals from 'globals'
2+
import eslintPlugin from 'eslint-plugin-eslint-plugin'
3+
import importPlugin from 'eslint-plugin-import'
4+
import i18nTextPlugin from 'eslint-plugin-i18n-text'
5+
import recommendedGitHub from './lib/configs/flat/recommended.js'
6+
import {fixupPluginRules} from '@eslint/compat'
77

8-
module.exports = [
8+
export default [
99
recommendedGitHub,
10-
eslintPlugin.configs['flat/all'],
10+
{
11+
files: ['lib/rules/**/*.js'],
12+
...eslintPlugin.configs['flat/all'],
13+
},
1114
{
1215
ignores: ['test-examples/**'],
1316
},

‎lib/configs/browser.js

Copy file name to clipboardExpand all lines: lib/configs/browser.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
env: {
33
browser: true,
44
},

‎lib/configs/flat/browser.js

Copy file name to clipboardExpand all lines: lib/configs/flat/browser.js
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const globals = require('globals')
2-
const github = require('../../plugin')
3-
const importPlugin = require('eslint-plugin-import')
4-
const escompat = require('eslint-plugin-escompat')
5-
const {fixupPluginRules} = require('@eslint/compat')
1+
import globals from 'globals'
2+
import github from '../../plugin.js'
3+
import importPlugin from 'eslint-plugin-import'
4+
import escompat from 'eslint-plugin-escompat'
5+
import {fixupPluginRules} from '@eslint/compat'
66

7-
module.exports = {
7+
export default {
88
...escompat.configs['flat/recommended'],
99
languageOptions: {
1010
globals: {

‎lib/configs/flat/internal.js

Copy file name to clipboardExpand all lines: lib/configs/flat/internal.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const github = require('../../plugin')
2-
const {fixupPluginRules} = require('@eslint/compat')
1+
import github from '../../plugin.js'
2+
import {fixupPluginRules} from '@eslint/compat'
33

4-
module.exports = {
4+
export default {
55
plugins: {github: fixupPluginRules(github)},
66
rules: {
77
'github/authenticity-token': 'error',

‎lib/configs/flat/react.js

Copy file name to clipboardExpand all lines: lib/configs/flat/react.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
const github = require('../../plugin')
2-
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y')
3-
const {fixupPluginRules} = require('@eslint/compat')
1+
import github from '../../plugin.js'
2+
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
3+
import {fixupPluginRules} from '@eslint/compat'
44

5-
module.exports = {
5+
export default {
66
...jsxA11yPlugin.flatConfigs.recommended,
77
languageOptions: {
88
sourceType: 'module',

‎lib/configs/flat/recommended.js

Copy file name to clipboardExpand all lines: lib/configs/flat/recommended.js
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const globals = require('globals')
2-
const github = require('../../plugin')
3-
const prettierPlugin = require('eslint-plugin-prettier')
4-
const eslintComments = require('eslint-plugin-eslint-comments')
5-
const importPlugin = require('eslint-plugin-import')
6-
const i18nTextPlugin = require('eslint-plugin-i18n-text')
7-
const noOnlyTestsPlugin = require('eslint-plugin-no-only-tests')
8-
const {fixupPluginRules} = require('@eslint/compat')
1+
import globals from 'globals'
2+
import github from '../../plugin.js'
3+
import prettierPlugin from 'eslint-plugin-prettier'
4+
import eslintComments from 'eslint-plugin-eslint-comments'
5+
import importPlugin from 'eslint-plugin-import'
6+
import i18nTextPlugin from 'eslint-plugin-i18n-text'
7+
import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests'
8+
import {fixupPluginRules} from '@eslint/compat'
99

10-
module.exports = {
10+
export default {
1111
languageOptions: {
1212
ecmaVersion: 6,
1313
sourceType: 'module',

‎lib/configs/flat/typescript.js

Copy file name to clipboardExpand all lines: lib/configs/flat/typescript.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const tseslint = require('typescript-eslint')
2-
const escompat = require('eslint-plugin-escompat')
1+
// eslint-disable-next-line import/no-unresolved
2+
import tseslint from 'typescript-eslint'
3+
import escompat from 'eslint-plugin-escompat'
34

4-
module.exports = tseslint.config(...tseslint.configs.recommended, ...escompat.configs['flat/typescript-2020'], {
5+
export default tseslint.config(...tseslint.configs.recommended, ...escompat.configs['flat/typescript-2020'], {
56
languageOptions: {
67
parser: tseslint.parser,
78
},

‎lib/configs/internal.js

Copy file name to clipboardExpand all lines: lib/configs/internal.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
plugins: ['github'],
33
rules: {
44
'github/authenticity-token': 'error',

‎lib/configs/react.js

Copy file name to clipboardExpand all lines: lib/configs/react.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
parserOptions: {
33
sourceType: 'module',
44
ecmaFeatures: {

‎lib/configs/recommended.js

Copy file name to clipboardExpand all lines: lib/configs/recommended.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
parserOptions: {
33
ecmaFeatures: {
44
ecmaVersion: 6,

‎lib/configs/typescript.js

Copy file name to clipboardExpand all lines: lib/configs/typescript.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:escompat/typescript-2020'],
33
parser: '@typescript-eslint/parser',
44
plugins: ['@typescript-eslint', 'escompat', 'github'],

‎lib/formatters/stylish-fixes.js

Copy file name to clipboardExpand all lines: lib/formatters/stylish-fixes.js
+7-14Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
'use strict'
1+
import childProcess from 'node:child_process'
2+
import fs from 'node:fs'
3+
import os from 'node:os'
4+
import path from 'node:path'
5+
import SourceCodeFixer from 'eslint/lib/linter/source-code-fixer.js'
6+
import getRuleURI from 'eslint-rule-documentation'
27

3-
const childProcess = require('child_process')
4-
const fs = require('fs')
5-
const os = require('os')
6-
const path = require('path')
7-
let SourceCodeFixer = null
8-
try {
9-
SourceCodeFixer = require('eslint/lib/linter/source-code-fixer')
10-
} catch {
11-
SourceCodeFixer = require('eslint/lib/util/source-code-fixer')
12-
}
13-
const getRuleURI = require('eslint-rule-documentation')
14-
15-
module.exports = function (results) {
8+
export default function stylishFixes(results) {
169
let output = '\n'
1710
let errors = 0
1811
let warnings = 0

‎lib/index.js

Copy file name to clipboard
+22-12Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
const github = require('./plugin')
1+
import github from './plugin.js'
2+
import flatBrowserConfig from './configs/flat/browser.js'
3+
import flatInternalConfig from './configs/flat/internal.js'
4+
import flatRecommendedConfig from './configs/flat/recommended.js'
5+
import flatTypescriptConfig from './configs/flat/typescript.js'
6+
import flatReactConfig from './configs/flat/react.js'
7+
import browserConfig from './configs/browser.js'
8+
import internalConfig from './configs/internal.js'
9+
import recommendedConfig from './configs/recommended.js'
10+
import typescriptConfig from './configs/typescript.js'
11+
import reactConfig from './configs/react.js'
212

313
const getFlatConfig = () => ({
4-
browser: require('./configs/flat/browser'),
5-
internal: require('./configs/flat/internal'),
6-
recommended: require('./configs/flat/recommended'),
7-
typescript: require('./configs/flat/typescript'),
8-
react: require('./configs/flat/react'),
14+
browser: flatBrowserConfig,
15+
internal: flatInternalConfig,
16+
recommended: flatRecommendedConfig,
17+
typescript: flatTypescriptConfig,
18+
react: flatReactConfig,
919
})
1020

11-
module.exports = {
21+
export default {
1222
rules: github.rules,
1323
configs: {
14-
browser: require('./configs/browser'),
15-
internal: require('./configs/internal'),
16-
recommended: require('./configs/recommended'),
17-
typescript: require('./configs/typescript'),
18-
react: require('./configs/react'),
24+
browser: browserConfig,
25+
internal: internalConfig,
26+
recommended: recommendedConfig,
27+
typescript: typescriptConfig,
28+
react: reactConfig,
1929
},
2030
getFlatConfigs: getFlatConfig,
2131
}

‎lib/plugin.js

Copy file name to clipboard
+54-27Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,59 @@
1-
const {name, version} = require('../package.json')
1+
import {packageJson} from './utils/commonjs-json-wrappers.cjs'
2+
import a11yNoVisuallyHiddenInteractiveElement from './rules/a11y-no-visually-hidden-interactive-element.js'
3+
import a11yNoGenericLinkText from './rules/a11y-no-generic-link-text.js'
4+
import a11yNoTitleAttribute from './rules/a11y-no-title-attribute.js'
5+
import a11yAriaLabelIsWellFormatted from './rules/a11y-aria-label-is-well-formatted.js'
6+
import a11yRoleSupportsAriaProps from './rules/a11y-role-supports-aria-props.js'
7+
import a11ySvgHasAccessibleName from './rules/a11y-svg-has-accessible-name.js'
8+
import arrayForeach from './rules/array-foreach.js'
9+
import asyncCurrenttarget from './rules/async-currenttarget.js'
10+
import asyncPreventdefault from './rules/async-preventdefault.js'
11+
import authenticityToken from './rules/authenticity-token.js'
12+
import filenamesMatchRegex from './rules/filenames-match-regex.js'
13+
import getAttribute from './rules/get-attribute.js'
14+
import jsClassName from './rules/js-class-name.js'
15+
import noBlur from './rules/no-blur.js'
16+
import noDNone from './rules/no-d-none.js'
17+
import noDataset from './rules/no-dataset.js'
18+
import noImplicitBuggyGlobals from './rules/no-implicit-buggy-globals.js'
19+
import noInnerHTML from './rules/no-inner-html.js'
20+
import noInnerText from './rules/no-innerText.js'
21+
import noDynamicScriptTag from './rules/no-dynamic-script-tag.js'
22+
import noThen from './rules/no-then.js'
23+
import noUselessPassive from './rules/no-useless-passive.js'
24+
import preferObservers from './rules/prefer-observers.js'
25+
import requirePassiveEvents from './rules/require-passive-events.js'
26+
import unescapedHtmlLiteral from './rules/unescaped-html-literal.js'
227

3-
module.exports = {
28+
const {name, version} = packageJson
29+
30+
export default {
431
meta: {name, version},
532
rules: {
6-
'a11y-no-visually-hidden-interactive-element': require('./rules/a11y-no-visually-hidden-interactive-element'),
7-
'a11y-no-generic-link-text': require('./rules/a11y-no-generic-link-text'),
8-
'a11y-no-title-attribute': require('./rules/a11y-no-title-attribute'),
9-
'a11y-aria-label-is-well-formatted': require('./rules/a11y-aria-label-is-well-formatted'),
10-
'a11y-role-supports-aria-props': require('./rules/a11y-role-supports-aria-props'),
11-
'a11y-svg-has-accessible-name': require('./rules/a11y-svg-has-accessible-name'),
12-
'array-foreach': require('./rules/array-foreach'),
13-
'async-currenttarget': require('./rules/async-currenttarget'),
14-
'async-preventdefault': require('./rules/async-preventdefault'),
15-
'authenticity-token': require('./rules/authenticity-token'),
16-
'filenames-match-regex': require('./rules/filenames-match-regex'),
17-
'get-attribute': require('./rules/get-attribute'),
18-
'js-class-name': require('./rules/js-class-name'),
19-
'no-blur': require('./rules/no-blur'),
20-
'no-d-none': require('./rules/no-d-none'),
21-
'no-dataset': require('./rules/no-dataset'),
22-
'no-implicit-buggy-globals': require('./rules/no-implicit-buggy-globals'),
23-
'no-inner-html': require('./rules/no-inner-html'),
24-
'no-innerText': require('./rules/no-innerText'),
25-
'no-dynamic-script-tag': require('./rules/no-dynamic-script-tag'),
26-
'no-then': require('./rules/no-then'),
27-
'no-useless-passive': require('./rules/no-useless-passive'),
28-
'prefer-observers': require('./rules/prefer-observers'),
29-
'require-passive-events': require('./rules/require-passive-events'),
30-
'unescaped-html-literal': require('./rules/unescaped-html-literal'),
33+
'a11y-no-visually-hidden-interactive-element': a11yNoVisuallyHiddenInteractiveElement,
34+
'a11y-no-generic-link-text': a11yNoGenericLinkText,
35+
'a11y-no-title-attribute': a11yNoTitleAttribute,
36+
'a11y-aria-label-is-well-formatted': a11yAriaLabelIsWellFormatted,
37+
'a11y-role-supports-aria-props': a11yRoleSupportsAriaProps,
38+
'a11y-svg-has-accessible-name': a11ySvgHasAccessibleName,
39+
'array-foreach': arrayForeach,
40+
'async-currenttarget': asyncCurrenttarget,
41+
'async-preventdefault': asyncPreventdefault,
42+
'authenticity-token': authenticityToken,
43+
'filenames-match-regex': filenamesMatchRegex,
44+
'get-attribute': getAttribute,
45+
'js-class-name': jsClassName,
46+
'no-blur': noBlur,
47+
'no-d-none': noDNone,
48+
'no-dataset': noDataset,
49+
'no-implicit-buggy-globals': noImplicitBuggyGlobals,
50+
'no-inner-html': noInnerHTML,
51+
'no-innerText': noInnerText,
52+
'no-dynamic-script-tag': noDynamicScriptTag,
53+
'no-then': noThen,
54+
'no-useless-passive': noUselessPassive,
55+
'prefer-observers': preferObservers,
56+
'require-passive-events': requirePassiveEvents,
57+
'unescaped-html-literal': unescapedHtmlLiteral,
3158
},
3259
}

‎lib/rules/a11y-aria-label-is-well-formatted.js

Copy file name to clipboardExpand all lines: lib/rules/a11y-aria-label-is-well-formatted.js
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
const {getProp} = require('jsx-ast-utils')
1+
import jsxAstUtils from 'jsx-ast-utils'
2+
import url from '../url.js'
23

3-
module.exports = {
4+
const {getProp} = jsxAstUtils
5+
6+
export default {
47
meta: {
58
type: 'problem',
69
docs: {
710
description: 'enforce [aria-label] text to be formatted as you would visual text.',
8-
url: require('../url')(module),
11+
url: url(import.meta.url),
912
recommended: false,
1013
},
1114
schema: [],

‎lib/rules/a11y-no-generic-link-text.js

Copy file name to clipboardExpand all lines: lib/rules/a11y-no-generic-link-text.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const {getProp, getPropValue} = require('jsx-ast-utils')
2-
const {getElementType} = require('../utils/get-element-type')
1+
import jsxAstUtils from 'jsx-ast-utils'
2+
import {getElementType} from '../utils/get-element-type.js'
3+
import url from '../url.js'
34

5+
const {getProp, getPropValue} = jsxAstUtils
46
const bannedLinkText = ['read more', 'here', 'click here', 'learn more', 'more']
57

68
/* Downcase and strip extra whitespaces and punctuation */
@@ -12,12 +14,12 @@ const stripAndDowncaseText = text => {
1214
.trim()
1315
}
1416

15-
module.exports = {
17+
export default {
1618
meta: {
1719
type: 'problem',
1820
docs: {
1921
description: 'disallow generic link text',
20-
url: require('../url')(module),
22+
url: url(import.meta.url),
2123
recommended: false,
2224
},
2325
deprecated: true,

‎lib/rules/a11y-no-title-attribute.js

Copy file name to clipboardExpand all lines: lib/rules/a11y-no-title-attribute.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const {getProp, getPropValue} = require('jsx-ast-utils')
2-
const {getElementType} = require('../utils/get-element-type')
1+
import jsxAstUtils from 'jsx-ast-utils'
2+
import {getElementType} from '../utils/get-element-type.js'
3+
import url from '../url.js'
34

5+
const {getProp, getPropValue} = jsxAstUtils
46
const SEMANTIC_ELEMENTS = [
57
'a',
68
'button',
@@ -38,12 +40,12 @@ const ifSemanticElement = (context, node) => {
3840
return false
3941
}
4042

41-
module.exports = {
43+
export default {
4244
meta: {
4345
type: 'problem',
4446
docs: {
4547
description: 'disallow using the title attribute',
46-
url: require('../url')(module),
48+
url: url(import.meta.url),
4749
recommended: false,
4850
},
4951
schema: [],

‎lib/rules/a11y-no-visually-hidden-interactive-element.js

Copy file name to clipboardExpand all lines: lib/rules/a11y-no-visually-hidden-interactive-element.js
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const {getProp, getLiteralPropValue} = require('jsx-ast-utils')
2-
const {getElementType} = require('../utils/get-element-type')
3-
const {generateObjSchema} = require('eslint-plugin-jsx-a11y/lib/util/schemas')
1+
import jsxAstUtils from 'jsx-ast-utils'
2+
import {getElementType} from '../utils/get-element-type.js'
3+
import {generateObjSchema} from 'eslint-plugin-jsx-a11y/lib/util/schemas.js'
4+
import url from '../url.js'
45

6+
const {getProp, getLiteralPropValue} = jsxAstUtils
57
const defaultClassName = 'sr-only'
68
const defaultcomponentName = 'VisuallyHidden'
79

@@ -55,12 +57,12 @@ const checkIfVisuallyHiddenAndInteractive = (context, options, node, isParentVis
5557
return false
5658
}
5759

58-
module.exports = {
60+
export default {
5961
meta: {
6062
type: 'problem',
6163
docs: {
6264
description: 'enforce that interactive elements are not visually hidden',
63-
url: require('../url')(module),
65+
url: url(import.meta.url),
6466
recommended: false,
6567
},
6668
schema: [schema],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.