Skip to content

Commit

Permalink
fix: more tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Apr 16, 2024
1 parent 1dfec8c commit e1071eb
Show file tree
Hide file tree
Showing 28 changed files with 456 additions and 335 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@
"@semantic-release/github": "10.0.3",
"@semantic-release/npm": "12.0.0",
"@semantic-release/release-notes-generator": "13.0.0",
"@stylistic/eslint-plugin": "1.7.0",
"@stylistic/eslint-plugin-migrate": "1.7.0",
"@stylistic/eslint-plugin": "1.7.2",
"@stylistic/eslint-plugin-migrate": "1.7.2",
"@types/node": "20.12.7",
"@types/rollup-plugin-auto-external": "2.0.5",
"@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.6.0",
"@typescript-eslint/utils": "7.6.0",
"@unocss/eslint-plugin": "0.59.2",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"@typescript-eslint/utils": "7.7.0",
"@unocss/eslint-plugin": "0.59.3",
"commitizen": "4.3.0",
"cspell": "8.7.0",
"cz-conventional-changelog": "3.3.0",
"deassert": "1.0.2",
"eslint": "9.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-flat-config-utils": "0.2.2",
"eslint-flat-config-utils": "0.2.3",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-merge-processors": "0.1.0",
"eslint-plugin-eslint-comments": "3.2.0",
Expand All @@ -99,7 +99,7 @@
"eslint-plugin-vue": "9.25.0",
"eslint-plugin-yml": "1.14.0",
"eslint-processor-vue-blocks": "0.1.1",
"eslint-typegen": "0.2.2",
"eslint-typegen": "0.2.3",
"husky": "9.0.11",
"jiti": "1.21.0",
"jsonc-eslint-parser": "2.4.0",
Expand Down
214 changes: 107 additions & 107 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

40 changes: 25 additions & 15 deletions scripts/typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ import {
functional,
ignores,
imports,
inEditor,
javascript,
jsdoc,
jsonc,
markdown,
node,
overrides,
promise,
regexp,
sonar,
sortTsconfig,
stylistic,
test,
Expand All @@ -27,24 +32,29 @@ import { combine } from "../src/utils";

const configs = await combine(
comments(),
formatters(),
functional(),
ignores(),
imports(),
javascript(),
jsdoc(),
jsonc(),
markdown(),
formatters({}, {}),
functional({}),
ignores({}),
imports({}),
inEditor(),
javascript({}),
jsdoc({}),
jsonc({}),
markdown({}),
node(),
overrides(),
promise(),
regexp(),
sonar({}),
sortTsconfig(),
stylistic(),
test(),
toml(),
typescript(),
stylistic({}),
test({}),
toml({}),
typescript({}),
unicorn(),
unocss(),
vue(),
yaml(),
unocss({}),
vue({}),
yaml({}),
);

const dts = await flatConfigsToRulesDTS(configs, {
Expand Down
4 changes: 1 addition & 3 deletions src/configs/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { type ESLint } from "eslint";
import { type FlatConfigItem } from "../types";
import { loadPackages } from "../utils";

export async function comments(
options: unknown = {},
): Promise<FlatConfigItem[]> {
export async function comments(): Promise<FlatConfigItem[]> {
const [pluginComments] = (await loadPackages([
"eslint-plugin-eslint-comments",
])) as [ESLint.Plugin];
Expand Down
6 changes: 2 additions & 4 deletions src/configs/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ import {
} from "../types";
import { loadPackages, parserPlain } from "../utils";

import { StylisticConfigDefaults } from "./stylistic";

export async function formatters(
opts: OptionsFormatters | true = {},
stylistic: StylisticConfig = StylisticConfigDefaults,
opts: Readonly<OptionsFormatters | true>,
stylistic: Readonly<StylisticConfig>,
): Promise<FlatConfigItem[]> {
const options =
opts === true
Expand Down
10 changes: 6 additions & 4 deletions src/configs/functional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
import { loadPackages } from "../utils";

export async function functional(
options: OptionsFunctional &
OptionsStylistic &
OptionsOverrides &
OptionsTypeScriptParserOptions = {},
options: Readonly<
OptionsFunctional &
OptionsStylistic &
OptionsOverrides &
OptionsTypeScriptParserOptions
>,
): Promise<FlatConfigItem[]> {
const {
overrides = {},
Expand Down
6 changes: 2 additions & 4 deletions src/configs/ignores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GLOB_EXCLUDE } from "../globs";
import { type FlatConfigItem, type OptionsIgnores } from "../types";

export function ignores(
options: Readonly<{ ignores?: OptionsIgnores }> = {},
options: Readonly<{ ignores?: OptionsIgnores }>,
): FlatConfigItem[] {
const ignoresOptions = options.ignores;

Expand All @@ -11,11 +11,9 @@ export function ignores(
? [true, ignoresOptions ?? []]
: [ignoresOptions.extend ?? true, ignoresOptions.files ?? []];

const ignores = extend ? [...GLOB_EXCLUDE, ...files] : [...files];

return [
{
ignores,
ignores: extend ? [...GLOB_EXCLUDE, ...files] : [...files],
},
];
}
8 changes: 5 additions & 3 deletions src/configs/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import {
import { loadPackages } from "../utils";

export async function imports(
options: OptionsStylistic &
OptionsTypeScriptWithTypes &
OptionsTypeScriptParserOptions = {},
options: Readonly<
OptionsStylistic &
OptionsTypeScriptWithTypes &
OptionsTypeScriptParserOptions
>,
): Promise<FlatConfigItem[]> {
const { stylistic = true } = options;

Expand Down
2 changes: 1 addition & 1 deletion src/configs/in-editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FlatConfigItem } from "../types";

export function inEditor(options: unknown = {}): FlatConfigItem[] {
export function inEditor(): FlatConfigItem[] {
return [
{
name: "rs:in-editor",
Expand Down
3 changes: 3 additions & 0 deletions src/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ export * from "./unicorn";
export * from "./unocss";
export * from "./vue";
export * from "./yaml";
export * from "./promise";
export * from "./regexp";
export * from "./sonar";
139 changes: 6 additions & 133 deletions src/configs/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
import { type ESLint } from "eslint";
import globals from "globals";

import {
type FlatConfigItem,
type OptionsFunctional,
type OptionsOverrides,
} from "../types";
import { loadPackages } from "../utils";

const useNumberIsFinite = "Please use Number.isFinite instead";
const useNumberIsNan = "Please use Number.isNaN instead";
const useObjectDefineProperty = "Please use Object.defineProperty instead.";

export async function javascript(
options: OptionsOverrides & OptionsFunctional = {},
): Promise<FlatConfigItem[]> {
export function javascript(
options: Readonly<OptionsOverrides & OptionsFunctional>,
): FlatConfigItem[] {
const { functionalEnforcement = "none", overrides = {} } = options;

const [pluginRegexp, pluginOptimizeRegex, pluginPromise, pluginSonar] =
(await loadPackages([
"eslint-plugin-regexp",
"eslint-plugin-optimize-regex",
"eslint-plugin-promise",
"eslint-plugin-sonarjs",
])) as [ESLint.Plugin, ESLint.Plugin, ESLint.Plugin, ESLint.Plugin];

return [
{
name: "rs:javascript",
Expand All @@ -48,17 +38,6 @@ export async function javascript(
linterOptions: {
reportUnusedDisableDirectives: true,
},
plugins: {
regexp: {
...pluginRegexp,
rules: {
...pluginRegexp.rules,
...pluginOptimizeRegex.rules,
},
},
promise: pluginPromise,
sonar: pluginSonar,
},
rules: {
"accessor-pairs": "error",
"array-callback-return": "error",
Expand Down Expand Up @@ -361,117 +340,11 @@ export async function javascript(
"vars-on-top": "error",
yoda: ["error", "never"],

"no-empty-character-class": "off",
"no-invalid-regexp": "off",
"no-useless-backreference": "off",
"regexp/confusing-quantifier": "error",
"regexp/control-character-escape": "error",
"regexp/match-any": "error",
"regexp/negation": "error",
"regexp/no-contradiction-with-assertion": "error",
"regexp/no-dupe-characters-character-class": "error",
"regexp/no-dupe-disjunctions": "error",
"regexp/no-empty-alternative": "error",
"regexp/no-empty-capturing-group": "error",
"regexp/no-empty-character-class": "error",
"regexp/no-empty-group": "error",
"regexp/no-empty-lookarounds-assertion": "error",
"regexp/no-empty-string-literal": "error",
"regexp/no-escape-backspace": "error",
"regexp/no-extra-lookaround-assertions": "error",
"regexp/no-invalid-regexp": "error",
"regexp/no-invisible-character": "error",
"regexp/no-lazy-ends": "error",
"regexp/no-legacy-features": "error",
"regexp/no-misleading-capturing-group": "error",
"regexp/no-misleading-unicode-character": "error",
"regexp/no-missing-g-flag": "error",
"regexp/no-non-standard-flag": "error",
"regexp/no-obscure-range": "error",
"regexp/no-optional-assertion": "error",
"regexp/no-potentially-useless-backreference": "error",
"regexp/no-super-linear-backtracking": "error",
"regexp/no-trivially-nested-assertion": "error",
"regexp/no-trivially-nested-quantifier": "error",
"regexp/no-unused-capturing-group": "error",
"regexp/no-useless-assertions": "error",
"regexp/no-useless-backreference": "error",
"regexp/no-useless-character-class": "error",
"regexp/no-useless-dollar-replacements": "error",
"regexp/no-useless-escape": "error",
"regexp/no-useless-flag": "error",
"regexp/no-useless-lazy": "error",
"regexp/no-useless-non-capturing-group": "error",
"regexp/no-useless-quantifier": "error",
"regexp/no-useless-range": "error",
"regexp/no-useless-set-operand": "error",
"regexp/no-useless-string-literal": "error",
"regexp/no-useless-two-nums-quantifier": "error",
"regexp/no-zero-quantifier": "error",
"regexp/optimal-lookaround-quantifier": "error",
"regexp/optimal-quantifier-concatenation": "error",
"regexp/optimize-regex": "error",
"regexp/prefer-character-class": "error",
"regexp/prefer-d": "error",
"regexp/prefer-plus-quantifier": "error",
"regexp/prefer-predefined-assertion": "error",
"regexp/prefer-question-quantifier": "error",
"regexp/prefer-range": "error",
"regexp/prefer-set-operation": "error",
"regexp/prefer-star-quantifier": "error",
"regexp/prefer-unicode-codepoint-escapes": "error",
"regexp/prefer-w": "error",
"regexp/simplify-set-operations": "error",
"regexp/sort-flags": "error",
"regexp/strict": "error",
"regexp/use-ignore-case": "error",

"promise/avoid-new": "warn",
"promise/no-callback-in-promise": "error",
// "promise/no-nesting": "error", // Doesn't work with eslint 9 yet
"promise/no-new-statics": "error",
// "promise/no-promise-in-callback": "error", // Doesn't work with eslint 9 yet
"promise/no-return-in-finally": "error",
// "promise/no-return-wrap": "error", // Doesn't work with eslint 9 yet
"promise/param-names": "error",
"promise/valid-params": "error",

"sonar/no-all-duplicated-branches": "error",
"sonar/no-collapsible-if": "error",
"sonar/no-collection-size-mischeck": "error",
"sonar/no-duplicated-branches": "error",
"sonar/no-element-overwrite": "error",
// "sonar/no-empty-collection": "error", // Doesn't work with eslint 9 yet
// "sonar/no-extra-arguments": "error", // Doesn't work with eslint 9 yet
// "sonar/no-gratuitous-expressions": "error", // Doesn't work with eslint 9 yet
"sonar/no-identical-conditions": "error",
"sonar/no-identical-expressions": "error",
"sonar/no-identical-functions": "error",
"sonar/no-ignored-return": "error",
"sonar/no-inverted-boolean-check": "error",
"sonar/no-nested-switch": "error",
"sonar/no-nested-template-literals": "error",
"sonar/no-one-iteration-loop": "error",
"sonar/no-redundant-boolean": "error",
// "sonar/no-redundant-jump": "error", // Doesn't work with eslint 9 yet
"sonar/no-same-line-conditional": "error",
// "sonar/no-unused-collection": "error", // Doesn't work with eslint 9 yet
// "sonar/no-use-of-empty-return-value": "error", // Doesn't work with eslint 9 yet
"sonar/no-useless-catch": "error",
"sonar/non-existent-operator": "error",
"sonar/prefer-immediate-return": "error",
"sonar/prefer-object-literal": "error",
"sonar/prefer-single-boolean-return": "error",
"sonar/prefer-while": "error",

...(functionalEnforcement === "none"
? {}
: functionalEnforcement === "lite"
? { "no-param-reassign": "error" }
: {
"no-param-reassign": "error",
"sonar/elseif-without-else": "error",
}),
: {
"no-param-reassign": "error",
}),

...overrides,
},
Expand Down
2 changes: 1 addition & 1 deletion src/configs/jsdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type FlatConfigItem, type OptionsStylistic } from "../types";
import { loadPackages } from "../utils";

export async function jsdoc(
options: OptionsStylistic = {},
options: Readonly<OptionsStylistic>,
): Promise<FlatConfigItem[]> {
const { stylistic = true } = options;

Expand Down
2 changes: 1 addition & 1 deletion src/configs/jsonc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { loadPackages } from "../utils";

export async function jsonc(
options: OptionsFiles & OptionsStylistic & OptionsOverrides = {},
options: Readonly<OptionsFiles & OptionsStylistic & OptionsOverrides>,
): Promise<FlatConfigItem[]> {
const {
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
Expand Down
2 changes: 1 addition & 1 deletion src/configs/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import { interopDefault, loadPackages, parserPlain } from "../utils";

export async function markdown(
options: OptionsFiles & OptionsComponentExts & OptionsOverrides = {},
options: Readonly<OptionsFiles & OptionsComponentExts & OptionsOverrides>,
): Promise<FlatConfigItem[]> {
const {
componentExts = [],
Expand Down
Loading

0 comments on commit e1071eb

Please sign in to comment.