diff --git a/.flowconfig b/.flowconfig index 46e35fd4e..e01587181 100644 --- a/.flowconfig +++ b/.flowconfig @@ -3,5 +3,6 @@ /lib/.* /docs/.* /reports/.* +/examples/.* [options] suppress_type=$FlowFixMe diff --git a/.github/workflows/node-4+.yml b/.github/workflows/node-4+.yml index d5c908cab..a21d5c9d3 100644 --- a/.github/workflows/node-4+.yml +++ b/.github/workflows/node-4+.yml @@ -25,6 +25,7 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} eslint: + - 9 - 8 - 7 - 6 @@ -32,6 +33,32 @@ jobs: - 4 - 3 exclude: + - node-version: 16 + eslint: 9 + - node-version: 15 + eslint: 9 + - node-version: 14 + eslint: 9 + - node-version: 13 + eslint: 9 + - node-version: 12 + eslint: 9 + - node-version: 11 + eslint: 9 + - node-version: 10 + eslint: 9 + - node-version: 9 + eslint: 9 + - node-version: 8 + eslint: 9 + - node-version: 7 + eslint: 9 + - node-version: 6 + eslint: 9 + - node-version: 5 + eslint: 9 + - node-version: 4 + eslint: 9 - node-version: 15 eslint: 8 - node-version: 13 @@ -90,7 +117,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 - uses: ljharb/actions/node/install@main name: 'nvm install ${{ matrix.node-version }} && npm install' env: diff --git a/__tests__/__util__/nodeReexports/assert.js b/__tests__/__util__/nodeReexports/assert.js new file mode 100644 index 000000000..78f8d741f --- /dev/null +++ b/__tests__/__util__/nodeReexports/assert.js @@ -0,0 +1,3 @@ +import assert from 'assert'; + +export default assert; diff --git a/__tests__/__util__/nodeReexports/fs-promises.js b/__tests__/__util__/nodeReexports/fs-promises.js new file mode 100644 index 000000000..c0d0215b9 --- /dev/null +++ b/__tests__/__util__/nodeReexports/fs-promises.js @@ -0,0 +1,3 @@ +import fs from 'fs/promises'; + +export default fs; diff --git a/__tests__/__util__/nodeReexports/fs.js b/__tests__/__util__/nodeReexports/fs.js new file mode 100644 index 000000000..6b9cf6a67 --- /dev/null +++ b/__tests__/__util__/nodeReexports/fs.js @@ -0,0 +1,3 @@ +import fs from 'fs'; + +export default fs; diff --git a/__tests__/__util__/nodeReexports/path.js b/__tests__/__util__/nodeReexports/path.js new file mode 100644 index 000000000..7b411d509 --- /dev/null +++ b/__tests__/__util__/nodeReexports/path.js @@ -0,0 +1,3 @@ +import path from 'path'; + +export default path; diff --git a/__tests__/__util__/nodeReexports/url.js b/__tests__/__util__/nodeReexports/url.js new file mode 100644 index 000000000..e851de2b4 --- /dev/null +++ b/__tests__/__util__/nodeReexports/url.js @@ -0,0 +1,3 @@ +import url from 'url'; + +export default url; diff --git a/__tests__/__util__/nodeReexports/util.js b/__tests__/__util__/nodeReexports/util.js new file mode 100644 index 000000000..1e9ac4b66 --- /dev/null +++ b/__tests__/__util__/nodeReexports/util.js @@ -0,0 +1,3 @@ +import util from 'util'; + +export default util; diff --git a/__tests__/__util__/parserOptionsMapper.js b/__tests__/__util__/parserOptionsMapper.js index 74db94a78..790e54625 100644 --- a/__tests__/__util__/parserOptionsMapper.js +++ b/__tests__/__util__/parserOptionsMapper.js @@ -1,26 +1,53 @@ +import { version as eslintVersion } from 'eslint/package.json'; +import semver from 'semver'; + +const usingLegacy = semver.major(eslintVersion) < 9; + const defaultParserOptions = { - ecmaVersion: 2018, ecmaFeatures: { experimentalObjectRestSpread: true, jsx: true, }, }; +const defaultLegacyParserOptions = { + ...defaultParserOptions, + ecmaVersion: 2018, +}; + +const defaultLanguageOptions = { + ecmaVersion: 'latest', + parserOptions: { + ...defaultParserOptions, + }, +}; + export default function parserOptionsMapper({ code, errors, options = [], - parserOptions = {}, - settings, + languageOptions = {}, + settings = {}, }) { - return { - code, - errors, - options, - parserOptions: { - ...defaultParserOptions, - ...parserOptions, - }, - settings, - }; + return usingLegacy + ? { + code, + errors, + options, + parserOptions: { + ...defaultLegacyParserOptions, + ...languageOptions, + }, + settings, + } + : { + code, + errors, + options, + languageOptions: { + ...defaultLanguageOptions, + ...languageOptions, + }, + settings, + }; } diff --git a/__tests__/src/rules/anchor-is-valid-test.js b/__tests__/src/rules/anchor-is-valid-test.js index 9fb4025e9..857605a15 100644 --- a/__tests__/src/rules/anchor-is-valid-test.js +++ b/__tests__/src/rules/anchor-is-valid-test.js @@ -272,14 +272,9 @@ ruleTester.run('anchor-is-valid', rule, { options: noHrefAspect, }, - // CUSTOM COMPONENTS AND SPECIALLINK AND ASPECT + // CUSTOM COMPONENTS AND SPECIAL LINK AND ASPECT { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - { code: '', options: componentsAndSpecialLinkAndInvalidHrefAspect }, - )).map(parserOptionsMapper), invalid: parsers.all([].concat( // DEFAULT ELEMENT 'a' TESTS @@ -372,7 +367,7 @@ ruleTester.run('anchor-is-valid', rule, { options: specialLink, }, - // CUSTOM BOTH COMPONENTS AND SPECIALLINK TESTS + // CUSTOM BOTH COMPONENTS AND SPECIAL LINK TESTS // NO HREF { code: '', errors: [noHrefexpectedError], options: componentsAndSpecialLink }, { code: '', errors: [noHrefexpectedError], options: componentsAndSpecialLink }, @@ -522,27 +517,7 @@ ruleTester.run('anchor-is-valid', rule, { errors: [invalidHrefexpectedError], }, - // CUSTOM COMPONENTS AND SPECIALLINK AND ASPECT - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, - { - code: '', - options: componentsAndSpecialLinkAndNoHrefAspect, - errors: [noHrefexpectedError], - }, + // CUSTOM COMPONENTS AND SPECIAL LINK AND ASPECT { code: '', options: componentsAndSpecialLinkAndNoHrefAspect, diff --git a/__tests__/src/rules/img-redundant-alt-test.js b/__tests__/src/rules/img-redundant-alt-test.js index 3bd5fcbbe..73bb14f02 100644 --- a/__tests__/src/rules/img-redundant-alt-test.js +++ b/__tests__/src/rules/img-redundant-alt-test.js @@ -67,8 +67,8 @@ ruleTester.run('img-redundant-alt', rule, { { code: '{imageAlt}' }, { code: '{imageAlt.name}' }, semver.satisfies(eslintVersion, '>= 6') ? [ - { code: '{imageAlt?.name}', parserOptions: { ecmaVersion: 2020 } }, - { code: 'Doing cool things', parserOptions: { ecmaVersion: 2020 } }, + { code: '{imageAlt?.name}', languageOptions: { ecmaVersion: 2020 } }, + { code: 'Doing cool things', languageOptions: { ecmaVersion: 2020 } }, ] : [], { code: 'Photography;' }, { code: 'ImageMagick;' }, diff --git a/__tests__/src/rules/no-noninteractive-element-interactions-test.js b/__tests__/src/rules/no-noninteractive-element-interactions-test.js index 2a82b168e..c75311cd5 100644 --- a/__tests__/src/rules/no-noninteractive-element-interactions-test.js +++ b/__tests__/src/rules/no-noninteractive-element-interactions-test.js @@ -336,7 +336,6 @@ const neverValid = [ { code: ' {}} />;', errors: [expectedError] }, { code: ' {}} />;', errors: [expectedError] }, { code: '