From c06e9d7e9715e22312e98b19ab2324523fff0b3d Mon Sep 17 00:00:00 2001 From: what1s1ove Date: Mon, 20 Nov 2023 20:38:35 +0200 Subject: [PATCH 1/4] chore: replace prettier yml config with js wd-157 --- .eslintrc.yml | 1 + .prettierrc.yml | 13 ------------- prettier.config.js | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 13 deletions(-) delete mode 100644 .prettierrc.yml create mode 100644 prettier.config.js diff --git a/.eslintrc.yml b/.eslintrc.yml index d57eb233..ebcffd15 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -134,6 +134,7 @@ rules: overrides: - files: - commitlint.config.js + - prettier.config.js rules: import/no-default-export: - off diff --git a/.prettierrc.yml b/.prettierrc.yml deleted file mode 100644 index f4611490..00000000 --- a/.prettierrc.yml +++ /dev/null @@ -1,13 +0,0 @@ -plugins: - - 'prettier-plugin-jsdoc' -printWidth: 80 -semi: false -singleQuote: true -quoteProps: preserve -trailingComma: all -bracketSpacing: true -arrowParens: always -overrides: - - files: '*.css' - options: - singleQuote: false diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 00000000..b1787742 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,21 @@ +/** @type {import('prettier').Config} */ +let config = { + arrowParens: `always`, + bracketSpacing: true, + overrides: [ + { + files: `*.css`, + options: { + singleQuote: false, + }, + }, + ], + plugins: [`prettier-plugin-jsdoc`], + printWidth: 80, + quoteProps: `preserve`, + semi: false, + singleQuote: true, + trailingComma: `all`, +} + +export default config From 1b8387db882d1762f47bffbe0583860db69a940f Mon Sep 17 00:00:00 2001 From: what1s1ove Date: Mon, 20 Nov 2023 20:55:34 +0200 Subject: [PATCH 2/4] chore: replace stylelint yml config with cjs wd-157 --- .eslintrc.yml | 1 + .stylelintrc.yml | 265 ------------------------------------------ stylelint.config.cjs | 268 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 269 insertions(+), 265 deletions(-) delete mode 100644 .stylelintrc.yml create mode 100644 stylelint.config.cjs diff --git a/.eslintrc.yml b/.eslintrc.yml index ebcffd15..187159f9 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -140,6 +140,7 @@ overrides: - off - files: - eleventy.config.cjs + - stylelint.config.cjs env: node: true rules: diff --git a/.stylelintrc.yml b/.stylelintrc.yml deleted file mode 100644 index a57c0dfa..00000000 --- a/.stylelintrc.yml +++ /dev/null @@ -1,265 +0,0 @@ -plugins: - - stylelint-order -extends: - - stylelint-config-standard -rules: - selector-class-pattern: null - custom-property-pattern: null - color-hex-length: long - order/order: - - custom-properties - - declarations - order/properties-order: - - all - - position - - top - - right - - bottom - - left - - inset - - inset-block-start - - inset-block-end - - inset-inline-start - - inset-inline-end - - z-index - - display - - grid-template - - grid-template-rows - - grid-template-columns - - grid-template-areas - - grid-auto-rows - - grid-auto-columns - - grid-auto-flow - - grid-area - - grid-row - - grid-column - - grid-row-start - - grid-row-end - - grid-column-start - - grid-column-end - - flex - - flex-grow - - flex-shrink - - flex-basis - - flex-flow - - flex-direction - - flex-wrap - - order - - justify-content - - justify-items - - justify-self - - align-content - - align-items - - align-self - - grid-gap - - gap - - grid-row-gap - - row-gap - - grid-column-gap - - column-gap - - float - - clear - - box-sizing - - writing-mode - - width - - min-width - - max-width - - height - - min-height - - max-height - - inline-size - - min-inline-size - - max-inline-size - - block-size - - min-block-size - - max-block-size - - margin - - margin-top - - margin-right - - margin-bottom - - margin-left - - margin-block-start - - margin-block-end - - margin-inline-start - - margin-inline-end - - padding - - padding-top - - padding-right - - padding-bottom - - padding-left - - padding-block-start - - padding-block-end - - padding-inline-start - - padding-inline-end - - overflow - - overflow-x - - overflow-y - - color - - font - - font-weight - - font-size - - font-family - - font-style - - font-display - - font-variant - - font-size-adjust - - font-stretch - - font-effect - - font-emphasize - - font-emphasize-position - - font-emphasize-style - - font-smooth - - line-height - - direction - - letter-spacing - - white-space - - text-align - - text-align-last - - text-transform - - text-decoration - - text-emphasis - - text-emphasis-color - - text-emphasis-style - - text-emphasis-position - - text-indent - - text-justify - - text-outline - - text-wrap - - text-overflow - - text-overflow-ellipsis - - text-overflow-mode - - text-orientation - - text-shadow - - vertical-align - - word-wrap - - word-break - - word-spacing - - overflow-wrap - - tab-size - - hyphens - - unicode-bidi - - columns - - column-count - - column-fill - - column-gap - - column-rule - - column-rule-color - - column-rule-style - - column-rule-width - - column-span - - column-width - - page-break-after - - page-break-before - - page-break-inside - - src - - list-style - - list-style-position - - list-style-type - - list-style-image - - table-layout - - empty-cells - - caption-side - - background - - background-color - - background-image - - background-repeat - - background-position - - background-position-x - - background-position-y - - background-size - - background-clip - - background-origin - - background-attachment - - background-blend-mode - - box-decoration-break - - border - - border-width - - border-style - - border-color - - border-top - - border-block-start - - border-top-width - - border-top-style - - border-top-color - - border-right - - border-inline-end - - border-right-width - - border-right-style - - border-right-color - - border-bottom - - border-block-end - - border-bottom-width - - border-bottom-style - - border-bottom-color - - border-left - - border-inline-start - - border-left-width - - border-left-style - - border-left-color - - border-radius - - border-top-left-radius - - border-top-right-radius - - border-bottom-right-radius - - border-bottom-left-radius - - border-image - - border-image-source - - border-image-slice - - border-image-width - - border-image-outset - - border-image-repeat - - border-collapse - - border-spacing - - outline - - outline-width - - outline-style - - outline-color - - outline-offset - - box-shadow - - visibility - - cursor - - mix-blend-mode - - backdrop-filter - - will-change - - transform - - transform-origin - - transform-style - - backface-visibility - - opacity - - filter - - perspective - - perspective-origin - - transition - - transition-delay - - transition-timing-function - - transition-duration - - transition-property - - animation - - animation-name - - animation-duration - - animation-play-state - - animation-timing-function - - animation-delay - - animation-iteration-count - - animation-direction - - animation-fill-mode - - appearance - - clip - - clip-path - - counter-reset - - counter-increment - - resize - - user-select - - nav-index - - nav-up - - nav-right - - nav-down - - nav-left - - pointer-events - - quotes - - touch-action - - zoom - - fill - - fill-rule - - clip-rule - - stroke - - stroke-width diff --git a/stylelint.config.cjs b/stylelint.config.cjs new file mode 100644 index 00000000..90c1c747 --- /dev/null +++ b/stylelint.config.cjs @@ -0,0 +1,268 @@ +/** @type {import('stylelint').Config} */ +let config = { + extends: [`stylelint-config-standard`], + plugins: [`stylelint-order`], + rules: { + 'color-hex-length': `long`, + 'custom-property-pattern': undefined, + 'order/order': [`custom-properties`, `declarations`], + 'order/properties-order': [ + `all`, + `position`, + `top`, + `right`, + `bottom`, + `left`, + `inset`, + `inset-block-start`, + `inset-block-end`, + `inset-inline-start`, + `inset-inline-end`, + `z-index`, + `display`, + `grid-template`, + `grid-template-rows`, + `grid-template-columns`, + `grid-template-areas`, + `grid-auto-rows`, + `grid-auto-columns`, + `grid-auto-flow`, + `grid-area`, + `grid-row`, + `grid-column`, + `grid-row-start`, + `grid-row-end`, + `grid-column-start`, + `grid-column-end`, + `flex`, + `flex-grow`, + `flex-shrink`, + `flex-basis`, + `flex-flow`, + `flex-direction`, + `flex-wrap`, + `order`, + `justify-content`, + `justify-items`, + `justify-self`, + `align-content`, + `align-items`, + `align-self`, + `grid-gap`, + `gap`, + `grid-row-gap`, + `row-gap`, + `grid-column-gap`, + `column-gap`, + `float`, + `clear`, + `box-sizing`, + `writing-mode`, + `width`, + `min-width`, + `max-width`, + `height`, + `min-height`, + `max-height`, + `inline-size`, + `min-inline-size`, + `max-inline-size`, + `block-size`, + `min-block-size`, + `max-block-size`, + `margin`, + `margin-top`, + `margin-right`, + `margin-bottom`, + `margin-left`, + `margin-block-start`, + `margin-block-end`, + `margin-inline-start`, + `margin-inline-end`, + `padding`, + `padding-top`, + `padding-right`, + `padding-bottom`, + `padding-left`, + `padding-block-start`, + `padding-block-end`, + `padding-inline-start`, + `padding-inline-end`, + `overflow`, + `overflow-x`, + `overflow-y`, + `color`, + `font`, + `font-weight`, + `font-size`, + `font-family`, + `font-style`, + `font-display`, + `font-variant`, + `font-size-adjust`, + `font-stretch`, + `font-effect`, + `font-emphasize`, + `font-emphasize-position`, + `font-emphasize-style`, + `font-smooth`, + `line-height`, + `direction`, + `letter-spacing`, + `white-space`, + `text-align`, + `text-align-last`, + `text-transform`, + `text-decoration`, + `text-emphasis`, + `text-emphasis-color`, + `text-emphasis-style`, + `text-emphasis-position`, + `text-indent`, + `text-justify`, + `text-outline`, + `text-wrap`, + `text-overflow`, + `text-overflow-ellipsis`, + `text-overflow-mode`, + `text-orientation`, + `text-shadow`, + `vertical-align`, + `word-wrap`, + `word-break`, + `word-spacing`, + `overflow-wrap`, + `tab-size`, + `hyphens`, + `unicode-bidi`, + `columns`, + `column-count`, + `column-fill`, + `column-gap`, + `column-rule`, + `column-rule-color`, + `column-rule-style`, + `column-rule-width`, + `column-span`, + `column-width`, + `page-break-after`, + `page-break-before`, + `page-break-inside`, + `src`, + `list-style`, + `list-style-position`, + `list-style-type`, + `list-style-image`, + `table-layout`, + `empty-cells`, + `caption-side`, + `background`, + `background-color`, + `background-image`, + `background-repeat`, + `background-position`, + `background-position-x`, + `background-position-y`, + `background-size`, + `background-clip`, + `background-origin`, + `background-attachment`, + `background-blend-mode`, + `box-decoration-break`, + `border`, + `border-width`, + `border-style`, + `border-color`, + `border-top`, + `border-block-start`, + `border-top-width`, + `border-top-style`, + `border-top-color`, + `border-right`, + `border-inline-end`, + `border-right-width`, + `border-right-style`, + `border-right-color`, + `border-bottom`, + `border-block-end`, + `border-bottom-width`, + `border-bottom-style`, + `border-bottom-color`, + `border-left`, + `border-inline-start`, + `border-left-width`, + `border-left-style`, + `border-left-color`, + `border-radius`, + `border-top-left-radius`, + `border-top-right-radius`, + `border-bottom-right-radius`, + `border-bottom-left-radius`, + `border-image`, + `border-image-source`, + `border-image-slice`, + `border-image-width`, + `border-image-outset`, + `border-image-repeat`, + `border-collapse`, + `border-spacing`, + `outline`, + `outline-width`, + `outline-style`, + `outline-color`, + `outline-offset`, + `box-shadow`, + `visibility`, + `cursor`, + `mix-blend-mode`, + `backdrop-filter`, + `will-change`, + `transform`, + `transform-origin`, + `transform-style`, + `backface-visibility`, + `opacity`, + `filter`, + `perspective`, + `perspective-origin`, + `transition`, + `transition-delay`, + `transition-timing-function`, + `transition-duration`, + `transition-property`, + `animation`, + `animation-name`, + `animation-duration`, + `animation-play-state`, + `animation-timing-function`, + `animation-delay`, + `animation-iteration-count`, + `animation-direction`, + `animation-fill-mode`, + `appearance`, + `clip`, + `clip-path`, + `counter-reset`, + `counter-increment`, + `resize`, + `user-select`, + `nav-index`, + `nav-up`, + `nav-right`, + `nav-down`, + `nav-left`, + `pointer-events`, + `quotes`, + `touch-action`, + `zoom`, + `fill`, + `fill-rule`, + `clip-rule`, + `stroke`, + `stroke-width`, + ], + 'selector-class-pattern': undefined, + }, +} + +module.exports = config From a3fa2d46036d8b76b727fbb99a99d6ea8ad4eb1b Mon Sep 17 00:00:00 2001 From: what1s1ove Date: Mon, 20 Nov 2023 21:04:39 +0200 Subject: [PATCH 3/4] chore: replace lint-staged yml config with js wd-157 --- .eslintrc.yml | 1 + .lintstagedrc.yml | 4 ---- lint-staged.config.js | 9 +++++++++ package-lock.json | 7 +++++++ package.json | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) delete mode 100644 .lintstagedrc.yml create mode 100644 lint-staged.config.js diff --git a/.eslintrc.yml b/.eslintrc.yml index 187159f9..6e730b48 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -135,6 +135,7 @@ overrides: - files: - commitlint.config.js - prettier.config.js + - lint-staged.config.js rules: import/no-default-export: - off diff --git a/.lintstagedrc.yml b/.lintstagedrc.yml deleted file mode 100644 index b88b5c91..00000000 --- a/.lintstagedrc.yml +++ /dev/null @@ -1,4 +0,0 @@ -'*.{json,yml,css,js,cjs,d.ts}': prettier --write -'*': make lint_editor lint_fs -'*.css': make lint_css -'*.js': make lint_js lint_type diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 00000000..16244e13 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,9 @@ +/** @type {import('lint-staged').Config} */ +let config = { + '*': `make lint_editor lint_fs`, + '*.{json,yml,css,js,cjs,d.ts}': `prettier --write`, + '*.css': `make lint_css`, + '*.js': `make lint_js lint_type`, +} + +export default config diff --git a/package-lock.json b/package-lock.json index f97ab26a..198a6a90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@commitlint/cli": "17.8.1", "@commitlint/config-conventional": "18.4.0", "@ls-lint/ls-lint": "2.2.2", + "@types/lint-staged": "13.2.2", "browserslist": "4.22.1", "concurrently": "8.2.2", "editorconfig-checker": "5.1.1", @@ -1648,6 +1649,12 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/lint-staged": { + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/@types/lint-staged/-/lint-staged-13.2.2.tgz", + "integrity": "sha512-9c2ffPMJ1geob6yBmLuxzYye11HzKyA/I4dRZ8NfrPgY6SyzXt2SROD8vB3YjdPZJqqcu3WXsRvrY3PZbb720A==", + "dev": true + }, "node_modules/@types/mdast": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.3.tgz", diff --git a/package.json b/package.json index 5f8eb1fd..7f3c0df5 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@commitlint/cli": "17.8.1", "@commitlint/config-conventional": "18.4.0", "@ls-lint/ls-lint": "2.2.2", + "@types/lint-staged": "13.2.2", "browserslist": "4.22.1", "concurrently": "8.2.2", "editorconfig-checker": "5.1.1", From c6d477c6c957c12c37860b8c6648373f9f8145a0 Mon Sep 17 00:00:00 2001 From: what1s1ove Date: Tue, 21 Nov 2023 17:02:46 +0200 Subject: [PATCH 4/4] chore: replace eslint yml config with js wd-157 --- .eslintrc.yml | 149 ---------------------------- Makefile | 2 +- eslint.config.js | 244 ++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 17 ++++ package.json | 1 + tsconfig.json | 1 + 6 files changed, 264 insertions(+), 150 deletions(-) delete mode 100644 .eslintrc.yml create mode 100644 eslint.config.js diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 6e730b48..00000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,149 +0,0 @@ -env: - es2021: true - browser: true - -extends: - - eslint:recommended - - plugin:import/recommended - - plugin:sonarjs/recommended - - plugin:unicorn/recommended - - plugin:perfectionist/recommended-natural - - plugin:jsdoc/recommended-typescript-flavor-error - -plugins: - - simple-import-sort - -parserOptions: - ecmaVersion: 2022 - sourceType: module - -settings: - jsdoc: - mode: typescript - import/resolver: - alias: - extensions: - - .js - map: - - ['~', './source/scripts'] - -ignorePatterns: - - build - -rules: - no-restricted-syntax: - - error - - selector: VariableDeclaration[kind!=let] - message: Only let can be used for the variable declaration. - - selector: SwitchCase > *.consequent[type!="BlockStatement"] - message: Switch cases without blocks are forbidden. - - selector: ExportAllDeclaration,ImportAllDeclaration - message: Export/Import all (*) is forbidden. - - selector: ExportNamedDeclaration[declaration!=null] - message: Exports should be at the end of the file. - semi: - - error - - never - comma-dangle: - - error - - always-multiline - quotes: - - error - - backtick - quote-props: - - error - - consistent - no-unused-expressions: - - error - - allowTernary: true - object-curly-newline: - - error - - multiline: true - consistent: true - curly: - - error - - all - object-curly-spacing: - - error - - always - implicit-arrow-linebreak: - - error - - beside - function-paren-newline: - - error - - consistent - no-confusing-arrow: - - error - - allowParens: true - require-atomic-updates: - - error - no-console: - - error - - allow: - - warn - - error - - info - arrow-parens: - - error - - always - no-multiple-empty-lines: - - error - - max: 1 - simple-import-sort/imports: - - error - simple-import-sort/exports: - - error - perfectionist/sort-named-imports: - - error - - type: alphabetical - import/exports-last: - - error - import/group-exports: - - error - import/no-default-export: - - error - import/first: - - error - import/newline-after-import: - - error - import/no-duplicates: - - error - import/extensions: - - error - - ignorePackages - jsdoc/require-jsdoc: - - error - - checkConstructors: false - checkGetters: true - checkSetters: true - contexts: - - ArrowFunctionExpression - - ClassProperty - - FunctionDeclaration - - FunctionExpression - - MethodDefinition - jsdoc/valid-types: - - off - jsdoc/require-returns-description: - - off - jsdoc/require-param-description: - - off - jsdoc/require-property-description: - - off - -overrides: - - files: - - commitlint.config.js - - prettier.config.js - - lint-staged.config.js - rules: - import/no-default-export: - - off - - files: - - eleventy.config.cjs - - stylelint.config.cjs - env: - node: true - rules: - sonarjs/cognitive-complexity: - - off diff --git a/Makefile b/Makefile index c922e967..d6bd3bbc 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ lint_html: lint_css: npx stylelint "source/styles/**/*.css" lint_js: - npx eslint --ext .js "**/*.{js,cjs}" + npx eslint "**/*.{js,cjs}" lint_type: npx tsc --noEmit lint: lint_fs lint_editor lint_prettify lint_html lint_css lint_js lint_type diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..0bd22a02 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,244 @@ +// @ts-expect-error: no declaration file +import js from '@eslint/js' +// @ts-expect-error: no declaration file +import importPlugin from 'eslint-plugin-import' +// @ts-expect-error: no declaration file +import jsdoc from 'eslint-plugin-jsdoc' +// @ts-expect-error: no declaration file +import perfectionist from 'eslint-plugin-perfectionist' +// @ts-expect-error: no declaration file +import simpleImportSort from 'eslint-plugin-simple-import-sort' +import sonarjs from 'eslint-plugin-sonarjs' +// @ts-expect-error: no declaration file +import unicorn from 'eslint-plugin-unicorn' +import globals from 'globals' + +/** @type {import('eslint').Linter.FlatConfig} */ +let ignoresConfig = { + ignores: [`build/**/*.js`], +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let globalConfig = { + languageOptions: { + globals: globals.browser, + parserOptions: { + ecmaVersion: `latest`, + sourceType: `module`, + }, + }, + rules: { + ...js.configs.recommended.rules, + }, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let importConfig = { + plugins: { + import: importPlugin, + }, + rules: { + ...importPlugin.configs.recommended.rules, + 'import/exports-last': [`error`], + 'import/extensions': [`error`, `ignorePackages`], + 'import/first': [`error`], + 'import/group-exports': [`error`], + 'import/newline-after-import': [`error`], + 'import/no-default-export': [`error`], + 'import/no-duplicates': [`error`], + }, + settings: { + 'import/parsers': { + espree: [`.js`, `.cjs`], + }, + 'import/resolver': { + alias: { + extensions: [`.js`], + map: [[`~`, `./source/scripts`]], + }, + }, + }, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let sonarConfig = { + plugins: { + sonarjs, + }, + rules: sonarjs.configs.recommended.rules, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let unicornConfig = { + plugins: { + unicorn, + }, + rules: unicorn.configs.recommended.rules, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let perfectionistConfig = { + plugins: { + perfectionist, + }, + rules: { + ...perfectionist.configs[`recommended-natural`].rules, + 'perfectionist/sort-named-imports': [ + `error`, + { + 'type': `alphabetical`, + }, + ], + }, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let jsdocConfig = { + plugins: { + jsdoc, + }, + rules: { + ...jsdoc.configs[`recommended-typescript-flavor-error`].rules, + 'jsdoc/require-jsdoc': [ + `error`, + { + checkConstructors: false, + checkGetters: true, + checkSetters: true, + contexts: [ + `ArrowFunctionExpression`, + `ClassProperty`, + `FunctionDeclaration`, + `FunctionExpression`, + `MethodDefinition`, + ], + }, + ], + 'jsdoc/require-param-description': [`off`], + 'jsdoc/require-property-description': [`off`], + 'jsdoc/require-returns-description': [`off`], + 'jsdoc/valid-types': [`off`], + }, + settings: { + jsdoc: { + mode: `typescript`, + }, + }, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let simpleImportSortConfig = { + plugins: { + 'simple-import-sort': simpleImportSort, + }, + rules: { + 'simple-import-sort/exports': [`error`], + 'simple-import-sort/imports': [`error`], + }, +} + +/** @type {import('eslint').Linter.FlatConfig} */ +let mainRulesConfig = { + rules: { + 'arrow-parens': [`error`, `always`], + 'comma-dangle': [`error`, `always-multiline`], + 'curly': [`error`, `all`], + 'function-paren-newline': [`error`, `consistent`], + 'implicit-arrow-linebreak': [`error`, `beside`], + 'no-confusing-arrow': [ + `error`, + { + allowParens: true, + }, + ], + 'no-console': [ + `error`, + { + allow: [`warn`, `error`, `info`], + }, + ], + 'no-multiple-empty-lines': [ + `error`, + { + max: 1, + }, + ], + 'no-restricted-syntax': [ + `error`, + { + message: `Only let can be used for the variable declaration.`, + selector: `VariableDeclaration[kind!=let]`, + }, + { + message: `Switch cases without blocks are forbidden.`, + selector: `SwitchCase > *.consequent[type!="BlockStatement"]`, + }, + { + message: `Export/Import all (*) is forbidden.`, + selector: `ExportAllDeclaration,ImportAllDeclaration`, + }, + { + message: `Exports should be at the end of the file.`, + selector: `ExportNamedDeclaration[declaration!=null]`, + }, + ], + 'no-unused-expressions': [ + `error`, + { + allowTernary: true, + }, + ], + 'object-curly-newline': [ + `error`, + { + consistent: true, + multiline: true, + }, + ], + 'object-curly-spacing': [`error`, `always`], + 'quote-props': [`error`, `consistent`], + 'quotes': [`error`, `backtick`], + 'require-atomic-updates': [`error`], + 'semi': [`error`, `never`], + }, +} + +/** @type {import('eslint').Linter.FlatConfig[]} */ +let overridesConfig = [ + { + files: [ + `commitlint.config.js`, + `prettier.config.js`, + `lint-staged.config.js`, + `eslint.config.js`, + ], + rules: { + 'import/no-default-export': [`off`], + }, + }, + { + files: [`eleventy.config.cjs`, `stylelint.config.cjs`], + languageOptions: { + globals: globals.node, + }, + rules: { + 'sonarjs/cognitive-complexity': [`off`], + }, + }, +] + +/** @type {import('eslint').Linter.FlatConfig[]} */ +let config = [ + ignoresConfig, + globalConfig, + importConfig, + sonarConfig, + unicornConfig, + perfectionistConfig, + jsdocConfig, + simpleImportSortConfig, + mainRulesConfig, + ...overridesConfig, +] + +export default config diff --git a/package-lock.json b/package-lock.json index 198a6a90..22bedc22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@commitlint/cli": "17.8.1", "@commitlint/config-conventional": "18.4.0", "@ls-lint/ls-lint": "2.2.2", + "@types/eslint": "8.44.7", "@types/lint-staged": "13.2.2", "browserslist": "4.22.1", "concurrently": "8.2.2", @@ -1637,6 +1638,22 @@ "@types/ms": "*" } }, + "node_modules/@types/eslint": { + "version": "8.44.7", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.44.7.tgz", + "integrity": "sha512-f5ORu2hcBbKei97U73mf+l9t4zTGl74IqZ0GQk4oVea/VS8tQZYkUveSYojk+frraAVYId0V2WC9O4PTNru2FQ==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", diff --git a/package.json b/package.json index 7f3c0df5..1e51f714 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@commitlint/cli": "17.8.1", "@commitlint/config-conventional": "18.4.0", "@ls-lint/ls-lint": "2.2.2", + "@types/eslint": "8.44.7", "@types/lint-staged": "13.2.2", "browserslist": "4.22.1", "concurrently": "8.2.2", diff --git a/tsconfig.json b/tsconfig.json index d9a39ef3..f346123f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "paths": { "~/*": ["source/scripts/*"] }, + "skipLibCheck": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], "types": ["./source/scripts/globals.d.ts"], "esModuleInterop": true,