@exbotanical/eslint-config 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -3
- package/dist/index.js +58 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11635,6 +11635,18 @@ interface OptionsJsonc extends AllOptions, OptionsSortKeys {
|
|
|
11635
11635
|
indent?: 'tab' | number;
|
|
11636
11636
|
}
|
|
11637
11637
|
|
|
11638
|
+
interface OptionsMarkdown extends AllOptions {
|
|
11639
|
+
/**
|
|
11640
|
+
* Lints the code blocks inside Markdown files as source files. Code blocks are often
|
|
11641
|
+
* documentation examples, including intentional counterexamples, so autofix rules that
|
|
11642
|
+
* reorder or remove code are turned off for them. Other fixes still rewrite them.
|
|
11643
|
+
* `overrides` passed here apply to the code blocks.
|
|
11644
|
+
*
|
|
11645
|
+
* @default false
|
|
11646
|
+
*/
|
|
11647
|
+
lintCodeBlocks?: boolean | OptionsOverrides;
|
|
11648
|
+
}
|
|
11649
|
+
|
|
11638
11650
|
interface OptionsPerfectionist extends AllOptions {
|
|
11639
11651
|
/**
|
|
11640
11652
|
* Sorts declarations whose order can carry meaning: interfaces, object types, enums,
|
|
@@ -11790,11 +11802,12 @@ interface OptionsConfig extends OptionsProjectType {
|
|
|
11790
11802
|
*/
|
|
11791
11803
|
toml?: boolean | OptionsToml;
|
|
11792
11804
|
/**
|
|
11793
|
-
* Enables
|
|
11794
|
-
*
|
|
11805
|
+
* Enables Markdown document rules. Code blocks are linted only when
|
|
11806
|
+
* `lintCodeBlocks` is set.
|
|
11807
|
+
*
|
|
11795
11808
|
* @default true
|
|
11796
11809
|
*/
|
|
11797
|
-
markdown?: boolean |
|
|
11810
|
+
markdown?: boolean | OptionsMarkdown;
|
|
11798
11811
|
/**
|
|
11799
11812
|
* Configurable global ignores.
|
|
11800
11813
|
*/
|
package/dist/index.js
CHANGED
|
@@ -903,33 +903,53 @@ var JsxConfig = class extends CustomConfig {
|
|
|
903
903
|
// src/configs/markdown.ts
|
|
904
904
|
var MarkdownConfig = class extends CustomConfig {
|
|
905
905
|
namespace = "markdown";
|
|
906
|
-
constructor({
|
|
906
|
+
constructor({
|
|
907
|
+
files = [GLOB_MARKDOWN],
|
|
908
|
+
lintCodeBlocks = false,
|
|
909
|
+
...rest
|
|
910
|
+
} = {}) {
|
|
907
911
|
super({
|
|
908
912
|
files,
|
|
913
|
+
lintCodeBlocks,
|
|
909
914
|
...rest
|
|
910
915
|
});
|
|
911
916
|
}
|
|
912
917
|
async _rules() {
|
|
913
|
-
const {
|
|
918
|
+
const {
|
|
919
|
+
files = [GLOB_MARKDOWN],
|
|
920
|
+
lintCodeBlocks = false,
|
|
921
|
+
overrides = {}
|
|
922
|
+
} = this.options;
|
|
914
923
|
const markdown = await interopDefault(import("@eslint/markdown"));
|
|
915
924
|
return [
|
|
916
925
|
this.createRuleConfig("setup", {
|
|
917
926
|
plugins: { markdown }
|
|
918
927
|
}),
|
|
919
|
-
this.createRuleConfig("processor", {
|
|
920
|
-
files,
|
|
921
|
-
ignores: ["**/*.md/*.md"],
|
|
922
|
-
// `eslint-plugin-markdown` only creates virtual files for code blocks,
|
|
923
|
-
// but not the markdown file itself (we use passthrough for this).
|
|
924
|
-
processor: mergeProcessors([markdown.processors.markdown, processorPassThrough])
|
|
925
|
-
}),
|
|
926
928
|
this.createRuleConfig("rules", {
|
|
927
929
|
files,
|
|
928
930
|
language: "markdown/gfm",
|
|
929
931
|
rules: {
|
|
930
|
-
...markdown.configs.recommended[0].rules
|
|
932
|
+
...markdown.configs.recommended[0].rules,
|
|
933
|
+
...overrides
|
|
931
934
|
}
|
|
932
935
|
}),
|
|
936
|
+
...lintCodeBlocks ? this.codeBlockRules(files, markdown, lintCodeBlocks) : []
|
|
937
|
+
];
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Builds the records that extract code blocks into virtual files and turn off the
|
|
941
|
+
* rules that do not fit documentation examples.
|
|
942
|
+
*/
|
|
943
|
+
codeBlockRules(files, markdown, lintCodeBlocks) {
|
|
944
|
+
const codeBlockOverrides = lintCodeBlocks === true ? {} : lintCodeBlocks.overrides ?? {};
|
|
945
|
+
return [
|
|
946
|
+
this.createRuleConfig("processor", {
|
|
947
|
+
files,
|
|
948
|
+
ignores: ["**/*.md/*.md"],
|
|
949
|
+
// The markdown processor only creates virtual files for code blocks, but not
|
|
950
|
+
// the markdown file itself (we use passthrough for this).
|
|
951
|
+
processor: mergeProcessors([markdown.processors.markdown, processorPassThrough])
|
|
952
|
+
}),
|
|
933
953
|
this.createRuleConfig("disables", {
|
|
934
954
|
files: [GLOB_MARKDOWN_CODE],
|
|
935
955
|
languageOptions: {
|
|
@@ -938,7 +958,13 @@ var MarkdownConfig = class extends CustomConfig {
|
|
|
938
958
|
}
|
|
939
959
|
},
|
|
940
960
|
rules: {
|
|
961
|
+
"import/first": "off",
|
|
941
962
|
"import/newline-after-import": "off",
|
|
963
|
+
"import/no-duplicates": "off",
|
|
964
|
+
"import/no-empty-named-blocks": "off",
|
|
965
|
+
"import/order": "off",
|
|
966
|
+
"jsdoc/no-blank-blocks": "off",
|
|
967
|
+
"jsdoc/sort-tags": "off",
|
|
942
968
|
"no-alert": "off",
|
|
943
969
|
"no-console": "off",
|
|
944
970
|
"no-labels": "off",
|
|
@@ -948,7 +974,24 @@ var MarkdownConfig = class extends CustomConfig {
|
|
|
948
974
|
"no-unused-expressions": "off",
|
|
949
975
|
"no-unused-labels": "off",
|
|
950
976
|
"no-unused-vars": "off",
|
|
977
|
+
"no-useless-return": "off",
|
|
951
978
|
"node/prefer-global/process": "off",
|
|
979
|
+
"perfectionist/sort-array-includes": "off",
|
|
980
|
+
"perfectionist/sort-classes": "off",
|
|
981
|
+
"perfectionist/sort-enums": "off",
|
|
982
|
+
"perfectionist/sort-exports": "off",
|
|
983
|
+
"perfectionist/sort-heritage-clauses": "off",
|
|
984
|
+
"perfectionist/sort-interfaces": "off",
|
|
985
|
+
"perfectionist/sort-intersection-types": "off",
|
|
986
|
+
"perfectionist/sort-modules": "off",
|
|
987
|
+
"perfectionist/sort-named-exports": "off",
|
|
988
|
+
"perfectionist/sort-named-imports": "off",
|
|
989
|
+
"perfectionist/sort-object-types": "off",
|
|
990
|
+
"perfectionist/sort-sets": "off",
|
|
991
|
+
"perfectionist/sort-union-types": "off",
|
|
992
|
+
"regexp/sort-alternatives": "off",
|
|
993
|
+
"regexp/sort-character-class-elements": "off",
|
|
994
|
+
"regexp/sort-flags": "off",
|
|
952
995
|
"style/comma-dangle": "off",
|
|
953
996
|
"style/eol-last": "off",
|
|
954
997
|
"ts/consistent-type-imports": "off",
|
|
@@ -960,9 +1003,10 @@ var MarkdownConfig = class extends CustomConfig {
|
|
|
960
1003
|
"ts/no-unused-vars": "off",
|
|
961
1004
|
"ts/no-use-before-define": "off",
|
|
962
1005
|
"unicode-bom": "off",
|
|
1006
|
+
"unicorn/prefer-export-from": "off",
|
|
963
1007
|
"unused-imports/no-unused-imports": "off",
|
|
964
1008
|
"unused-imports/no-unused-vars": "off",
|
|
965
|
-
...
|
|
1009
|
+
...codeBlockOverrides
|
|
966
1010
|
}
|
|
967
1011
|
})
|
|
968
1012
|
];
|
|
@@ -2523,9 +2567,6 @@ async function exbotanical({
|
|
|
2523
2567
|
if (optionsCss) {
|
|
2524
2568
|
configs2.push(new CssConfig({ ...factoryConfig(optionsCss) }).rules());
|
|
2525
2569
|
}
|
|
2526
|
-
if (optionsMarkdown) {
|
|
2527
|
-
configs2.push(new MarkdownConfig({ ...factoryConfig(optionsMarkdown) }).rules());
|
|
2528
|
-
}
|
|
2529
2570
|
if (optionsGraphql) {
|
|
2530
2571
|
configs2.push(new GraphqlConfig().rules());
|
|
2531
2572
|
}
|
|
@@ -2552,6 +2593,9 @@ async function exbotanical({
|
|
|
2552
2593
|
new YamlConfig({ ...factoryConfig(optionsYaml), ...optionsStyle }).rules()
|
|
2553
2594
|
);
|
|
2554
2595
|
}
|
|
2596
|
+
if (optionsMarkdown) {
|
|
2597
|
+
configs2.push(new MarkdownConfig({ ...factoryConfig(optionsMarkdown) }).rules());
|
|
2598
|
+
}
|
|
2555
2599
|
configs2.push(
|
|
2556
2600
|
new DataFilesConfig({
|
|
2557
2601
|
files: [
|
package/package.json
CHANGED