Skip to content
Merged
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

135 changes: 0 additions & 135 deletions .eslintrc.js

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
run: npm run build

- name: lint
# Skip on old Node.js, devDependencies use newish JS features.
if: matrix.node != '14'
# Only run lint on latest Node.js, because devDependencies use new JS features.
if: matrix.node == '20' && runner.os != 'Windows'
run: npm run lint

- name: test
Expand Down
160 changes: 160 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import js from '@eslint/js';
import globals from 'globals';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import unicorn from 'eslint-plugin-unicorn';
import importPlugin from 'eslint-plugin-import';
import prettierConfig from 'eslint-config-prettier/flat';

export default [
// TODO: enable these
// js.configs.recommended,
// typescriptEslint.configs.recommended,
// unicorn.configs.recommended,
// prettierConfig,
{
files: ['packages/neovim/bin/cli.js', '**/*.ts'],
ignores: [
'**/*.d.ts',
// TODO: these are probably broken because they don't end with "**"?
// irrelevant for now because --ignore-pattern is specified in the "lint" task directly.
'packages/*/lib/',
'packages/*/bin/',
'packages/neovim/scripts/',
'packages/integration-tests/__tests__/',
'examples/rplugin/node/',
'packages/example-plugin/',
'packages/example-plugin-decorators/',
],
languageOptions: {
parser: typescriptParser,
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 'latest',
sourceType: 'module',
},
globals: {
...globals.node,
...globals.es2020,
...globals.mocha,
},
},
plugins: {
'@typescript-eslint': typescriptEslint,
unicorn,
import: importPlugin,
},
settings: {
'import/resolver': { node: { extensions: ['.js', '.jsx', '.ts'] } },
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
rules: {
curly: 'error', // Enforce braces on "if"/"for"/etc.
// Avoid accidental use of "==" instead of "===".
eqeqeq: 'error',
camelcase: ['error', { properties: 'never' }],
'class-methods-use-this': 'off',
'comma-dangle': [
'error',
{
arrays: 'only-multiline',
objects: 'only-multiline',
imports: 'only-multiline',
exports: 'only-multiline',
functions: 'ignore',
},
],
'no-restricted-syntax': 'off',
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
'no-underscore-dangle': 'off',
'no-mixed-operators': 'off',
'func-names': 'off',
'max-classes-per-file': 'off',
'operator-assignment': ['error', 'never'],

// For overloading (and typescript throws when dupe members anyway)
'no-dupe-class-members': 'off',

// Causes issues with enums
'no-shadow': 'off',
'prefer-destructuring': 'off', // Intentionally disabled trash.

'import/extensions': 'off',
'import/prefer-default-export': 'off',

'global-require': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-mutable-exports': 'error',
'new-cap': 'error',
'no-console': 'error',
'no-param-reassign': ['error', { props: true }],
'no-void': 'error',

'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
// TODO: '@typescript-eslint/no-floating-promises': 'error', // Promises must catch errors or be awaited.
// TODO? '@typescript-eslint/no-unsafe-assignment': 'error',
// TODO? '@typescript-eslint/no-unsafe-return': 'error',
// TODO? '@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',

// Rules from https://github.com/sindresorhus/eslint-plugin-unicorn
// TODO: 'unicorn/no-useless-promise-resolve-reject': 'error',
// TODO: 'unicorn/prefer-event-target': 'error',
// TODO: 'unicorn/prefer-string-slice': 'error',
// TODO? 'unicorn/custom-error-definition': 'error',
// TODO? 'unicorn/prefer-json-parse-buffer': 'error',
// TODO? ESM modules https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-module.md
// 'unicorn/prefer-module': 'error',
// 'unicorn/no-null': 'error',
'unicorn/no-abusive-eslint-disable': 'error',
'unicorn/prefer-at': 'error',
'unicorn/prefer-negative-index': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-ternary': 'error',
'unicorn/no-unnecessary-polyfills': 'error',
'unicorn/no-useless-spread': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-blob-reading-methods': 'error',
'unicorn/prefer-code-point': 'error',
'unicorn/prefer-date-now': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
'unicorn/prefer-includes': 'error',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-modern-dom-apis': 'error',
'unicorn/prefer-modern-math-apis': 'error',
'unicorn/prefer-native-coercion-functions': 'error',
'unicorn/prefer-node-protocol': 'error',
'unicorn/prefer-object-from-entries': 'error',
'unicorn/prefer-reflect-apply': 'error',
'unicorn/prefer-string-trim-start-end': 'error',
'unicorn/prefer-type-error': 'error',
},
},
{
files: ['**/*.test.ts'],
rules: {
// This rule requires es2022(?) but the CI node14 job runs the tests
// in node14, but the test code is not compiled/polyfilled... so the
// test code needs to be compatible with node14.
// TODO: can the back-compat CI jobs for older node.js versions run
// `jest` against the compiled .js results (would require compiling
// the test files as well)?
'unicorn/prefer-at': 'off',
'new-cap': 'off',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: true, optionalDependencies: false, peerDependencies: false },
],
},
},
];
Loading
Loading