update to flat eslint config

This commit is contained in:
AJ Slater 2024-02-16 18:27:29 -08:00
parent 39fe7c8f79
commit 9ccd8957bb
8 changed files with 2376 additions and 5068 deletions

13
.eslintignore Normal file
View File

@ -0,0 +1,13 @@
!.circleci
**/__pycache__
*test-results*
*~
.git
.mypy_cache
.pytest_cache
.ruff_cache
.venv
dist
node_modules
package-lock.json
typings

View File

@ -1,101 +0,0 @@
module.exports = {
root: true,
env: {
browser: true,
es2022: true,
node: true,
},
extends: [
"eslint:recommended",
// LANGS
"plugin:json/recommended",
"plugin:mdx/recommended",
"plugin:yaml/recommended",
// CODE QUALITY
"plugin:sonarjs/recommended",
"plugin:unicorn/all",
// PRACTICES
"plugin:array-func/recommended",
"plugin:eslint-comments/recommended",
"plugin:no-use-extend-native/recommended",
"plugin:optimize-regex/all",
"plugin:promise/recommended",
"plugin:import/recommended",
"plugin:switch-case/recommended",
// PRETTIER
"plugin:prettier/recommended",
"prettier", // prettier-config
// SECURITY
"plugin:no-unsanitized/DOM",
"plugin:security/recommended-legacy",
],
overrides: [
{
files: ["*.md"],
rules: {
"prettier/prettier": ["warn", { parser: "markdown" }],
},
},
],
parserOptions: {
ecmaVersion: "latest",
ecmaFeatures: {
impliedStrict: true,
},
},
plugins: [
"array-func",
"eslint-comments",
"json",
"import",
"no-constructor-bind",
"no-secrets",
"no-unsanitized",
"no-use-extend-native",
"optimize-regex",
"prettier",
"promise",
"simple-import-sort",
"switch-case",
"security",
"sonarjs",
"unicorn",
"yaml",
],
rules: {
"array-func/prefer-array-from": "off", // for modern browsers the spread operator, as preferred by unicorn, works fine.
"max-params": ["warn", 4],
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-constructor-bind/no-constructor-bind": "error",
"no-constructor-bind/no-constructor-state": "error",
"no-secrets/no-secrets": "error",
"eslint-comments/no-unused-disable": 1,
"prettier/prettier": "warn",
"security/detect-object-injection": "off",
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": "warn",
"space-before-function-paren": "off",
"switch-case/newline-between-switch-case": "off", // Malfunctioning
"unicorn/switch-case-braces": ["warn", "avoid"],
"unicorn/prefer-node-protocol": 0,
"unicorn/prevent-abbreviations": "off",
"unicorn/filename-case": [
"error",
{ case: "kebabCase", ignore: [".*.md"] },
],
},
ignorePatterns: [
"*~",
"**/__pycache__",
".git",
"!.circleci",
".mypy_cache",
".pytest_cache",
".venv*",
"dist",
"package-lock.json",
"test-results",
"typings",
],
};

View File

@ -4,6 +4,8 @@ An API and CLI for extracting structured comic metadata from filenames.
## Install
<!-- eslint-skip -->
```sh
pip install comicfn2dict
```
@ -14,6 +16,8 @@ look at `comicfn2dict/comicfn2dict.py`
## CLI
<!-- eslint-skip -->
```sh
comicfn2dict "Series Name #01 - Title (2023).cbz"
{'ext': 'cbz',

186
eslint.config.js Normal file
View File

@ -0,0 +1,186 @@
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import arrayFunc from "eslint-plugin-array-func";
// import plugin broken for flag config
// https://github.com/import-js/eslint-plugin-import/issues/2556
// import importPlugin from "eslint-plugin-import";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import pluginSecurity from "eslint-plugin-security";
import eslintPluginUnicorn from "eslint-plugin-unicorn";
import globals from "globals";
const compat = new FlatCompat();
export default [
{
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
},
linterOptions: {
reportUnusedDisableDirectives: "warn",
},
plugins: {
// import: importPlugin,
unicorn: eslintPluginUnicorn,
},
rules: {
"array-func/prefer-array-from": "off", // for modern browsers the spread operator, as preferred by unicorn, works fine.
"max-params": ["warn", 4],
"no-console": "warn",
"no-debugger": "warn",
"no-constructor-bind/no-constructor-bind": "error",
"no-constructor-bind/no-constructor-state": "error",
"no-secrets/no-secrets": "error",
"prettier/prettier": "warn",
"security/detect-object-injection": "off",
"space-before-function-paren": "off",
"unicorn/switch-case-braces": ["warn", "avoid"],
"unicorn/prefer-node-protocol": 0,
"unicorn/prevent-abbreviations": "off",
"unicorn/filename-case": [
"error",
{ case: "kebabCase", ignore: [".*.md"] },
],
/*
...importPlugin.configs["recommended"].rules,
"import/no-unresolved": [
"error",
{
ignore: ["^[@]"],
},
],
*/
},
/*
settings: {
"import/parsers": {
espree: [".js", ".cjs", ".mjs", ".jsx"],
"@typescript-eslint/parser": [".ts"],
},
"import/resolver": {
typescript: true,
node: true,
},
},
*/
},
js.configs.recommended,
arrayFunc.configs.all,
pluginSecurity.configs.recommended,
eslintPluginPrettierRecommended,
...compat.config({
root: true,
env: {
browser: true,
es2024: true,
node: true,
},
extends: [
// LANGS
"plugin:jsonc/recommended-with-jsonc",
"plugin:markdown/recommended",
"plugin:toml/recommended",
"plugin:yml/standard",
"plugin:yml/prettier",
// CODE QUALITY
"plugin:sonarjs/recommended",
// PRACTICES
"plugin:eslint-comments/recommended",
// "plugin:import/recommended",
"plugin:no-use-extend-native/recommended",
"plugin:optimize-regex/all",
"plugin:promise/recommended",
"plugin:switch-case/recommended",
// SECURITY
"plugin:no-unsanitized/DOM",
],
overrides: [
{
files: ["**/*.md"],
processor: "markdown/markdown",
rules: {
"prettier/prettier": ["warn", { parser: "markdown" }],
},
},
{
files: ["**/*.md/*.js"], // Will match js code inside *.md files
rules: {
"no-unused-vars": "off",
"no-undef": "off",
},
},
{
files: ["**/*.md/*.sh"],
rules: {
"prettier/prettier": ["error", { parser: "sh" }],
},
},
{
files: ["*.yaml", "*.yml"],
//parser: "yaml-eslint-parser",
rules: {
"unicorn/filename-case": "off",
},
},
{
files: ["*.toml"],
//parser: "toml-eslint-parser",
rules: {
"prettier/prettier": ["error", { parser: "toml" }],
},
},
{
files: ["*.json", "*.json5", "*.jsonc"],
//parser: "jsonc-eslint-parser",
},
],
parserOptions: {
ecmaFeatures: {
impliedStrict: true,
},
ecmaVersion: "latest",
},
plugins: [
"eslint-comments",
//"import",
"markdown",
"no-constructor-bind",
"no-secrets",
"no-unsanitized",
"no-use-extend-native",
"optimize-regex",
"promise",
"simple-import-sort",
"sonarjs",
"switch-case",
"unicorn",
],
rules: {
"no-constructor-bind/no-constructor-bind": "error",
"no-constructor-bind/no-constructor-state": "error",
"no-secrets/no-secrets": "error",
"eslint-comments/no-unused-disable": 1,
"simple-import-sort/exports": "warn",
"simple-import-sort/imports": "warn",
"switch-case/newline-between-switch-case": "off", // Malfunctioning
},
ignorePatterns: [
"*~",
"**/__pycache__",
".git",
"!.circleci",
".mypy_cache",
".ruff_cache",
".pytest_cache",
".venv*",
"dist",
"node_modules",
"package-lock.json",
"test-results",
"typings",
],
}),
];

6139
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
{
"version": "0.1.0",
"description": "linting",
"version": "0.2.0",
"description": "comicfn2dict linting",
"type": "module",
"scripts": {
"fix": "eslint_d --cache --fix --ignore-pattern frontend --ext .cjs,.mjs,.js,.json,.yaml,.md . && prettier --write .",
"lint": "eslint_d --cache --ignore-pattern frontend --ext .cjs,.mjs,.js,.json,.yaml,.md . && prettier --check .",
"fix": "eslint --cache --fix . && prettier --write .",
"lint": "eslint --cache . && prettier --check .",
"remark-check": "remark .",
"remark-fix": "remark . --output"
},
@ -13,12 +13,13 @@
"@prettier/plugin-xml",
"prettier-plugin-nginx",
"prettier-plugin-packagejson",
"prettier-plugin-sh"
"prettier-plugin-sh",
"prettier-plugin-toml"
],
"overrides": [
{
"files": [
"*.md"
"**/*.md"
],
"options": {
"proseWrap": "always"
@ -28,6 +29,7 @@
},
"remarkConfig": {
"plugins": [
"gfm",
"preset-lint-consistent",
"preset-lint-recommended",
"preset-lint-markdown-style-guide",
@ -42,36 +44,37 @@
"@prettier/plugin-xml": "^3.0.0",
"eslint": "^8.34.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-array-func": "^4.0.0",
"eslint-plugin-array-func": "^5.0.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-json": "^3.1.0",
"eslint-plugin-mdx": "^3.0.0",
"eslint-plugin-jsonc": "^2.13.0",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-no-constructor-bind": "^2.0.4",
"eslint-plugin-no-secrets": "^0.8.9",
"eslint-plugin-no-unsanitized": "^4.0.0",
"eslint-plugin-no-use-extend-native": "^0.5.0",
"eslint-plugin-only-warn": "^1.0.2",
"eslint-plugin-optimize-regex": "^1.2.0",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-scanjs-rules": "^0.2.1",
"eslint-plugin-security": "^2.1.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-sonarjs": "^0.23.0",
"eslint-plugin-simple-import-sort": "^12.0.0",
"eslint-plugin-sonarjs": "^0.24.0",
"eslint-plugin-switch-case": "^1.1.2",
"eslint-plugin-unicorn": "^50.0.1",
"eslint-plugin-yaml": "^0.5.0",
"eslint-plugin-toml": "^0.9.2",
"eslint-plugin-unicorn": "^51.0.1",
"eslint-plugin-yml": "^1.12.2",
"eslint_d": "^13.0.0",
"prettier": "^3.0.0",
"prettier-plugin-nginx": "^1.0.3",
"prettier-plugin-packagejson": "^2.4.4",
"prettier-plugin-sh": "^0.14.0",
"prettier-plugin-toml": "^2.0.1",
"remark-cli": "^12.0.0",
"remark-gfm": "^4.0.0",
"remark-preset-lint-consistent": "^5.1.1",
"remark-preset-lint-markdown-style-guide": "^5.1.2",
"remark-preset-lint-recommended": "^6.1.2",
"remark-preset-prettier": "^2.0.1",
"toml": "^3.0.0"
"remark-preset-prettier": "^2.0.1"
}
}

915
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,10 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
]
packages = [{ include = "comicfn2dict" }, { include = "tests", format = "sdist" }]
packages = [
{ include = "comicfn2dict" },
{ include = "tests", format = "sdist" },
]
exclude = ["*/**/*~"]
include = []
@ -42,7 +45,7 @@ pytest-gitignore = "^1.3"
codespell = "^2.1.0"
pyright = "^1.1.232"
radon = { version = "^6.0.1", extras = ["toml"] }
ruff = "^0.1.2"
ruff = "^0.2.1"
types-python-dateutil = "^2.8.19"
vulture = "^2.3"
@ -77,7 +80,7 @@ omit = [
"dist/*",
"node_modules/*",
"test-results/*",
"typings/*"
"typings/*",
]
[tool.pyright]
@ -102,8 +105,6 @@ pythonVersion = "3.10"
pythonPlatform = "All"
[tool.pytest.ini_options]
junit_family = "xunit2"
# --black
addopts = """
--junit-xml=test-results/pytest/results.xml
-ra
@ -113,21 +114,38 @@ addopts = """
--cov-append
--cov-report=html
--cov-report=term
--ignore=.git
--ignore=cache
--ignore=frontend
--ignore=typings
"""
junit_family = "xunit2"
testpaths = "tests"
[tool.radon]
exclude = "*~,.git/*,.mypy_cache/*,.pytest_cache/*,.venv*,__pycache__/*,cache/*,dist/*,node_modules/*,test-results/*,typings/*"
[tool.ruff]
extend-exclude = ["typings"]
extend-ignore = ["S101", "D203", "D213",
target-version = "py310"
[tool.lint.ruff]
extend-ignore = [
"S101",
"D203",
"D213",
# Format ignores
"W191", "E501", "E111", "E114", "E117", "D206", "D300", "Q000", "Q001",
"Q002", "Q003", "COM812", "COM819", "ISC001", "ISC002"
"W191",
"E501",
"E111",
"E114",
"E117",
"D206",
"D300",
"Q000",
"Q001",
"Q002",
"Q003",
"COM812",
"COM819",
"ISC001",
"ISC002",
]
extend-select = [
"A",
@ -168,19 +186,16 @@ extend-select = [
"TRY",
"UP",
"W",
"YTT"
"YTT",
# "ANN", "ERA", "COM"
]
external = ["V101"]
# format = "grouped"
# show-source = true
target-version = "py310"
task-tags = ["TODO", "FIXME", "XXX", "http", "HACK"]
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["SLF001", "T201", "T203"]
[tool.ruff.pycodestyle]
[tool.ruff.lint.pycodestyle]
ignore-overlong-task-comments = true
[tool.vulture]