UNPKG

eslint-config-cityssm

Version:

ESLint rules used in the City of Sault Ste. Marie's TypeScript projects.

262 lines (261 loc) 9.19 kB
import eslintJs from '@eslint/js'; import eslintJson from '@eslint/json'; import eslintMarkdown from '@eslint/markdown'; import eslintConfigLove from 'eslint-config-love'; import eslintPluginNodeTest from 'eslint-node-test'; import eslintPluginJsdoc from 'eslint-plugin-jsdoc'; import eslintPluginNodeDependencies from 'eslint-plugin-node-dependencies'; import eslintPluginNodeSecurity from 'eslint-plugin-node-security'; import eslintPluginPackageJson from 'eslint-plugin-package-json'; import eslintPluginPerfectionist from 'eslint-plugin-perfectionist'; import eslintPluginRegexp from 'eslint-plugin-regexp'; import eslintPluginRuntimeCleanup from 'eslint-plugin-runtime-cleanup'; import eslintPluginSecureCoding from 'eslint-plugin-secure-coding'; import eslintPluginSonarJs from 'eslint-plugin-sonarjs'; import eslintPluginSqliteSecurity from 'eslint-plugin-sqlite-security'; import eslintPluginUnicorn from 'eslint-plugin-unicorn'; import eslintPluginWriteGoodComments from 'eslint-plugin-write-good-comments-2'; import { defineConfig } from 'eslint/config'; import tseslint from 'typescript-eslint'; import noMagicNumbers from './lists/noMagicNumbers.ignore.js'; import writeGoodCommentsAllowlist from './lists/writeGoodComments.allowlist.js'; /** * ESLint Configuration for General TypeScript/JavaScript Projects */ export const config = defineConfig({ linterOptions: { reportUnusedDisableDirectives: 'error', reportUnusedInlineConfigs: 'error' } }, { files: ['**/*.ts'], ignores: ['**/*.d.ts'], extends: [ tseslint.configs.recommendedTypeChecked, tseslint.configs.stylisticTypeChecked, eslintJs.configs.recommended, eslintPluginJsdoc.configs['flat/recommended-typescript'], eslintPluginNodeSecurity.configs.recommended, eslintPluginNodeTest.configs.recommended, eslintPluginPerfectionist.configs['recommended-natural'], eslintPluginRegexp.configs['flat/recommended'], eslintPluginRuntimeCleanup.configs['recommended-type-checked'], eslintPluginSecureCoding.configs.recommended, eslintPluginSonarJs.configs.recommended, eslintPluginSqliteSecurity.configs.recommended, eslintPluginUnicorn.configs.recommended, // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion eslintConfigLove ], languageOptions: { parserOptions: { ecmaFeatures: { modules: true }, ecmaVersion: 2022, sourceType: 'module', projectService: true, tsconfigRootDir: import.meta.dirname } }, plugins: { 'write-good-comments': eslintPluginWriteGoodComments }, rules: { '@typescript-eslint/init-declarations': 'warn', '@typescript-eslint/no-magic-numbers': [ 'warn', { ignore: noMagicNumbers } ], '@typescript-eslint/no-misused-promises': 'warn', '@typescript-eslint/no-non-null-assertion': 'warn', '@typescript-eslint/no-unnecessary-type-assertion': 'off', '@typescript-eslint/no-unsafe-argument': 'warn', '@typescript-eslint/no-unsafe-assignment': 'warn', '@typescript-eslint/no-unsafe-call': 'warn', '@typescript-eslint/no-unsafe-member-access': 'warn', '@typescript-eslint/no-unsafe-type-assertion': 'warn', '@typescript-eslint/non-nullable-type-assertion-style': 'off', '@typescript-eslint/prefer-destructuring': 'off', '@typescript-eslint/prefer-optional-chain': 'warn', '@typescript-eslint/restrict-plus-operands': 'warn', '@typescript-eslint/space-before-function-paren': 'off', '@typescript-eslint/strict-boolean-expressions': 'warn', complexity: [ 'warn', { max: 20 } ], '@eslint-community/eslint-comments/require-description': 'off', 'jsdoc/require-asterisk-prefix': ['error', 'always'], 'jsdoc/require-hyphen-before-param-description': 'error', 'jsdoc/require-jsdoc': ['warn', { publicOnly: true }], 'n/no-missing-import': 'off', 'no-await-in-loop': 'warn', 'no-extra-semi': 'off', 'no-param-reassign': ['error', { props: false }], 'no-redeclare': 'off', 'no-undef': 'off', // checked by "@typescript-eslint/no-unused-vars" 'no-unused-vars': 'off', 'perfectionist/sort-imports': [ 'error', { groups: [ 'builtin', ['external', 'internal'], 'parent', 'sibling', 'unknown' ], newlinesBetween: 1 } ], 'perfectionist/sort-interfaces': [ 'warn', { partitionByNewLine: true } ], 'perfectionist/sort-modules': [ 'warn', { partitionByNewLine: true } ], 'perfectionist/sort-named-exports': [ 'error', { groups: ['type-export', 'unknown'] } ], 'perfectionist/sort-named-imports': [ 'error', { groups: ['type-import', 'unknown'] } ], 'perfectionist/sort-object-types': [ 'warn', { partitionByNewLine: true } ], 'perfectionist/sort-objects': [ 'warn', { partitionByNewLine: true } ], 'perfectionist/sort-union-types': [ 'error', { groups: ['unknown', 'nullish'] } ], // checked by "no-useless-escape" 'regexp/no-useless-escape': 'off', 'require-unicode-regexp': 'warn', // lots of false positives 'secure-coding/no-improper-sanitization': 'off', // checked by "complexity" 'sonarjs/cognitive-complexity': 'off', 'sonarjs/different-types-comparison': 'off', // checked by "regexp/no-dupe-characters-character-class" 'sonarjs/duplicates-in-character-class': 'off', // checked by "no-control-regex" 'sonarjs/no-control-regex': 'off', 'sonarjs/no-duplicate-string': 'warn', // checked by "secure-coding/no-hardcoded-passwords" 'sonarjs/no-hardcoded-passwords': 'off', // checked by "@typescript-eslint/no-misused-promises" 'sonarjs/no-misused-promises': 'off', // checked by "max-nested-callbacks" 'sonarjs/no-nested-functions': 'off', 'sonarjs/no-nested-template-literals': 'warn', // checked by "@typescript-eslint/no-redundant-type-constituents" 'sonarjs/no-redundant-type-constituents': 'off', 'sonarjs/unnecessary-character-escapes': 'off', // checked by "node-test/consistent-assert-style" 'unicorn/consistent-assert': 'off', 'unicorn/consistent-function-scoping': 'warn', 'unicorn/empty-brace-spaces': 'off', 'unicorn/filename-case': [ 'error', { case: 'camelCase', ignore: ['DB', 'URL'] } ], 'unicorn/name-replacements': [ 'error', { replacements: { def: { definition: true }, ele: { element: true }, eles: { elements: true }, fns: { functions: true }, res: { result: false }, temp: { temporary: false } } } ], 'write-good-comments/write-good-comments': [ 'warn', { passive: false, whitelist: writeGoodCommentsAllowlist } ] } }, { files: ['**/*.json'], ignores: ['**/package.json', '**/package-lock.json'], extends: [eslintJson.configs.recommended], language: 'json/json', plugins: { json: eslintJson } }, { files: ['**/package.json'], extends: [ eslintPluginPackageJson.configs.recommended, eslintPluginNodeDependencies.configs.recommended ], rules: { 'package-json/exports-subpaths-style': [ 'error', { prefer: 'explicit' } ], 'package-json/order-properties': [ 'error', { order: 'sort-package-json' } ] } }, { files: ['**/*.md'], extends: [eslintMarkdown.configs.recommended], language: 'markdown/gfm', plugins: { markdown: eslintMarkdown } }); export default config; export { defineConfig } from 'eslint/config';