- встроенные проверки: команда качества, lockfile, CI-конфиг по Effective Spec - subject: отпечаток дерева SHA-256 + git revision/dirty (git из PATH — узкое исключение sonarjs/no-os-command-from-path в eslint.config.mjs) - evidence с fingerprint байтов; FAIL доказателен (отсутствие — наблюдение) - отчёт проходит report validate; повторный аудит идентичен (тесты) - требования без проверки → UNKNOWN/semantic/low; пакет 41/41
93 lines
3.2 KiB
JavaScript
93 lines
3.2 KiB
JavaScript
import js from '@eslint/js';
|
|
import { defineConfig } from 'eslint/config';
|
|
import importX from 'eslint-plugin-import-x';
|
|
import sonarjs from 'eslint-plugin-sonarjs';
|
|
import globals from 'globals';
|
|
import tseslint from 'typescript-eslint';
|
|
|
|
// Adapted from ../../library/code-quality-practices/typescript/work-harness.md
|
|
// via experiments/pi-supervisor/eslint.config.mjs.
|
|
// Only this package, its tests and this config are in the adoption scope.
|
|
const files = ['src/**/*.ts', 'tests/**/*.{ts,mjs}', 'eslint.config.mjs'];
|
|
const typedFiles = ['src/**/*.ts', 'tests/**/*.ts'];
|
|
|
|
export default defineConfig(
|
|
{
|
|
files,
|
|
extends: [js.configs.recommended],
|
|
languageOptions: { globals: globals.node },
|
|
linterOptions: {
|
|
noInlineConfig: true,
|
|
reportUnusedDisableDirectives: 'error',
|
|
reportUnusedInlineConfigs: 'error',
|
|
},
|
|
rules: {
|
|
'array-callback-return': ['error', { checkForEach: true }],
|
|
eqeqeq: ['error', 'always'],
|
|
curly: ['error', 'all'],
|
|
'no-console': 'error',
|
|
'no-eval': 'error',
|
|
'no-implicit-coercion': 'error',
|
|
'no-promise-executor-return': 'error',
|
|
'no-return-assign': ['error', 'always'],
|
|
'no-unmodified-loop-condition': 'error',
|
|
'no-unreachable-loop': 'error',
|
|
'no-unsafe-optional-chaining': 'error',
|
|
'prefer-const': 'error',
|
|
'prefer-promise-reject-errors': 'error',
|
|
},
|
|
},
|
|
{
|
|
files: typedFiles,
|
|
extends: [
|
|
tseslint.configs.strictTypeChecked,
|
|
importX.flatConfigs.recommended,
|
|
importX.flatConfigs.typescript,
|
|
sonarjs.configs.recommended,
|
|
],
|
|
languageOptions: {
|
|
parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname },
|
|
},
|
|
settings: {
|
|
'import-x/resolver': { typescript: { project: './tsconfig.json' } },
|
|
},
|
|
rules: {
|
|
'@typescript-eslint/consistent-type-imports': [
|
|
'error',
|
|
{ fixStyle: 'separate-type-imports' },
|
|
],
|
|
'@typescript-eslint/consistent-type-exports': 'error',
|
|
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'never' }],
|
|
'@typescript-eslint/no-floating-promises': [
|
|
'error',
|
|
{ ignoreVoid: false, ignoreIIFE: false },
|
|
],
|
|
'@typescript-eslint/no-misused-promises': 'error',
|
|
'@typescript-eslint/strict-boolean-expressions': 'error',
|
|
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
'@typescript-eslint/no-shadow': 'error',
|
|
'@typescript-eslint/return-await': ['error', 'error-handling-correctness-only'],
|
|
'max-lines-per-function': [
|
|
'error',
|
|
{ max: 80, IIFEs: true, skipBlankLines: true, skipComments: true },
|
|
],
|
|
'sonarjs/cognitive-complexity': ['error', 10],
|
|
},
|
|
},
|
|
{
|
|
files: ['tests/**/*.ts'],
|
|
rules: {
|
|
// A scenario keeps setup, action and assertions together; production stays at 80.
|
|
'max-lines-per-function': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['src/audit.ts'],
|
|
rules: {
|
|
// git is optional audit metadata resolved from the operator PATH; absence yields
|
|
// no revision fields rather than a failure. Scoped to the audit engine only.
|
|
'sonarjs/no-os-command-from-path': 'off',
|
|
},
|
|
},
|
|
);
|