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

infra: upgrade eslint #973

Merged
merged 1 commit into from
Feb 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

103 changes: 103 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// @ts-check
const { defineConfig } = require('eslint-define-config');
const { readGitignoreFiles } = require('eslint-gitignore');

/// <reference types="@eslint-types/prettier" />
/// <reference types="@eslint-types/typescript-eslint" />

module.exports = defineConfig({
ignorePatterns: [
...readGitignoreFiles(),
'templates',
'.eslintrc.cjs', // Skip self linting
],
root: true,
env: {
node: true,
},
reportUnusedDisableDirectives: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/strict-type-checked',
'plugin:prettier/recommended',
],
parserOptions: {
project: ['./tsconfig.lint.json'],
warnOnUnsupportedTypeScriptVersion: false,
},
rules: {
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-else-return': 'error',
'prefer-exponentiation-operator': 'error',
'prefer-template': 'error',

'@typescript-eslint/array-type': [
'error',
{ default: 'array-simple', readonly: 'generic' },
],
// TODO @Shinigami92 2024-02-29: Enable consistent-type-imports later
// '@typescript-eslint/consistent-type-imports': 'error',
// TODO @Shinigami92 2024-02-29: Enable consistent-type-imports later
// '@typescript-eslint/explicit-module-boundary-types': 'error',
// TODO @Shinigami92 2024-02-29: Enable consistent-type-imports later
// '@typescript-eslint/naming-convention': [
// 'error',
// {
// format: ['PascalCase'],
// selector: ['class', 'interface', 'typeAlias', 'enumMember'],
// leadingUnderscore: 'forbid',
// trailingUnderscore: 'forbid',
// },
// {
// format: ['PascalCase'],
// selector: ['typeParameter'],
// prefix: ['T'],
// leadingUnderscore: 'forbid',
// trailingUnderscore: 'forbid',
// },
// ],
'@typescript-eslint/no-inferrable-types': [
'error',
{ ignoreParameters: true },
],
'@typescript-eslint/no-unnecessary-condition': 'off', // requires `strictNullChecks` to be enabled
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: 'block-like', next: '*' },
],
'@typescript-eslint/prefer-regexp-exec': 'error',
// TODO @Shinigami92 2024-02-29: Enable consistent-type-imports later
// '@typescript-eslint/restrict-template-expressions': [
// 'error',
// { allowNumber: true, allowBoolean: true },
// ],
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ requireDefaultForNonUnion: true },
],
'@typescript-eslint/unbound-method': 'off',

// TODO @Shinigami92 2024-02-29: Remove these later
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-includes': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unified-signatures': 'off',
},
});
39 changes: 0 additions & 39 deletions .eslintrc.js

This file was deleted.

99 changes: 95 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,98 @@
.idea
.env
# Logs
logs
*.log
/migrations
/node_modules
npm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
reports/

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Dependency directories
node_modules/
.pnpm-store/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Docusaurus cache and generated files
.docusaurus

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# Transpiled JS script files for GitHub Actions
.github/workflows/*.js

# IDE
/.idea
/nbproject

# Meteor build and version
.build*
versions.json

# Dist
/dist
/docs/.vitepress/cache
/docs/.vitepress/dist
/lib

/migrations

TAGS
REVISION
*.tmproj
*~
.DS_Store
.settings
.project
.tasks-cache
*DONOTVERSION*
.history

# Unwanted package managers
.yarn/
package-lock.json
yarn.lock
5 changes: 0 additions & 5 deletions bin/node-pg-migrate
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
/* eslint-disable strict, no-console */

'use strict';

Expand All @@ -17,7 +16,6 @@ process.on('uncaughtException', (err) => {

function tryRequire(moduleName) {
try {
// eslint-disable-next-line import/no-dynamic-require,global-require,security/detect-non-literal-require
return require(moduleName);
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
Expand Down Expand Up @@ -260,7 +258,6 @@ function readTsconfig() {
const json5 = tryRequire('json5');

try {
// eslint-disable-next-line security/detect-non-literal-fs-filename
const config = fs.readFileSync(
path.resolve(process.cwd(), tsconfigPath),
{ encoding: 'utf-8' }
Expand Down Expand Up @@ -368,7 +365,6 @@ process.env.SUPPRESS_NO_CONFIG_WARNING = oldSuppressWarning;

const configFileName = argv[configFileArg];
if (configFileName) {
// eslint-disable-next-line global-require,import/no-dynamic-require,security/detect-non-literal-require
const jsonConfig = require(path.resolve(configFileName));
readJson(jsonConfig);
}
Expand Down Expand Up @@ -449,7 +445,6 @@ if (action === 'create') {
let migrationName;

if (updownArg !== null) {
// eslint-disable-next-line eqeqeq
if (parseInt(updownArg, 10) == updownArg) {
numMigrations = parseInt(updownArg, 10);
} else {
Expand Down
2 changes: 0 additions & 2 deletions mocha.bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
const chai = require('chai');
const sinonChai = require('sinon-chai');
const chaiAsPromised = require('chai-as-promised');
Expand All @@ -8,7 +7,6 @@ const config = require('./tsconfig-test.json');
config.compilerOptions.module = 'commonjs';
config.transpileOnly = true;

// eslint-disable-next-line import/no-extraneous-dependencies
require('ts-node').register(config);

chai.use(sinonChai);
Expand Down
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"build:types": "tsc --declaration --emitDeclarationOnly",
"build": "run-s build:clean build:code build:types",
"format": "prettier --cache --write .",
"lint": "eslint . bin/* --ext .js,.ts",
"lint:fix": "npm run lint -- --fix && prettier --write *.json *.md docs/*.md",
"lint": "eslint --cache --cache-strategy content --report-unused-disable-directives .",
"test": "cross-env NODE_ENV=test mocha --require ./mocha.bootstrap.js \"test/*.ts\"",
"docs:dev": "docsify serve docs",
"migrate": "node bin/node-pg-migrate",
Expand Down Expand Up @@ -64,6 +63,8 @@
"yargs": "~17.3.0"
},
"devDependencies": {
"@eslint-types/prettier": "5.1.3",
"@eslint-types/typescript-eslint": "7.0.2",
"@types/chai": "4.3.0",
"@types/chai-as-promised": "7.1.4",
"@types/mkdirp": "1.0.2",
Expand All @@ -72,22 +73,20 @@
"@types/proxyquire": "1.3.28",
"@types/sinon": "10.0.6",
"@types/sinon-chai": "3.2.6",
"@typescript-eslint/eslint-plugin": "5.7.0",
"@typescript-eslint/parser": "5.7.0",
"@typescript-eslint/eslint-plugin": "7.1.0",
"@typescript-eslint/parser": "7.1.0",
"chai": "4.3.4",
"chai-as-promised": "7.1.1",
"config": "3.3.6",
"cross-env": "7.0.3",
"docsify-cli": "4.4.3",
"dotenv": "16.0.1",
"dotenv-expand": "8.0.3",
"eslint": "8.4.1",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-import": "2.25.3",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-define-config": "2.1.0",
"eslint-gitignore": "0.1.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-security": "1.4.0",
"json5": "2.2.0",
"mocha": "9.1.3",
"npm-run-all2": "6.1.2",
Expand Down