// Copyright 2017-2026 @pezkuwi/dev authors & contributors // SPDX-License-Identifier: Apache-2.0 import JSON5 from 'json5'; import fs from 'node:fs'; import path from 'node:path'; import process from 'node:process'; const FIXME = { // This is in the new 6.0.0 and we should switch this on // at some point. For a first iteration we keep as-is '@typescript-eslint/prefer-nullish-coalescing': 'off' }; /** * Returns a copyright header pattern (using tsconfig.base.json) * * @returns {string} */ function getHeaderPattern () { const tsPath = path.join(process.cwd(), 'tsconfig.base.json'); if (!fs.existsSync(tsPath)) { throw new Error(`Unable to load ${tsPath}`); } const tsConfig = JSON5.parse(fs.readFileSync(tsPath, 'utf-8')); if (!tsConfig?.compilerOptions?.paths) { throw new Error(`Unable to extract compilerOptions.paths structure from ${tsPath}`); } const paths = Object.keys(tsConfig.compilerOptions.paths); if (!paths.length) { throw new Error(`No keys found in compilerOptions.paths from ${tsPath}`); } const packages = paths.reduce((packages, k) => { const [pd, pk] = k.split('/'); if (pd !== '@pezkuwi' || !pk) { throw new Error(`Non @pezkuwi path in ${tsPath}`); } return packages.length ? `${packages}|${pk}` : pk; }, ''); const fullyear = new Date().getFullYear(); const years = []; for (let i = 17, last = fullyear - 2000; i < last; i++) { years.push(`${i}`); } return ` Copyright 20(${years.join('|')})(-${fullyear})? @pezkuwi/(${packages})( authors & contributors)?`; } export const overrideAll = { ...FIXME, '@stylistic/arrow-parens': ['error', 'always'], '@stylistic/brace-style': ['error', '1tbs'], '@stylistic/function-call-argument-newline': ['error', 'consistent'], '@stylistic/indent': ['error', 2], '@stylistic/no-extra-semi': 'error', '@stylistic/object-curly-newline': ['error', { ExportDeclaration: { minProperties: 2048 }, ImportDeclaration: { minProperties: 2048 }, ObjectPattern: { minProperties: 2048 } }], '@stylistic/padding-line-between-statements': [ 'error', { blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] }, { blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] }, { blankLine: 'always', next: 'block-like', prev: '*' }, { blankLine: 'always', next: '*', prev: 'block-like' }, { blankLine: 'always', next: 'function', prev: '*' }, { blankLine: 'always', next: '*', prev: 'function' }, { blankLine: 'always', next: 'try', prev: '*' }, { blankLine: 'always', next: '*', prev: 'try' }, { blankLine: 'always', next: 'return', prev: '*' }, { blankLine: 'always', next: 'import', prev: '*' }, { blankLine: 'always', next: '*', prev: 'import' }, { blankLine: 'any', next: 'import', prev: 'import' } ], '@stylistic/semi': ['error', 'always'], '@stylistic/spaced-comment': ['error', 'always', { block: { // pure export helpers markers: ['#__PURE__'] }, line: { // TS reference types markers: ['/