Skip to content

Commit fe762dd

Browse files
committed
Improve further eslint config
1 parent 5887422 commit fe762dd

File tree

5 files changed

+93
-74
lines changed

5 files changed

+93
-74
lines changed

.eslintignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
node_modules
22
dist
3-
examples
4-
scripts
5-
tests/env
6-
coverage
7-
/jest-disable-built-in-fetch.js
3+
/tests/env
4+
/coverage
5+
# @TODO: I'm not sure what's going on here, we're importing
6+
# in JS file from TS files, better left ignored for now
7+
/playgrounds

.eslintrc.js

Lines changed: 78 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22

33
module.exports = {
44
root: true,
5-
plugins: ['tsdoc', '@typescript-eslint'],
65
env: {
76
// @TODO: Can be removed, ES versions are cumulative:
87
// https://stackoverflow.com/a/61688878
98
// es6: true,
10-
es2020: true,
9+
// This seems to be what Node.js 20 fully supports, but online documentation
10+
// isn't exactly crystal clear about what should be put here
11+
es2022: true,
1112
browser: true,
1213
node: true,
1314
},
14-
parser: '@typescript-eslint/parser',
15+
// Standard linting for pure javascript files
1516
parserOptions: {
1617
// @TODO: Can be removed, as env ES version sets this too:
1718
// https://eslint.org/docs/latest/use/configure/language-options#specifying-environments
1819
// ecmaVersion: 2019,
19-
sourceType: 'module',
20-
project: 'tsconfig.eslint.json',
20+
// @TODO: Remove because in JS files we use commonjs
21+
// sourceType: 'module',
2122
},
23+
// prettier must always be put last, so it overrides anything before it
2224
extends: [
2325
'eslint:recommended',
24-
'plugin:@typescript-eslint/recommended-type-checked',
2526
// Disables all style rules
2627
// https://prettier.io/docs/en/integrating-with-linters.html
2728
// https://github.com/prettier/eslint-config-prettier
@@ -31,60 +32,78 @@ module.exports = {
3132
// @TODO: Remove this rule, as it's a style rule covered by prettier and
3233
// it's deprecated https://eslint.org/docs/latest/rules/comma-dangle
3334
// 'comma-dangle': 'off',
34-
// @TODO: Remove as it doesn't seem to cause issues anymore with fn overloads
35-
// 'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions
36-
'tsdoc/syntax': 'error',
37-
// new TS rules begin @TODO: Remove these and adapt code
38-
'@typescript-eslint/prefer-as-const': 'off',
39-
'@typescript-eslint/ban-ts-comment': 'off',
40-
'@typescript-eslint/no-unsafe-call': 'off',
41-
'@typescript-eslint/no-unsafe-member-access': 'off',
42-
'@typescript-eslint/no-unsafe-return': 'off',
43-
'@typescript-eslint/no-unsafe-assignment': 'off',
44-
'@typescript-eslint/no-unsafe-argument': 'off',
45-
'@typescript-eslint/no-floating-promises': 'off',
46-
// new TS rules end
47-
'@typescript-eslint/array-type': ['warn', { default: 'array-simple' }],
48-
// @TODO: Remove, as it's already off
49-
// '@typescript-eslint/return-await': 'off',
50-
// @TODO: Remove this rule, deprecated:
51-
// https://typescript-eslint.io/rules/space-before-function-paren/
52-
// '@typescript-eslint/space-before-function-paren': 0,
53-
// @TODO: Should be careful with this rule, should leave it be and disable
54-
// it within files where necessary with explanations
55-
'@typescript-eslint/no-explicit-any': 'off',
56-
// @TODO: Remove, as it's already off
57-
// '@typescript-eslint/explicit-function-return-type': 'off',
58-
// @TODO: Remove, as it's already off
59-
// '@typescript-eslint/no-throw-literal': 'off',
60-
'@typescript-eslint/no-unused-vars': [
61-
'error',
62-
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
63-
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
64-
{ args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
65-
],
66-
// @TODO: Remove this rule, as it's a style rule covered by prettier
67-
// '@typescript-eslint/member-delimiter-style': [
68-
// 'error',
69-
// {
70-
// multiline: {
71-
// delimiter: 'none', // 'none' or 'semi' or 'comma'
72-
// requireLast: true,
73-
// },
74-
// singleline: {
75-
// delimiter: 'semi', // 'semi' or 'comma'
76-
// requireLast: false,
77-
// },
78-
// },
79-
// ],
80-
// @TODO: Not recommended to disable rule, should instead disable locally
81-
// with explanation
82-
'@typescript-eslint/ban-ts-ignore': 'off',
8335
},
8436
overrides: [
85-
// Jest linting is only for test files
37+
// TypeScript linting for TypeScript files
8638
{
87-
files: ['tests/**/*.ts'],
39+
files: '*.ts',
40+
plugins: [
41+
'@typescript-eslint',
42+
// TSDoc is only meant for TS files https://tsdoc.org/
43+
'eslint-plugin-tsdoc',
44+
],
45+
parser: '@typescript-eslint/parser',
46+
parserOptions: { project: 'tsconfig.eslint.json' },
47+
// prettier must always be put last, so it overrides anything before it
48+
extends: [
49+
'plugin:@typescript-eslint/recommended-type-checked',
50+
'prettier',
51+
],
52+
rules: {
53+
// @TODO: Remove as it doesn't seem to cause issues anymore with fn overloads
54+
// 'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions
55+
'tsdoc/syntax': 'error',
56+
// new TS rules begin @TODO: Remove these and adapt code
57+
'@typescript-eslint/prefer-as-const': 'off',
58+
'@typescript-eslint/ban-ts-comment': 'off',
59+
'@typescript-eslint/no-unsafe-call': 'off',
60+
'@typescript-eslint/no-unsafe-member-access': 'off',
61+
'@typescript-eslint/no-unsafe-return': 'off',
62+
'@typescript-eslint/no-unsafe-assignment': 'off',
63+
'@typescript-eslint/no-unsafe-argument': 'off',
64+
'@typescript-eslint/no-floating-promises': 'off',
65+
// new TS rules end
66+
'@typescript-eslint/array-type': ['warn', { default: 'array-simple' }],
67+
// @TODO: Remove, as it's already off
68+
// '@typescript-eslint/return-await': 'off',
69+
// @TODO: Remove this rule, deprecated:
70+
// https://typescript-eslint.io/rules/space-before-function-paren/
71+
// '@typescript-eslint/space-before-function-paren': 0,
72+
// @TODO: Should be careful with this rule, should leave it be and disable
73+
// it within files where necessary with explanations
74+
'@typescript-eslint/no-explicit-any': 'off',
75+
// @TODO: Remove, as it's already off
76+
// '@typescript-eslint/explicit-function-return-type': 'off',
77+
// @TODO: Remove, as it's already off
78+
// '@typescript-eslint/no-throw-literal': 'off',
79+
'@typescript-eslint/no-unused-vars': [
80+
'error',
81+
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
82+
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
83+
{ args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
84+
],
85+
// @TODO: Remove this rule, as it's a style rule covered by prettier
86+
// '@typescript-eslint/member-delimiter-style': [
87+
// 'error',
88+
// {
89+
// multiline: {
90+
// delimiter: 'none', // 'none' or 'semi' or 'comma'
91+
// requireLast: true,
92+
// },
93+
// singleline: {
94+
// delimiter: 'semi', // 'semi' or 'comma'
95+
// requireLast: false,
96+
// },
97+
// },
98+
// ],
99+
// @TODO: Not recommended to disable rule, should instead disable locally
100+
// with explanation
101+
'@typescript-eslint/ban-ts-ignore': 'off',
102+
},
103+
},
104+
// Jest linting for test files
105+
{
106+
files: 'tests/*.ts',
88107
plugins: ['jest'],
89108
env: {
90109
// @TODO: Jasmine is not meant to be used in Jest tests,
@@ -93,7 +112,8 @@ module.exports = {
93112
jest: true,
94113
'jest/globals': true,
95114
},
96-
extends: ['plugin:jest/recommended'],
115+
// prettier must always be put last, so it overrides anything before it
116+
extends: ['plugin:jest/recommended', 'prettier'],
97117
// @TODO: Remove these rules and adapt code!
98118
rules: {
99119
'jest/no-disabled-tests': 'off',

.prettierignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
22
dist
3+
/tests/env
4+
/coverage
35
*.md
4-
tests/env
5-
coverage

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// eslint-disable-next-line tsdoc/syntax
21
/** @type {import('jest').Config} */
32
const config = {
43
rootDir: '.',

rollup.config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import nodeResolve from '@rollup/plugin-node-resolve'
2-
import { resolve } from 'path'
3-
import commonjs from '@rollup/plugin-commonjs'
4-
import json from '@rollup/plugin-json'
5-
import typescript from 'rollup-plugin-typescript2'
6-
import pkg from './package.json'
7-
import { terser } from 'rollup-plugin-terser'
8-
import { babel } from '@rollup/plugin-babel'
1+
const nodeResolve = require('@rollup/plugin-node-resolve')
2+
const { resolve } = require('path')
3+
const commonjs = require('@rollup/plugin-commonjs')
4+
const json = require('@rollup/plugin-json')
5+
const typescript = require('rollup-plugin-typescript2')
6+
const pkg = require('./package.json')
7+
const { terser } = require('rollup-plugin-terser')
8+
const { babel } = require('@rollup/plugin-babel')
99

1010
function getOutputFileName(fileName, isProd = false) {
1111
return isProd ? fileName.replace(/\.js$/, '.min.js') : fileName

0 commit comments

Comments
 (0)