diff --git a/.changeset/dry-turtles-repair.md b/.changeset/dry-turtles-repair.md new file mode 100644 index 0000000..61ff25a --- /dev/null +++ b/.changeset/dry-turtles-repair.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-node-roikoren': major +--- + +chore: transpile typescript to es2020 diff --git a/.changeset/hungry-maps-join.md b/.changeset/hungry-maps-join.md new file mode 100644 index 0000000..fecfcc5 --- /dev/null +++ b/.changeset/hungry-maps-join.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-node-roikoren': major +--- + +chore: drop node v12 support diff --git a/.changeset/lovely-files-pay.md b/.changeset/lovely-files-pay.md new file mode 100644 index 0000000..211da37 --- /dev/null +++ b/.changeset/lovely-files-pay.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-node-roikoren': major +--- + +chore: update default ecmaVersion to es2020 diff --git a/.eslintrc.js b/.eslintrc.js index e53192e..0012f69 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,7 +9,6 @@ module.exports = { jsxPragma: null, }, reportUnusedDisableDirectives: true, - plugins: ['import'], settings: { 'import/parsers': { '@typescript-eslint/parser': ['.ts'] }, 'import/resolver': { node: { extensions: ['.ts', '.js', '.json'] }, typescript: {} }, @@ -36,7 +35,6 @@ module.exports = { 'max-lines': ERROR, 'no-bitwise': ERROR, 'no-caller': ERROR, - 'no-case-declarations': ERROR, 'no-console': ERROR, 'no-constant-binary-expression': ERROR, 'no-constructor-return': ERROR, @@ -173,50 +171,24 @@ module.exports = { 'import/extensions': [ERROR, { json: 'always' }], 'import/first': ERROR, - 'import/named': ERROR, - 'import/namespace': ERROR, 'import/newline-after-import': ERROR, 'import/no-cycle': ERROR, 'import/no-default-export': ERROR, 'import/no-duplicates': ERROR, 'import/no-extraneous-dependencies': ERROR, - 'import/no-unresolved': ERROR, 'import/no-useless-path-segments': ERROR, 'import/order': [ ERROR, { alphabetize: { order: 'asc' }, 'newlines-between': 'always', warnOnUnassignedImports: true }, ], - 'unicorn/better-regex': ERROR, - 'unicorn/catch-error-name': ERROR, - 'unicorn/consistent-function-scoping': ERROR, - 'unicorn/explicit-length-check': ERROR, - 'unicorn/filename-case': ERROR, 'unicorn/import-index': ERROR, - 'unicorn/import-style': ERROR, 'unicorn/no-array-for-each': OFF, 'unicorn/no-array-reduce': OFF, - 'unicorn/no-array-callback-reference': ERROR, 'unicorn/no-null': OFF, - 'unicorn/no-object-as-default-parameter': ERROR, - 'unicorn/no-process-exit': ERROR, - 'unicorn/no-unreadable-array-destructuring': ERROR, - 'unicorn/no-useless-undefined': ERROR, - 'unicorn/prefer-add-event-listener': ERROR, - 'unicorn/prefer-array-flat': ERROR, 'unicorn/prefer-module': OFF, - 'unicorn/prefer-negative-index': ERROR, 'unicorn/prefer-node-protocol': OFF, - 'unicorn/prefer-number-properties': ERROR, - 'unicorn/prefer-object-from-entries': ERROR, - 'unicorn/prefer-optional-catch-binding': ERROR, - 'unicorn/prefer-query-selector': ERROR, - 'unicorn/prefer-set-has': ERROR, - 'unicorn/prefer-spread': ERROR, - 'unicorn/prefer-string-slice': ERROR, - 'unicorn/prefer-ternary': ERROR, 'unicorn/prevent-abbreviations': OFF, - 'unicorn/template-indent': ERROR, }, overrides: [ { files: ['./.commitlintrc.js', './.eslintrc.js', './.prettierrc.js'], rules: { 'no-undef': OFF } }, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abea991..a036936 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: strategy: matrix: eslint: [7.0.0, 7, 8] - node: [12, 14, 16, 18] + node: [14, 16, 18] os: [ubuntu-latest] include: # On other platforms @@ -63,11 +63,12 @@ jobs: node-version: ${{ matrix.node }} cache: npm - name: Install NPM v8 - if: matrix.node != 16 + if: matrix.node != 16 && matrix.node != 18 run: npm i -g npm - name: Install Packages run: npm i - name: Install ESLint ${{ matrix.eslint }} + if: matrix.eslint != 8 run: npm i eslint@${{ matrix.eslint }} -D - name: Test run: npm test diff --git a/package-lock.json b/package-lock.json index 3de5516..c731d1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -951,7 +951,7 @@ "node_modules/@codechecks/client/node_modules/is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", "dev": true, "engines": { "node": ">=0.10.0" @@ -3340,7 +3340,7 @@ "node_modules/eslint-module-utils/node_modules/find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "integrity": "sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==", "dev": true, "dependencies": { "locate-path": "^2.0.0" @@ -3352,7 +3352,7 @@ "node_modules/eslint-module-utils/node_modules/locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "integrity": "sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==", "dev": true, "dependencies": { "p-locate": "^2.0.0", @@ -7239,7 +7239,7 @@ "node_modules/supports-hyperlinks/node_modules/has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "integrity": "sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==", "dev": true, "engines": { "node": ">=0.10.0" @@ -7260,7 +7260,7 @@ "node_modules/supports-hyperlinks/node_modules/supports-color/node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true, "engines": { "node": ">=4" @@ -8688,7 +8688,7 @@ "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", "dev": true }, "json5": { @@ -10443,7 +10443,7 @@ "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "integrity": "sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==", "dev": true, "requires": { "locate-path": "^2.0.0" @@ -10452,7 +10452,7 @@ "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "integrity": "sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==", "dev": true, "requires": { "p-locate": "^2.0.0", @@ -11329,7 +11329,7 @@ "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", "dev": true }, "json5": { @@ -13084,7 +13084,7 @@ "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "integrity": "sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==", "dev": true, "requires": { "locate-path": "^2.0.0" @@ -13093,7 +13093,7 @@ "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "integrity": "sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA==", "dev": true, "requires": { "p-locate": "^2.0.0", @@ -15571,7 +15571,7 @@ "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "integrity": "sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==", "dev": true }, "supports-color": { @@ -15586,7 +15586,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true } } @@ -18451,7 +18451,7 @@ "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "integrity": "sha512-P+1n3MnwjR/Epg9BBo1KT8qbye2g2Ou4sFumihwt6I4tsUX7jnLcX4BTOSKg/B1ZrIYMN9FcEnG4x5a7NB8Eng==", "dev": true }, "supports-color": { @@ -18466,7 +18466,7 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "dev": true } } diff --git a/src/configs/recommended-module.ts b/src/configs/recommended-module.ts index 9ffe124..cf40936 100644 --- a/src/configs/recommended-module.ts +++ b/src/configs/recommended-module.ts @@ -4,7 +4,7 @@ import { commonGlobals, commonRules } from './commons'; const recommendedModule: TSESLint.Linter.Config = { globals: { ...commonGlobals, __dirname: 'off', __filename: 'off', exports: 'off', module: 'off', require: 'off' }, - parserOptions: { ecmaFeatures: { globalReturn: false }, ecmaVersion: 2019, sourceType: 'module' }, + parserOptions: { ecmaFeatures: { globalReturn: false }, ecmaVersion: 2020, sourceType: 'module' }, plugins: ['node-roikoren'], rules: { ...commonRules, 'node-roikoren/no-unsupported-features/es-syntax': ['error', { ignores: ['modules'] }] }, }; diff --git a/src/configs/recommended-script.ts b/src/configs/recommended-script.ts index 72c3803..cc028ab 100644 --- a/src/configs/recommended-script.ts +++ b/src/configs/recommended-script.ts @@ -11,7 +11,7 @@ const recommendedScript: TSESLint.Linter.Config = { module: 'readonly', require: 'readonly', }, - parserOptions: { ecmaFeatures: { globalReturn: true }, ecmaVersion: 2019, sourceType: 'script' }, + parserOptions: { ecmaFeatures: { globalReturn: true }, ecmaVersion: 2020, sourceType: 'script' }, plugins: ['node-roikoren'], rules: { ...commonRules, 'node-roikoren/no-unsupported-features/es-syntax': ['error', { ignores: [] }] }, }; diff --git a/src/rules/global-require.ts b/src/rules/global-require.ts index e4d69a1..bc235fb 100644 --- a/src/rules/global-require.ts +++ b/src/rules/global-require.ts @@ -27,7 +27,6 @@ const findReference = (scope: TSESLint.Scope.Scope, node: TSESTree.Identifier): (reference) => reference.identifier.range[0] === node.range[0] && reference.identifier.range[1] === node.range[1], ); - /* istanbul ignore else: correctly returns null */ if (references.length === 1) { return references[0]; } diff --git a/src/rules/no-mixed-requires.ts b/src/rules/no-mixed-requires.ts index cdd9c5b..a37bc9f 100644 --- a/src/rules/no-mixed-requires.ts +++ b/src/rules/no-mixed-requires.ts @@ -207,19 +207,13 @@ export default createRule<[options: IOptions], 'noMixCoreModuleFileComputed' | ' }, defaultOptions: [{ grouping: false, allowCall: false }], create(context, appliedOptions) { - const [options] = appliedOptions; - let grouping = false; - let allowCall = false; - - if (typeof options === 'object') { - ({ grouping, allowCall } = options as Required); - } + const [{ grouping, allowCall }] = appliedOptions; return { VariableDeclaration(node) { - if (isMixed(allowCall, node.declarations)) { + if (isMixed(allowCall ?? false, node.declarations)) { context.report({ node, messageId: 'noMixRequire' }); - } else if (grouping && !isGrouped(allowCall, node.declarations)) { + } else if (grouping && !isGrouped(allowCall ?? false, node.declarations)) { context.report({ node, messageId: 'noMixCoreModuleFileComputed' }); } }, diff --git a/src/rules/no-path-concat.ts b/src/rules/no-path-concat.ts index 18949d5..e5a0824 100644 --- a/src/rules/no-path-concat.ts +++ b/src/rules/no-path-concat.ts @@ -24,10 +24,6 @@ const collectFirstCharsOfTemplateElement = ( ): void => { const element = node.quasis[i].value.cooked; - if (!element && element !== '') { - return; - } - if (element !== '') { outNextChars.push(element[0]); diff --git a/src/rules/process-exit-as-throw.ts b/src/rules/process-exit-as-throw.ts index 7a167dd..81927d3 100644 --- a/src/rules/process-exit-as-throw.ts +++ b/src/rules/process-exit-as-throw.ts @@ -50,17 +50,14 @@ interface ICodePath { const CodePathAnalyzer = safeRequire( path.join(require.resolve('eslint'), '..', 'linter', 'code-path-analysis', 'code-path-analyzer'), 'eslint/lib/linter/code-path-analysis/code-path-analyzer', - 'eslint/lib/code-path-analysis/code-path-analyzer', ); const CodePathSegment = safeRequire( path.join(require.resolve('eslint'), '..', 'linter', 'code-path-analysis', 'code-path-segment'), 'eslint/lib/linter/code-path-analysis/code-path-segment', - 'eslint/lib/code-path-analysis/code-path-segment', ); const CodePath = safeRequire( path.join(require.resolve('eslint'), '..', 'linter', 'code-path-analysis', 'code-path'), 'eslint/lib/linter/code-path-analysis/code-path', - 'eslint/lib/code-path-analysis/code-path', ); const originalLeaveNode = CodePathAnalyzer?.prototype.leaveNode as ICodePathAnalyzer['prototype']['leaveNode']; diff --git a/tests/src/dynamic-import.ts b/tests/src/dynamic-import.ts deleted file mode 100644 index 50e0034..0000000 --- a/tests/src/dynamic-import.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { TSESLint } from '@typescript-eslint/utils'; - -export const DynamicImportSupported = (() => { - const messages = new TSESLint.Linter().verify('import(s)', { parserOptions: { ecmaVersion: 2020 } }); - - return messages.length === 0; -})(); diff --git a/tests/src/es2020.ts b/tests/src/es2020.ts index d9db05c..c06b3dd 100644 --- a/tests/src/es2020.ts +++ b/tests/src/es2020.ts @@ -6,20 +6,6 @@ const ES2021Supported = (() => { return messages.length === 0; })(); -const ES2020Supported = - ES2021Supported || - (() => { - const messages = new TSESLint.Linter().verify('0n', { parserOptions: { ecmaVersion: 2020 } }); - - return messages.length === 0; - })(); - -const getEcmaVersion = (): TSESLint.EcmaVersion => { - if (ES2021Supported) { - return 2021; - } - - return ES2020Supported ? 2020 : 2019; -}; +const getEcmaVersion = (): TSESLint.EcmaVersion => (ES2021Supported ? 2021 : 2020); export const ecmaVersion = getEcmaVersion(); diff --git a/tests/src/rules/file-extension-in-import.ts b/tests/src/rules/file-extension-in-import.ts index 77bf96f..f4cf006 100644 --- a/tests/src/rules/file-extension-in-import.ts +++ b/tests/src/rules/file-extension-in-import.ts @@ -6,7 +6,6 @@ import { TSESLint } from '@typescript-eslint/utils'; import { gte } from 'semver'; import rule from '../../../src/rules/file-extension-in-import'; -import { DynamicImportSupported } from '../dynamic-import'; const error = (ext: string, notForbid?: boolean): TSESLint.TestCaseError<`${'forbid' | 'require'}Ext`> => ({ messageId: `${notForbid ? 'require' : 'forbid'}Ext`, @@ -16,10 +15,6 @@ const error = (ext: string, notForbid?: boolean): TSESLint.TestCaseError<`${'for type: AST_NODE_TYPES.Literal, }); -if (!DynamicImportSupported) { - console.warn("[%s] Skip tests for 'import()'", path.basename(__filename, '.js')); -} - const fixture = (filename: string, ts?: boolean): string => path.resolve(__dirname, `../../fixtures/file-extension-in-import${ts ? '-ts' : ''}`, filename); @@ -176,25 +171,21 @@ new TSESLint.RuleTester({ }, // import() - ...(DynamicImportSupported - ? [ - { - filename: fixture('test.js'), - code: "function f() { import('./a') }", - output: "function f() { import('./a.js') }", - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error('js', true), column: 23 }], - }, - { - filename: fixture('test.js'), - code: "function f() { import('./a.js') }", - output: "function f() { import('./a') }", - options: ['never'] as const, - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error('js'), column: 23 }], - }, - ] - : []), + { + filename: fixture('test.js'), + code: "function f() { import('./a') }", + output: "function f() { import('./a.js') }", + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error('js', true), column: 23 }], + }, + { + filename: fixture('test.js'), + code: "function f() { import('./a.js') }", + output: "function f() { import('./a') }", + options: ['never'], + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error('js'), column: 23 }], + }, ], }); @@ -356,25 +347,21 @@ if (gte((TSESLint.ESLint.version || TSESLint.Linter.version || TSESLint.CLIEngin }, // import() - ...(DynamicImportSupported - ? [ - { - filename: fixture('test.ts', true), - code: "function f() { import('./a') }", - output: "function f() { import('./a.js') }", - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error('js', true), column: 23 }], - }, - { - filename: fixture('test.ts', true), - code: "function f() { import('./a.ts') }", - output: "function f() { import('./a') }", - options: ['never'] as const, - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error('ts'), column: 23 }], - }, - ] - : []), + { + filename: fixture('test.ts', true), + code: "function f() { import('./a') }", + output: "function f() { import('./a.js') }", + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error('js', true), column: 23 }], + }, + { + filename: fixture('test.ts', true), + code: "function f() { import('./a.ts') }", + output: "function f() { import('./a') }", + options: ['never'], + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error('ts'), column: 23 }], + }, ], }); } diff --git a/tests/src/rules/no-extraneous-import.ts b/tests/src/rules/no-extraneous-import.ts index effacb8..12b4294 100644 --- a/tests/src/rules/no-extraneous-import.ts +++ b/tests/src/rules/no-extraneous-import.ts @@ -5,11 +5,6 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types'; import { TSESLint } from '@typescript-eslint/utils'; import rule from '../../../src/rules/no-extraneous-import'; -import { DynamicImportSupported } from '../dynamic-import'; - -if (!DynamicImportSupported) { - console.warn("[%s] Skip tests for 'import()'", path.basename(__filename, '.js')); -} const error = { messageId: 'extraneous' as const, @@ -66,16 +61,12 @@ new TSESLint.RuleTester({ { filename: fixture('optionalDependencies/a.js'), code: "import bbb from 'bbb'", errors: [error] }, // import() - ...(DynamicImportSupported - ? [ - { - filename: fixture('dependencies/a.js'), - code: "function f() { import('bbb') }", - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error, column: 23 }], - }, - ] - : []), + { + filename: fixture('dependencies/a.js'), + code: "function f() { import('bbb') }", + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error, column: 23 }], + }, ], }); diff --git a/tests/src/rules/no-missing-import.ts b/tests/src/rules/no-missing-import.ts index dc8e4f8..dc8e6b3 100644 --- a/tests/src/rules/no-missing-import.ts +++ b/tests/src/rules/no-missing-import.ts @@ -4,11 +4,6 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types'; import { TSESLint } from '@typescript-eslint/utils'; import rule from '../../../src/rules/no-missing-import'; -import { DynamicImportSupported } from '../dynamic-import'; - -if (!DynamicImportSupported) { - console.warn("[%s] Skip tests for 'import()'", path.basename(__filename, '.js')); -} const error = (name: string): TSESLint.TestCaseError<'missing'> => ({ messageId: 'missing', @@ -91,15 +86,7 @@ new TSESLint.RuleTester({ }, // import() - ...(DynamicImportSupported - ? [ - { - filename: fixture('test.js'), - code: 'function f() { import(foo) }', - parserOptions: { ecmaVersion: 2020 as const }, - }, - ] - : []), + { filename: fixture('test.js'), code: 'function f() { import(foo) }', parserOptions: { ecmaVersion: 2020 } }, // onlyRelativePath option { @@ -150,16 +137,12 @@ new TSESLint.RuleTester({ { filename: fixture('test.js'), code: "import a from './A.js';", errors: [{ ...error('./A.js'), column: 15 }] }, // import() - ...(DynamicImportSupported - ? [ - { - filename: fixture('test.js'), - code: "function f() { import('no-exist-package-0') }", - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error('no-exist-package-0'), column: 23 }], - }, - ] - : []), + { + filename: fixture('test.js'), + code: "function f() { import('no-exist-package-0') }", + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error('no-exist-package-0'), column: 23 }], + }, // onlyRelativePath option { diff --git a/tests/src/rules/no-restricted-import.ts b/tests/src/rules/no-restricted-import.ts index a278bf2..407a518 100644 --- a/tests/src/rules/no-restricted-import.ts +++ b/tests/src/rules/no-restricted-import.ts @@ -5,11 +5,6 @@ import { TSESLint } from '@typescript-eslint/utils'; import rule from '../../../src/rules/no-restricted-import'; import type { RestrictionDefinition } from '../../../src/util/check-restricted'; -import { DynamicImportSupported } from '../dynamic-import'; - -if (!DynamicImportSupported) { - console.warn("[%s] Skip tests for 'import()'", path.basename(__filename, '.js')); -} const error = (name: string, replace?: string): TSESLint.TestCaseError<'restricted'> => ({ messageId: 'restricted', @@ -42,9 +37,7 @@ new TSESLint.RuleTester({ }, // import() - ...(DynamicImportSupported - ? [{ code: 'import(fs)', options: [['fs']] as readonly [['fs']], parserOptions: { ecmaVersion: 2020 as const } }] - : []), + { code: 'import(fs)', options: [['fs']], parserOptions: { ecmaVersion: 2020 } }, ], invalid: [ { code: 'import "fs"', options: [['fs']], errors: [error('fs')] }, @@ -91,15 +84,6 @@ new TSESLint.RuleTester({ ]), // import() - ...(DynamicImportSupported - ? [ - { - code: 'import("fs")', - options: [['fs']] as readonly [['fs']], - parserOptions: { ecmaVersion: 2020 as const }, - errors: [error('fs')], - }, - ] - : []), + { code: 'import("fs")', options: [['fs']], parserOptions: { ecmaVersion: 2020 }, errors: [error('fs')] }, ], }); diff --git a/tests/src/rules/no-unpublished-import.ts b/tests/src/rules/no-unpublished-import.ts index f9a8648..ff94887 100644 --- a/tests/src/rules/no-unpublished-import.ts +++ b/tests/src/rules/no-unpublished-import.ts @@ -4,11 +4,6 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types'; import { TSESLint } from '@typescript-eslint/utils'; import rule from '../../../src/rules/no-unpublished-import'; -import { DynamicImportSupported } from '../dynamic-import'; - -if (!DynamicImportSupported) { - console.warn("[%s] Skip tests for 'import()'", path.basename(__filename, '.js')); -} const error = (name: string): TSESLint.TestCaseError<'notPublished'> => ({ messageId: 'notPublished', @@ -141,15 +136,11 @@ new TSESLint.RuleTester({ }, // import() - ...(DynamicImportSupported - ? [ - { - filename: fixture('2/test.js'), - code: "function f() { import('./ignore1.js') }", - parserOptions: { ecmaVersion: 2020 as const }, - errors: [{ ...error('./ignore1.js'), column: 23 }], - }, - ] - : []), + { + filename: fixture('2/test.js'), + code: "function f() { import('./ignore1.js') }", + parserOptions: { ecmaVersion: 2020 }, + errors: [{ ...error('./ignore1.js'), column: 23 }], + }, ], }); diff --git a/tests/src/rules/no-unsupported-features/es-syntax.ts b/tests/src/rules/no-unsupported-features/es-syntax.ts index 38a655a..e5a9758 100644 --- a/tests/src/rules/no-unsupported-features/es-syntax.ts +++ b/tests/src/rules/no-unsupported-features/es-syntax.ts @@ -1277,7 +1277,6 @@ new TSESLint.RuleTester({ // ---------------------------------------------------------------------- { keyword: 'bigint', - requiredEcmaVersion: 2020, valid: [ { code: 'var n = 0n', options: [{ version: '10.4.0' }] }, { code: 'var n = BigInt(0)', options: [{ version: '10.3.0' }] }, @@ -1310,7 +1309,6 @@ new TSESLint.RuleTester({ }, { keyword: 'dynamicImport', - requiredEcmaVersion: 2020, valid: [ { code: 'obj.import(source)', options: [{ version: '12.0.0' }] }, { code: 'import(source)', options: [{ version: '12.17.0' }] }, @@ -1351,7 +1349,6 @@ new TSESLint.RuleTester({ }, { keyword: 'optionalChaining', - requiredEcmaVersion: 2020, valid: [{ code: 'foo?.bar;', options: [{ version: '14.0.0' }] }], invalid: [ { @@ -1365,7 +1362,6 @@ new TSESLint.RuleTester({ }, { keyword: 'nullishCoalescingOperators', - requiredEcmaVersion: 2020, valid: [{ code: 'foo ?? bar;', options: [{ version: '14.0.0' }] }], invalid: [ { diff --git a/tsconfig.json b/tsconfig.json index 6e5a96a..495a47f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,6 @@ "tests/**/*.ts", "index.ts", ".eslintrc.js", - ".prettierrc.js", - "commitlint.config.js" + ".prettierrc.js" ] } diff --git a/tsconfig.prod.json b/tsconfig.prod.json index c6e210f..eca8437 100644 --- a/tsconfig.prod.json +++ b/tsconfig.prod.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es6", + "target": "es2020", "module": "commonjs", "allowJs": true, "declaration": true, @@ -11,6 +11,5 @@ "preserveSymlinks": true, "resolveJsonModule": true }, - "exclude": ["**/*.spec.ts", "**/*.spec.tsx", "**/__tests__", "**/dist/**/*"], - "include": ["src/**/*", "index.ts", "base.ts", "playwright.ts", "type-checking.ts", ".eslintrc.ts"] + "include": ["src/**/*"] }