Skip to content

Commit 72b9a18

Browse files
fix: build cjs and adjust rules some more
1 parent 6f02ef8 commit 72b9a18

18 files changed

+567
-362
lines changed

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
},
2222
"type": "module",
2323
"exports": {
24-
"import": {
25-
"types": "./dist/index.d.mts",
26-
"default": "./dist/index.mjs"
27-
}
24+
"types": {
25+
"require": "./dist/index.d.cts",
26+
"import": "./dist/index.d.mts"
27+
},
28+
"require": "./dist/index.cjs",
29+
"import": "./dist/index.mjs"
2830
},
2931
"files": [
3032
"dist/",

rollup.config.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@ const treeshake = {
1515
export default {
1616
input: "src/index.ts",
1717

18-
output: {
19-
file: pkg.exports.import.default,
20-
format: "esm",
21-
sourcemap: false,
22-
},
18+
output: [
19+
{
20+
file: pkg.exports.import,
21+
format: "esm",
22+
sourcemap: false,
23+
generatedCode: {
24+
preset: "es2015",
25+
},
26+
},
27+
{
28+
file: pkg.exports.import,
29+
format: "esm",
30+
sourcemap: false,
31+
generatedCode: {
32+
preset: "es2015",
33+
},
34+
},
35+
],
2336

2437
plugins: [
2538
rollupPluginAutoExternal(),

src/configs/formatters.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
GLOB_TS,
1919
GLOB_TSX,
2020
GLOB_YAML,
21-
} from "..";
21+
} from "../globs";
2222
import {
2323
type FlatConfigItem,
2424
type OptionsFormatters,
@@ -80,6 +80,7 @@ export async function formatters(
8080
const turnOffRulesForPrettier = {
8181
...configPrettier.rules,
8282

83+
"no-irregular-whitespace": "off",
8384
"style/block-spacing": "off",
8485
"style/brace-style": "off",
8586
"style/comma-dangle": "off",
@@ -91,6 +92,7 @@ export async function formatters(
9192
"style/keyword-spacing": "off",
9293
"style/lines-around-comment": "off",
9394
"style/member-delimiter-style": "off",
95+
"style/newline-per-chained-call": "off",
9496
"style/no-extra-parens": "off",
9597
"style/no-extra-semi": "off",
9698
"style/nonblock-statement-body-position": "off",
@@ -117,7 +119,7 @@ export async function formatters(
117119
},
118120
];
119121

120-
if (options.js !== undefined && options.js !== false) {
122+
if (options.js !== undefined && options.js) {
121123
configs.push({
122124
name: "rs:formatter:javascript",
123125
files: [GLOB_JS, GLOB_JSX],
@@ -134,7 +136,7 @@ export async function formatters(
134136
});
135137
}
136138

137-
if (options.ts !== undefined && options.ts !== false) {
139+
if (options.ts !== undefined && options.ts) {
138140
configs.push({
139141
name: "rs:formatter:typescript",
140142
files: [GLOB_TS, GLOB_TSX],
@@ -152,7 +154,7 @@ export async function formatters(
152154
});
153155
}
154156

155-
if (options.yaml !== undefined && options.yaml !== false) {
157+
if (options.yaml !== undefined && options.yaml) {
156158
configs.push({
157159
name: "rs:formatter:yaml",
158160
files: [GLOB_YAML],
@@ -173,7 +175,7 @@ export async function formatters(
173175
});
174176
}
175177

176-
if (options.json !== undefined && options.json !== false) {
178+
if (options.json !== undefined && options.json) {
177179
configs.push(
178180
{
179181
name: "rs:formatter:json",
@@ -253,7 +255,7 @@ export async function formatters(
253255
);
254256
}
255257

256-
if (options.css !== undefined && options.css !== false) {
258+
if (options.css !== undefined && options.css) {
257259
configs.push(
258260
{
259261
name: "rs:formatter:css",
@@ -309,7 +311,7 @@ export async function formatters(
309311
);
310312
}
311313

312-
if (options.html !== undefined && options.html !== false) {
314+
if (options.html !== undefined && options.html) {
313315
configs.push({
314316
name: "rs:formatter:html",
315317
files: ["**/*.html"],
@@ -329,7 +331,7 @@ export async function formatters(
329331
});
330332
}
331333

332-
if (options.markdown !== undefined && options.markdown !== false) {
334+
if (options.markdown !== undefined && options.markdown) {
333335
const GLOB_SLIDEV =
334336
options.slidev === undefined || options.slidev === false
335337
? []
@@ -382,7 +384,7 @@ export async function formatters(
382384
}
383385
}
384386

385-
if (options.graphql !== undefined && options.graphql !== false) {
387+
if (options.graphql !== undefined && options.graphql) {
386388
configs.push({
387389
files: [GLOB_GRAPHQL],
388390
languageOptions: {

src/configs/functional.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { type ESLint } from "eslint";
2-
31
import { GLOB_TS } from "../globs";
42
import {
53
type FlatConfigItem,
@@ -28,8 +26,8 @@ export async function functional(
2826
}
2927

3028
const [pluginFunctional] = (await loadPackages([
31-
"eslint-plugin-functional/flat",
32-
])) as [(typeof import("eslint-plugin-functional/flat"))["default"]];
29+
"eslint-plugin-functional",
30+
])) as [(typeof import("eslint-plugin-functional"))["default"]];
3331

3432
const strictRules = {
3533
"functional/functional-parameters": "error",
@@ -209,7 +207,7 @@ export async function functional(
209207
{
210208
name: "rs:functional",
211209
plugins: {
212-
functional: pluginFunctional as unknown as ESLint.Plugin,
210+
functional: pluginFunctional,
213211
},
214212
settings: {
215213
immutability: {

src/configs/ignores.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import { GLOB_EXCLUDE } from "../globs";
2-
import { type FlatConfigItem } from "../types";
2+
import { type FlatConfigItem, type OptionsIgnores } from "../types";
3+
4+
export function ignores(options: Readonly<OptionsIgnores>): FlatConfigItem[] {
5+
const [extend, files] =
6+
options === undefined || Array.isArray(options)
7+
? [true, options ?? []]
8+
: [options.extend ?? true, options.files ?? []];
9+
10+
const ignores = extend ? [...GLOB_EXCLUDE, ...files] : [...files];
311

4-
export function ignores(): FlatConfigItem[] {
512
return [
613
{
7-
ignores: GLOB_EXCLUDE,
14+
ignores,
815
},
916
];
1017
}

src/configs/imports.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type ESLint } from "eslint";
22

3-
import { GLOB_DTS, GLOB_MJS, GLOB_MTS, GLOB_TS, GLOB_TSX } from "..";
3+
import { GLOB_DTS, GLOB_MJS, GLOB_MTS, GLOB_TS, GLOB_TSX } from "../globs";
44
import { type FlatConfigItem, type OptionsStylistic } from "../types";
55
import { loadPackages } from "../utils";
66

@@ -107,7 +107,7 @@ export async function imports(
107107
"import/no-self-import": "error",
108108
"import/no-unassigned-import": "error",
109109
// "import/no-unused-modules": "off",
110-
"import/no-unresolved": "error",
110+
// "import/no-unresolved": "off",
111111
"import/no-useless-path-segments": [
112112
"error",
113113
{

src/configs/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from "./jsdoc";
88
export * from "./jsonc";
99
export * from "./markdown";
1010
export * from "./node";
11+
export * from "./overrides";
1112
export * from "./sort";
1213
export * from "./stylistic";
1314
export * from "./test";

src/configs/javascript.ts

+6-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { type ESLint } from "eslint";
22
import globals from "globals";
33

4-
import { GLOB_SRC, GLOB_SRC_EXT } from "../globs";
54
import {
65
type FlatConfigItem,
76
type OptionsFunctional,
@@ -380,29 +379,15 @@ export async function javascript(
380379

381380
...(functionalEnforcement === "none"
382381
? {}
383-
: {
384-
"no-param-reassign": "error",
385-
"sonar/elseif-without-else": "error",
386-
}),
382+
: functionalEnforcement === "lite"
383+
? { "no-param-reassign": "error" }
384+
: {
385+
"no-param-reassign": "error",
386+
"sonar/elseif-without-else": "error",
387+
}),
387388

388389
...overrides,
389390
},
390391
},
391-
{
392-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
393-
name: "rs:scripts-overrides",
394-
rules: {
395-
"no-console": "off",
396-
397-
"functional/no-conditional-statements": "off",
398-
"functional/no-expression-statements": "off",
399-
"functional/no-loop-statements": "off",
400-
"functional/no-return-void": "off",
401-
"functional/no-throw-statements": "off",
402-
403-
"node/no-sync": "off",
404-
"node/no-unpublished-import": "off",
405-
},
406-
},
407392
];
408393
}

src/configs/markdown.ts

+37-26
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
GLOB_MARKDOWN,
66
GLOB_MARKDOWN_CODE,
77
GLOB_MARKDOWN_IN_MARKDOWN,
8-
} from "..";
8+
} from "../globs";
99
import {
1010
type FlatConfigItem,
1111
type OptionsComponentExts,
@@ -31,9 +31,7 @@ export async function markdown(
3131
interopDefault(import("@typescript-eslint/eslint-plugin")).catch(
3232
() => undefined,
3333
),
34-
interopDefault(import("eslint-plugin-functional/flat")).catch(
35-
() => undefined,
36-
),
34+
interopDefault(import("eslint-plugin-functional")).catch(() => undefined),
3735
]);
3836

3937
return [
@@ -71,6 +69,7 @@ export async function markdown(
7169
],
7270
languageOptions: {
7371
parserOptions: {
72+
project: null,
7473
ecmaFeatures: {
7574
impliedStrict: true,
7675
},
@@ -80,49 +79,61 @@ export async function markdown(
8079
...pluginTs?.configs["disable-type-checked"]?.rules,
8180
...pluginFunctional?.configs.off.rules,
8281

83-
"import/newline-after-import": "off",
82+
"dot-notation": "off",
83+
"init-declarations": "off",
8484
"no-alert": "off",
8585
"no-console": "off",
86+
"no-empty-function": "off",
87+
"no-empty": "off",
88+
"no-irregular-whitespace": "off",
89+
"no-invalid-this": "off",
8690
"no-labels": "off",
8791
"no-lone-blocks": "off",
8892
"no-restricted-syntax": "off",
93+
"no-throw-literal": "off",
8994
"no-undef": "off",
9095
"no-unused-expressions": "off",
9196
"no-unused-labels": "off",
9297
"no-unused-vars": "off",
93-
"node/prefer-global/process": "off",
94-
"style/comma-dangle": "off",
95-
"style/eol-last": "off",
96-
"ts/consistent-type-imports": "off",
97-
"ts/no-namespace": "off",
98-
"ts/no-redeclare": "off",
99-
"ts/no-require-imports": "off",
100-
"ts/no-unused-vars": "off",
101-
"ts/no-use-before-define": "off",
102-
"ts/no-var-requires": "off",
98+
"no-useless-return": "off",
99+
"prefer-const": "off",
103100
"unicode-bom": "off",
104-
"dot-notation": "off",
101+
105102
"import/extensions": "off",
103+
"import/newline-after-import": "off",
104+
"import/no-extraneous-dependencies": "off",
106105
"import/no-unresolved": "off",
107-
"init-declarations": "off",
106+
108107
"jsdoc/require-jsdoc": "off",
109-
"n/handle-callback-err": "off",
110-
"no-empty-function": "off",
111-
"no-empty": "off",
112-
"no-invalid-this": "off",
113-
"no-throw-literal": "off",
114-
"no-useless-return": "off",
115-
"prefer-const": "off",
108+
109+
"node/handle-callback-err": "off",
110+
"node/prefer-global/process": "off",
111+
116112
"prettier/prettier": "off",
117-
"sonarjs/no-extra-arguments": "off",
118-
"sonarjs/no-unused-collection": "off",
113+
114+
"sonar/no-extra-arguments": "off",
115+
"sonar/no-unused-collection": "off",
116+
117+
"style/comma-dangle": "off",
118+
"style/eol-last": "off",
119+
119120
"ts/consistent-generic-constructors": "off",
121+
"ts/consistent-indexed-object-style": "off",
120122
"ts/consistent-type-definitions": "off",
123+
"ts/consistent-type-imports": "off",
121124
"ts/explicit-member-accessibility": "off",
122125
"ts/no-empty-function": "off",
123126
"ts/no-explicit-any": "off",
127+
"ts/no-namespace": "off",
128+
"ts/no-redeclare": "off",
129+
"ts/no-require-imports": "off",
124130
"ts/no-unused-expressions": "off",
131+
"ts/no-unused-vars": "off",
132+
"ts/no-use-before-define": "off",
133+
"ts/no-var-requires": "off",
134+
"ts/prefer-for-of": "off",
125135
"ts/prefer-function-type": "off",
136+
126137
"unicorn/prefer-optional-catch-binding": "off",
127138
"unicorn/prefer-top-level-await": "off",
128139
"unicorn/switch-case-braces": "off",

0 commit comments

Comments
 (0)