Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/dry-turtles-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-node-roikoren': major
---

chore: transpile typescript to es2020
5 changes: 5 additions & 0 deletions .changeset/hungry-maps-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-node-roikoren': major
---

chore: drop node v12 support
5 changes: 5 additions & 0 deletions .changeset/lovely-files-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-node-roikoren': major
---

chore: update default ecmaVersion to es2020
28 changes: 0 additions & 28 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {} },
Expand All @@ -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,
Expand Down Expand Up @@ -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 } },
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/configs/recommended-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }] },
};
Expand Down
2 changes: 1 addition & 1 deletion src/configs/recommended-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [] }] },
};
Expand Down
1 change: 0 additions & 1 deletion src/rules/global-require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
12 changes: 3 additions & 9 deletions src/rules/no-mixed-requires.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IOptions>);
}
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' });
}
},
Expand Down
4 changes: 0 additions & 4 deletions src/rules/no-path-concat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ const collectFirstCharsOfTemplateElement = (
): void => {
const element = node.quasis[i].value.cooked;

if (!element && element !== '') {
return;
}

if (element !== '') {
outNextChars.push(element[0]);

Expand Down
3 changes: 0 additions & 3 deletions src/rules/process-exit-as-throw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,14 @@ interface ICodePath {
const CodePathAnalyzer = safeRequire<ICodePathAnalyzer>(
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<ICodePathSegment>(
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<ICodePath>(
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'];
Expand Down
7 changes: 0 additions & 7 deletions tests/src/dynamic-import.ts

This file was deleted.

16 changes: 1 addition & 15 deletions tests/src/es2020.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Loading