Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded comments from config files #1657

Merged
merged 2 commits into from
May 23, 2024
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
62 changes: 7 additions & 55 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,34 @@

module.exports = {
root: true,
env: {
// @TODO: Can be removed, ES versions are cumulative:
// https://stackoverflow.com/a/61688878
// es6: true,
// This seems to be what Node.js 18, 20 fully supports, but online documentation
// isn't exactly crystal clear about what should be put here
es2022: true,
browser: true,
node: true,
},
env: { es2022: true, browser: true, node: true },
// Standard linting for pure javascript files
parserOptions: {
// @TODO: Can be removed, as env ES version sets this too:
// https://eslint.org/docs/latest/use/configure/language-options#specifying-environments
// ecmaVersion: 2019,
// @TODO: Remove because in JS files we use commonjs
// sourceType: 'module',
},
// prettier must always be put last, so it overrides anything before it
extends: [
'eslint:recommended',
// Disables all style rules
// Disables all style rules (must always be put last, so it overrides anything before it)
// https://prettier.io/docs/en/integrating-with-linters.html
// https://github.com/prettier/eslint-config-prettier
'prettier',
],
rules: {
// @TODO: Remove this rule, as it's a style rule covered by prettier and
// it's deprecated https://eslint.org/docs/latest/rules/comma-dangle
// 'comma-dangle': 'off',
},
overrides: [
// TypeScript linting for TypeScript files
{
files: '*.ts',
plugins: [
'@typescript-eslint',
// TSDoc is only meant for TS files https://tsdoc.org/
// https://tsdoc.org/
'eslint-plugin-tsdoc',
],
parser: '@typescript-eslint/parser',
parserOptions: { project: 'tsconfig.eslint.json' },
// prettier must always be put last, so it overrides anything before it
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'prettier',
],
rules: {
// @TODO: Remove as it doesn't seem to cause issues anymore with fn overloads
// 'no-dupe-class-members': 'off', // Off due to conflict with typescript overload functions
'tsdoc/syntax': 'error',
// new TS rules begin @TODO: Remove these and adapt code
// @TODO: Remove the ones between "~~", adapt code
// ~~
'@typescript-eslint/prefer-as-const': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
Expand All @@ -62,40 +38,17 @@ module.exports = {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-floating-promises': 'off',
// new TS rules end
// ~~
'@typescript-eslint/array-type': ['warn', { default: 'array-simple' }],
// @TODO: Remove, as it's already off
// '@typescript-eslint/return-await': 'off',
// @TODO: Remove this rule, deprecated:
// https://typescript-eslint.io/rules/space-before-function-paren/
// '@typescript-eslint/space-before-function-paren': 0,
// @TODO: Should be careful with this rule, should leave it be and disable
// it within files where necessary with explanations
'@typescript-eslint/no-explicit-any': 'off',
// @TODO: Remove, as it's already off
// '@typescript-eslint/explicit-function-return-type': 'off',
// @TODO: Remove, as it's already off
// '@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
// argsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
// varsIgnorePattern: https://eslint.org/docs/latest/rules/no-unused-vars#varsignorepattern
{ args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
// @TODO: Remove this rule, as it's a style rule covered by prettier
// '@typescript-eslint/member-delimiter-style': [
// 'error',
// {
// multiline: {
// delimiter: 'none', // 'none' or 'semi' or 'comma'
// requireLast: true,
// },
// singleline: {
// delimiter: 'semi', // 'semi' or 'comma'
// requireLast: false,
// },
// },
// ],
// @TODO: Not recommended to disable rule, should instead disable locally
// with explanation
'@typescript-eslint/ban-ts-ignore': 'off',
Expand All @@ -112,9 +65,8 @@ module.exports = {
jest: true,
'jest/globals': true,
},
// prettier must always be put last, so it overrides anything before it
extends: ['plugin:jest/recommended', 'prettier'],
// @TODO: Remove these rules and adapt code!
// @TODO: Remove all of these rules and adapt code!
rules: {
'jest/no-disabled-tests': 'off',
'jest/expect-expect': 'off',
Expand Down
6 changes: 0 additions & 6 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

module.exports = {
singleQuote: true,
// @TODO Remove as it's default
// arrowParens: 'always',
semi: false,
// @TODO Remove as it's default
// bracketSpacing: true,
trailingComma: 'es5',
// @TODO Remove as it's default
// printWidth: 80,
plugins: ['./node_modules/prettier-plugin-jsdoc/dist/index.js'],
// https://github.com/hosseinmd/prettier-plugin-jsdoc#tsdoc
tsdoc: true,
Expand Down
5 changes: 0 additions & 5 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
// extend your base config so you don't have to redefine your compilerOptions
"extends": "./tsconfig.json",
// @TODO: Can be removed, all of these are already in the extended tsconfig.json
// "compilerOptions": {
// "allowJs": false,
// "module": "esnext"
// },
"include": [
"src/**/*.ts",
"tests/**/*.ts",
Expand Down
39 changes: 2 additions & 37 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"compilerOptions": {
// @TODO: Remove these, as we're not using decorators
// "experimentalDecorators": true,
// "emitDecoratorMetadata": true,
// @TODO: Remove, as it defaults to true: https://www.typescriptlang.org/tsconfig#forceConsistentCasingInFileNames
// "forceConsistentCasingInFileNames": true,
// @TODO: Remove, as it's false by default: https://www.typescriptlang.org/tsconfig#removeComments
// "removeComments": false,
// @TODO: This is false by default, can be removed
// "allowJs": false,
// @TODO: perhaps "emitDeclarationOnly" should be used here (build fails with it), need to
// investigate further https://www.typescriptlang.org/tsconfig#emitDeclarationOnly
// probably need to update rollup and its config
Expand All @@ -21,42 +12,16 @@
// https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler
// However "module": "node16" or "nodenext" is a better option:
// https://www.typescriptlang.org/docs/handbook/modules/theory.html#module-resolution-for-libraries
// Problem is, a lot of files would need changes, so to keep things simpler for now let's keep it as "bundler"
// Also this should be applied too: https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax
// but again, too many changes for now
"moduleResolution": "bundler",
// "moduleResolution" = "bundler" requires this to be "esnext"
"module": "esnext",
// @TODO: Remove as it's not all that useful these days, and just generates more unnecessary code
// just so we can `import crypto from "crypto"` instead of `import * as crypto from "crypto"`
// or even better `import { createHmac } from "crypto"`
// "esModuleInterop": true,
// @TODO: Remove, as "moduleResolution": "bundler" sets this to true
// "allowSyntheticDefaultImports": true,
// Node.js 18 supports up to ES2022 according to https://www.npmjs.com/package/@tsconfig/node18
// This matters for the generated CJS and ESM file, UMD file is down-leveled further to support IE11
// with the help of Babel.
// (only the syntax, URL, URLSearchParams, fetch is not IE11 compatible) with the help of Babel.
"target": "es2022",
"lib": [
// @TODO: Remove as ES versions are cumulative, so ESNext contains everything
//"ES2019",
"ESNext",
"dom"
],
"lib": ["ESNext", "dom"],
"strict": true,
// @TODO: Remove these, as they are covered by "strict":
// https://www.typescriptlang.org/tsconfig#strict
// "alwaysStrict": true,
// "strictNullChecks": true,
// "strictFunctionTypes": true,
// "strictPropertyInitialization": true,
// "strictBindCallApply": true,
// "noImplicitAny": true,
// "noImplicitThis": true,
"noImplicitReturns": true
// @TODO: These are already covered by ESLint, furthermore these disallow
// underscore vars (_myVar) too, so they nullify the ESLint custom rule
// "noUnusedLocals": true,
// "noUnusedParameters": true
}
}