@powerlines/plugin-eslint 0.8.367 → 0.8.369
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/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/helpers/format-message.cjs +29 -0
- package/dist/helpers/format-message.d.cts +18 -0
- package/dist/helpers/format-message.d.cts.map +1 -0
- package/dist/helpers/format-message.d.mts +18 -0
- package/dist/helpers/format-message.d.mts.map +1 -0
- package/dist/helpers/format-message.mjs +28 -0
- package/dist/helpers/format-message.mjs.map +1 -0
- package/dist/helpers/index.cjs +5 -0
- package/dist/helpers/index.d.cts +2 -0
- package/dist/helpers/index.d.mts +2 -0
- package/dist/helpers/index.mjs +3 -0
- package/dist/index.cjs +106 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +103 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +69 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +69 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _stryke_path_find = require("@stryke/path/find");
|
|
3
|
+
let _stryke_path_normalize = require("@stryke/path/normalize");
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/format-message.ts
|
|
6
|
+
let MessageSeverity = /* @__PURE__ */ function(MessageSeverity) {
|
|
7
|
+
MessageSeverity[MessageSeverity["Warning"] = 1] = "Warning";
|
|
8
|
+
MessageSeverity[MessageSeverity["Error"] = 2] = "Error";
|
|
9
|
+
return MessageSeverity;
|
|
10
|
+
}({});
|
|
11
|
+
function formatMessage(dir, messages, filePath) {
|
|
12
|
+
let fileName = (0, _stryke_path_normalize.correctPath)((0, _stryke_path_find.relative)(dir, filePath));
|
|
13
|
+
if (!fileName.startsWith(".")) fileName = `./${fileName}`;
|
|
14
|
+
let output = `\n${fileName}`;
|
|
15
|
+
for (let i = 0; i < messages.length; i++) {
|
|
16
|
+
const { message, severity, line, column, ruleId } = messages[i];
|
|
17
|
+
output += "\n";
|
|
18
|
+
if (line && column) output = `${output + line.toString()}:${column.toString()} `;
|
|
19
|
+
if (severity === MessageSeverity.Warning) output += `Warning: `;
|
|
20
|
+
else output += `Error: `;
|
|
21
|
+
output += message;
|
|
22
|
+
if (ruleId) output += ` ${ruleId}`;
|
|
23
|
+
}
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.MessageSeverity = MessageSeverity;
|
|
29
|
+
exports.formatMessage = formatMessage;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/helpers/format-message.d.ts
|
|
2
|
+
declare enum MessageSeverity {
|
|
3
|
+
Warning = 1,
|
|
4
|
+
Error = 2
|
|
5
|
+
}
|
|
6
|
+
interface LintMessage {
|
|
7
|
+
ruleId: string | null;
|
|
8
|
+
severity: MessageSeverity;
|
|
9
|
+
message: string;
|
|
10
|
+
line: number;
|
|
11
|
+
column: number;
|
|
12
|
+
}
|
|
13
|
+
declare function formatMessage(dir: string, messages: LintMessage[], filePath: string): string;
|
|
14
|
+
declare type __ΩMessageSeverity = any[];
|
|
15
|
+
declare type __ΩLintMessage = any[];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { LintMessage, MessageSeverity, __ΩLintMessage, __ΩMessageSeverity, formatMessage };
|
|
18
|
+
//# sourceMappingURL=format-message.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-message.d.cts","names":[],"sources":["../../src/helpers/format-message.ts"],"mappings":";aAqBY,eAAA;EACV,OAAA;EACA,KAAA;AAAA;AAAA,UAGe,WAAA;EACf,MAAA;EACA,QAAA,EAAU,eAAA;EACV,OAAA;EACA,IAAA;EACA,MAAA;AAAA;AAAA,iBAGc,aAAA,CACd,GAAA,UACA,QAAA,EAAU,WAAA,IACV,QAAA;AAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/helpers/format-message.d.ts
|
|
2
|
+
declare enum MessageSeverity {
|
|
3
|
+
Warning = 1,
|
|
4
|
+
Error = 2
|
|
5
|
+
}
|
|
6
|
+
interface LintMessage {
|
|
7
|
+
ruleId: string | null;
|
|
8
|
+
severity: MessageSeverity;
|
|
9
|
+
message: string;
|
|
10
|
+
line: number;
|
|
11
|
+
column: number;
|
|
12
|
+
}
|
|
13
|
+
declare function formatMessage(dir: string, messages: LintMessage[], filePath: string): string;
|
|
14
|
+
declare type __ΩMessageSeverity = any[];
|
|
15
|
+
declare type __ΩLintMessage = any[];
|
|
16
|
+
//#endregion
|
|
17
|
+
export { LintMessage, MessageSeverity, __ΩLintMessage, __ΩMessageSeverity, formatMessage };
|
|
18
|
+
//# sourceMappingURL=format-message.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-message.d.mts","names":[],"sources":["../../src/helpers/format-message.ts"],"mappings":";aAqBY,eAAA;EACV,OAAA;EACA,KAAA;AAAA;AAAA,UAGe,WAAA;EACf,MAAA;EACA,QAAA,EAAU,eAAA;EACV,OAAA;EACA,IAAA;EACA,MAAA;AAAA;AAAA,iBAGc,aAAA,CACd,GAAA,UACA,QAAA,EAAU,WAAA,IACV,QAAA;AAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { relative } from "@stryke/path/find";
|
|
2
|
+
import { correctPath } from "@stryke/path/normalize";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/format-message.ts
|
|
5
|
+
let MessageSeverity = /* @__PURE__ */ function(MessageSeverity) {
|
|
6
|
+
MessageSeverity[MessageSeverity["Warning"] = 1] = "Warning";
|
|
7
|
+
MessageSeverity[MessageSeverity["Error"] = 2] = "Error";
|
|
8
|
+
return MessageSeverity;
|
|
9
|
+
}({});
|
|
10
|
+
function formatMessage(dir, messages, filePath) {
|
|
11
|
+
let fileName = correctPath(relative(dir, filePath));
|
|
12
|
+
if (!fileName.startsWith(".")) fileName = `./${fileName}`;
|
|
13
|
+
let output = `\n${fileName}`;
|
|
14
|
+
for (let i = 0; i < messages.length; i++) {
|
|
15
|
+
const { message, severity, line, column, ruleId } = messages[i];
|
|
16
|
+
output += "\n";
|
|
17
|
+
if (line && column) output = `${output + line.toString()}:${column.toString()} `;
|
|
18
|
+
if (severity === MessageSeverity.Warning) output += `Warning: `;
|
|
19
|
+
else output += `Error: `;
|
|
20
|
+
output += message;
|
|
21
|
+
if (ruleId) output += ` ${ruleId}`;
|
|
22
|
+
}
|
|
23
|
+
return output;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { MessageSeverity, formatMessage };
|
|
28
|
+
//# sourceMappingURL=format-message.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-message.mjs","names":[],"sources":["../../src/helpers/format-message.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { relative } from \"@stryke/path/find\";\nimport { correctPath } from \"@stryke/path/normalize\";\n\nexport enum MessageSeverity {\n Warning = 1,\n Error = 2\n}\n\nexport interface LintMessage {\n ruleId: string | null;\n severity: MessageSeverity;\n message: string;\n line: number;\n column: number;\n}\n\nexport function formatMessage(\n dir: string,\n messages: LintMessage[],\n filePath: string\n): string {\n let fileName = correctPath(relative(dir, filePath));\n if (!fileName.startsWith(\".\")) {\n fileName = `./${fileName}`;\n }\n\n let output = `\\n${fileName}`;\n\n for (let i = 0; i < messages.length; i++) {\n const { message, severity, line, column, ruleId } = messages[i]!;\n\n output += \"\\n\";\n\n if (line && column) {\n output = `${output + line.toString()}:${column.toString()} `;\n }\n\n if (severity === MessageSeverity.Warning) {\n output += `Warning: `;\n } else {\n output += `Error: `;\n }\n\n output += message;\n\n if (ruleId) {\n output += ` ${ruleId}`;\n }\n }\n\n return output;\n}\n"],"mappings":";;;;AAqBA,IAAY,kBAAL;AACL;AACA;;KACD;AAUD,SAAgB,cACd,KACA,UACA,UACQ;CACR,IAAI,WAAW,YAAY,SAAS,KAAK,SAAS,CAAC;AACnD,KAAI,CAAC,SAAS,WAAW,IAAI,CAC3B,YAAW,KAAK;CAGlB,IAAI,SAAS,KAAK;AAElB,MAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;EACxC,MAAM,EAAE,SAAS,UAAU,MAAM,QAAQ,WAAW,SAAS;AAE7D,YAAU;AAEV,MAAI,QAAQ,OACV,UAAS,GAAG,SAAS,KAAK,UAAU,CAAC,GAAG,OAAO,UAAU,CAAC;AAG5D,MAAI,aAAa,gBAAgB,QAC/B,WAAU;MAEV,WAAU;AAGZ,YAAU;AAEV,MAAI,OACF,WAAU,KAAK;;AAInB,QAAO"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_helpers_format_message = require('./format-message.cjs');
|
|
3
|
+
|
|
4
|
+
exports.MessageSeverity = require_helpers_format_message.MessageSeverity;
|
|
5
|
+
exports.formatMessage = require_helpers_format_message.formatMessage;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_helpers_format_message = require('./helpers/format-message.cjs');
|
|
3
|
+
require('./helpers/index.cjs');
|
|
4
|
+
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
5
|
+
let _stryke_fs_get_parent_path = require("@stryke/fs/get-parent-path");
|
|
6
|
+
let _stryke_fs_package_fns = require("@stryke/fs/package-fns");
|
|
7
|
+
let _stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
8
|
+
let _stryke_fs_semver_fns = require("@stryke/fs/semver-fns");
|
|
9
|
+
let _stryke_path_find = require("@stryke/path/find");
|
|
10
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
11
|
+
let defu = require("defu");
|
|
12
|
+
|
|
13
|
+
//#region src/index.ts
|
|
14
|
+
/**
|
|
15
|
+
* A Powerlines plugin to lint a project's source code with ESLint.
|
|
16
|
+
*/
|
|
17
|
+
function plugin(options = {}) {
|
|
18
|
+
return {
|
|
19
|
+
name: "eslint",
|
|
20
|
+
async config() {
|
|
21
|
+
this.debug("Providing default configuration for the Powerlines `eslint` build plugin.");
|
|
22
|
+
return { eslint: (0, defu.defu)(options, {
|
|
23
|
+
configFile: (0, _stryke_fs_get_parent_path.getParentPath)([
|
|
24
|
+
"eslint.config.js",
|
|
25
|
+
"eslint.config.mjs",
|
|
26
|
+
"eslint.config.cjs",
|
|
27
|
+
"eslint.config.ts",
|
|
28
|
+
"eslint.config.mts",
|
|
29
|
+
"eslint.config.cts",
|
|
30
|
+
".eslintrc.js",
|
|
31
|
+
".eslintrc.cjs",
|
|
32
|
+
".eslintrc.yaml",
|
|
33
|
+
".eslintrc.yml",
|
|
34
|
+
".eslintrc.json",
|
|
35
|
+
".eslintrc"
|
|
36
|
+
], this.config.root, {
|
|
37
|
+
ignoreCase: true,
|
|
38
|
+
skipCwd: false,
|
|
39
|
+
includeNameInResults: true
|
|
40
|
+
}),
|
|
41
|
+
reportErrorsOnly: false,
|
|
42
|
+
maxWarnings: 5,
|
|
43
|
+
fix: true,
|
|
44
|
+
outputFile: null,
|
|
45
|
+
type: "recommended"
|
|
46
|
+
}) };
|
|
47
|
+
},
|
|
48
|
+
async configResolved() {
|
|
49
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(this.packageJson.eslintConfig) && (!this.config.lint.eslint.configFile || !(0, _stryke_fs_exists.existsSync)(this.config.lint.eslint.configFile))) throw new Error("No ESLint configuration file could be found");
|
|
50
|
+
else if (this.config.lint.eslint.configFile && (0, _stryke_fs_exists.existsSync)(this.config.lint.eslint.configFile)) {
|
|
51
|
+
const content = await (0, _stryke_fs_read_file.readFile)(this.config.lint.eslint.configFile);
|
|
52
|
+
if (content?.trim().replace(/\s/g, "") || content?.trim().replace(/\s/g, "") === "---" || content?.trim().replace(/\s/g, "") === "{}" || content?.trim().replace(/\s/g, "") === "module.exports={}") throw new Error(`The ESLint configuration file at "${this.config.lint.eslint.configFile}" is empty`);
|
|
53
|
+
}
|
|
54
|
+
if (!(0, _stryke_fs_package_fns.isPackageExists)("eslint", { paths: [this.workspaceConfig.workspaceRoot, this.config.root] })) throw new Error(`ESLint must be installed to use the Powerlines ESLint plugin. Please run: npm install --save-dev eslint`);
|
|
55
|
+
const module = await this.resolver.import(this.resolver.esmResolve("eslint"));
|
|
56
|
+
const useFlatConfig = this.config.lint.eslint.configFile ? (0, _stryke_path_find.findFileName)(this.config.lint.eslint.configFile).startsWith("eslint.config.") : true;
|
|
57
|
+
let ESLint;
|
|
58
|
+
if ("loadESLint" in module) ESLint = await module.loadESLint({ useFlatConfig });
|
|
59
|
+
const eslintVersion = (0, _stryke_fs_semver_fns.parseVersion)(ESLint?.version);
|
|
60
|
+
if (!eslintVersion || eslintVersion.compare("8.57.0") < 0) throw new Error(`Error - Your project has an older version of ESLint installed${eslintVersion ? ` (${eslintVersion.major}.${eslintVersion.minor}.${eslintVersion.patch})` : ""}. Please upgrade to ESLint version 8.57.0 or above`);
|
|
61
|
+
const options = {
|
|
62
|
+
useEslintrc: !useFlatConfig,
|
|
63
|
+
baseConfig: {},
|
|
64
|
+
errorOnUnmatchedPattern: false,
|
|
65
|
+
extensions: [
|
|
66
|
+
".js",
|
|
67
|
+
".jsx",
|
|
68
|
+
".ts",
|
|
69
|
+
".tsx"
|
|
70
|
+
],
|
|
71
|
+
cache: true
|
|
72
|
+
};
|
|
73
|
+
if (eslintVersion?.compare("9.0.0") && useFlatConfig) {
|
|
74
|
+
for (const option of [
|
|
75
|
+
"useEslintrc",
|
|
76
|
+
"extensions",
|
|
77
|
+
"ignorePath",
|
|
78
|
+
"reportUnusedDisableDirectives",
|
|
79
|
+
"resolvePluginsRelativeTo",
|
|
80
|
+
"rulePaths",
|
|
81
|
+
"inlineConfig",
|
|
82
|
+
"maxWarnings"
|
|
83
|
+
]) if (option in options) delete options[option];
|
|
84
|
+
}
|
|
85
|
+
this.eslint = new ESLint(options);
|
|
86
|
+
},
|
|
87
|
+
async lint() {
|
|
88
|
+
this.debug("Linting project files with ESLint.");
|
|
89
|
+
let results = await this.eslint.lintFiles(this.tsconfig.fileNames.filter((fileName) => !fileName.includes(this.artifactsPath) && !fileName.includes("node_modules")));
|
|
90
|
+
const module = await this.resolver.import(this.resolver.esmResolve("eslint"));
|
|
91
|
+
let ESLint;
|
|
92
|
+
if ("loadESLint" in module) ESLint = await module.loadESLint({ useFlatConfig: this.config.lint.eslint.configFile ? (0, _stryke_path_find.findFileName)(this.config.lint.eslint.configFile).startsWith("eslint.config.") : true });
|
|
93
|
+
if (this.config.lint.eslint.fix) await ESLint.outputFixes(results);
|
|
94
|
+
if (this.config.lint.eslint.reportErrorsOnly) results = ESLint.getErrorResults(results);
|
|
95
|
+
const output = results.filter(({ messages }) => messages?.length).map(({ messages, filePath }) => require_helpers_format_message.formatMessage(this.config.root, messages, filePath)).join("\n");
|
|
96
|
+
if (this.config.lint.eslint.outputFile) await this.fs.write(this.config.lint.eslint.outputFile, output);
|
|
97
|
+
else this.info(output);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
exports.MessageSeverity = require_helpers_format_message.MessageSeverity;
|
|
104
|
+
exports.default = plugin;
|
|
105
|
+
exports.plugin = plugin;
|
|
106
|
+
exports.formatMessage = require_helpers_format_message.formatMessage;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LintMessage, MessageSeverity, __ΩLintMessage, __ΩMessageSeverity, formatMessage } from "./helpers/format-message.cjs";
|
|
2
|
+
import { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig } from "./types/plugin.cjs";
|
|
3
|
+
import { Plugin } from "powerlines";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare module "powerlines" {
|
|
7
|
+
interface Config {
|
|
8
|
+
eslint?: ESLintPluginOptions;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A Powerlines plugin to lint a project's source code with ESLint.
|
|
13
|
+
*/
|
|
14
|
+
declare function plugin(options?: ESLintPluginOptions): Plugin<ESLintPluginContext>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, LintMessage, MessageSeverity, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig, __ΩLintMessage, __ΩMessageSeverity, plugin as default, plugin, formatMessage };
|
|
17
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAwCY,MAAA;IACR,MAAA,GAAS,mBAAA;EAAA;AAAA;;;;iBAOG,MAAA,CACd,OAAA,GAAS,mBAAA,GACR,MAAA,CAAO,mBAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LintMessage, MessageSeverity, __ΩLintMessage, __ΩMessageSeverity, formatMessage } from "./helpers/format-message.mjs";
|
|
2
|
+
import { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig } from "./types/plugin.mjs";
|
|
3
|
+
import { Plugin } from "powerlines";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare module "powerlines" {
|
|
7
|
+
interface Config {
|
|
8
|
+
eslint?: ESLintPluginOptions;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A Powerlines plugin to lint a project's source code with ESLint.
|
|
13
|
+
*/
|
|
14
|
+
declare function plugin(options?: ESLintPluginOptions): Plugin<ESLintPluginContext>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, LintMessage, MessageSeverity, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig, __ΩLintMessage, __ΩMessageSeverity, plugin as default, plugin, formatMessage };
|
|
17
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;YAwCY,MAAA;IACR,MAAA,GAAS,mBAAA;EAAA;AAAA;;;;iBAOG,MAAA,CACd,OAAA,GAAS,mBAAA,GACR,MAAA,CAAO,mBAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { MessageSeverity, formatMessage } from "./helpers/format-message.mjs";
|
|
2
|
+
import "./helpers/index.mjs";
|
|
3
|
+
import { existsSync } from "@stryke/fs/exists";
|
|
4
|
+
import { getParentPath } from "@stryke/fs/get-parent-path";
|
|
5
|
+
import { isPackageExists } from "@stryke/fs/package-fns";
|
|
6
|
+
import { readFile } from "@stryke/fs/read-file";
|
|
7
|
+
import { parseVersion } from "@stryke/fs/semver-fns";
|
|
8
|
+
import { findFileName } from "@stryke/path/find";
|
|
9
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
10
|
+
import { defu } from "defu";
|
|
11
|
+
|
|
12
|
+
//#region src/index.ts
|
|
13
|
+
/**
|
|
14
|
+
* A Powerlines plugin to lint a project's source code with ESLint.
|
|
15
|
+
*/
|
|
16
|
+
function plugin(options = {}) {
|
|
17
|
+
return {
|
|
18
|
+
name: "eslint",
|
|
19
|
+
async config() {
|
|
20
|
+
this.debug("Providing default configuration for the Powerlines `eslint` build plugin.");
|
|
21
|
+
return { eslint: defu(options, {
|
|
22
|
+
configFile: getParentPath([
|
|
23
|
+
"eslint.config.js",
|
|
24
|
+
"eslint.config.mjs",
|
|
25
|
+
"eslint.config.cjs",
|
|
26
|
+
"eslint.config.ts",
|
|
27
|
+
"eslint.config.mts",
|
|
28
|
+
"eslint.config.cts",
|
|
29
|
+
".eslintrc.js",
|
|
30
|
+
".eslintrc.cjs",
|
|
31
|
+
".eslintrc.yaml",
|
|
32
|
+
".eslintrc.yml",
|
|
33
|
+
".eslintrc.json",
|
|
34
|
+
".eslintrc"
|
|
35
|
+
], this.config.root, {
|
|
36
|
+
ignoreCase: true,
|
|
37
|
+
skipCwd: false,
|
|
38
|
+
includeNameInResults: true
|
|
39
|
+
}),
|
|
40
|
+
reportErrorsOnly: false,
|
|
41
|
+
maxWarnings: 5,
|
|
42
|
+
fix: true,
|
|
43
|
+
outputFile: null,
|
|
44
|
+
type: "recommended"
|
|
45
|
+
}) };
|
|
46
|
+
},
|
|
47
|
+
async configResolved() {
|
|
48
|
+
if (!isSetObject(this.packageJson.eslintConfig) && (!this.config.lint.eslint.configFile || !existsSync(this.config.lint.eslint.configFile))) throw new Error("No ESLint configuration file could be found");
|
|
49
|
+
else if (this.config.lint.eslint.configFile && existsSync(this.config.lint.eslint.configFile)) {
|
|
50
|
+
const content = await readFile(this.config.lint.eslint.configFile);
|
|
51
|
+
if (content?.trim().replace(/\s/g, "") || content?.trim().replace(/\s/g, "") === "---" || content?.trim().replace(/\s/g, "") === "{}" || content?.trim().replace(/\s/g, "") === "module.exports={}") throw new Error(`The ESLint configuration file at "${this.config.lint.eslint.configFile}" is empty`);
|
|
52
|
+
}
|
|
53
|
+
if (!isPackageExists("eslint", { paths: [this.workspaceConfig.workspaceRoot, this.config.root] })) throw new Error(`ESLint must be installed to use the Powerlines ESLint plugin. Please run: npm install --save-dev eslint`);
|
|
54
|
+
const module = await this.resolver.import(this.resolver.esmResolve("eslint"));
|
|
55
|
+
const useFlatConfig = this.config.lint.eslint.configFile ? findFileName(this.config.lint.eslint.configFile).startsWith("eslint.config.") : true;
|
|
56
|
+
let ESLint;
|
|
57
|
+
if ("loadESLint" in module) ESLint = await module.loadESLint({ useFlatConfig });
|
|
58
|
+
const eslintVersion = parseVersion(ESLint?.version);
|
|
59
|
+
if (!eslintVersion || eslintVersion.compare("8.57.0") < 0) throw new Error(`Error - Your project has an older version of ESLint installed${eslintVersion ? ` (${eslintVersion.major}.${eslintVersion.minor}.${eslintVersion.patch})` : ""}. Please upgrade to ESLint version 8.57.0 or above`);
|
|
60
|
+
const options = {
|
|
61
|
+
useEslintrc: !useFlatConfig,
|
|
62
|
+
baseConfig: {},
|
|
63
|
+
errorOnUnmatchedPattern: false,
|
|
64
|
+
extensions: [
|
|
65
|
+
".js",
|
|
66
|
+
".jsx",
|
|
67
|
+
".ts",
|
|
68
|
+
".tsx"
|
|
69
|
+
],
|
|
70
|
+
cache: true
|
|
71
|
+
};
|
|
72
|
+
if (eslintVersion?.compare("9.0.0") && useFlatConfig) {
|
|
73
|
+
for (const option of [
|
|
74
|
+
"useEslintrc",
|
|
75
|
+
"extensions",
|
|
76
|
+
"ignorePath",
|
|
77
|
+
"reportUnusedDisableDirectives",
|
|
78
|
+
"resolvePluginsRelativeTo",
|
|
79
|
+
"rulePaths",
|
|
80
|
+
"inlineConfig",
|
|
81
|
+
"maxWarnings"
|
|
82
|
+
]) if (option in options) delete options[option];
|
|
83
|
+
}
|
|
84
|
+
this.eslint = new ESLint(options);
|
|
85
|
+
},
|
|
86
|
+
async lint() {
|
|
87
|
+
this.debug("Linting project files with ESLint.");
|
|
88
|
+
let results = await this.eslint.lintFiles(this.tsconfig.fileNames.filter((fileName) => !fileName.includes(this.artifactsPath) && !fileName.includes("node_modules")));
|
|
89
|
+
const module = await this.resolver.import(this.resolver.esmResolve("eslint"));
|
|
90
|
+
let ESLint;
|
|
91
|
+
if ("loadESLint" in module) ESLint = await module.loadESLint({ useFlatConfig: this.config.lint.eslint.configFile ? findFileName(this.config.lint.eslint.configFile).startsWith("eslint.config.") : true });
|
|
92
|
+
if (this.config.lint.eslint.fix) await ESLint.outputFixes(results);
|
|
93
|
+
if (this.config.lint.eslint.reportErrorsOnly) results = ESLint.getErrorResults(results);
|
|
94
|
+
const output = results.filter(({ messages }) => messages?.length).map(({ messages, filePath }) => formatMessage(this.config.root, messages, filePath)).join("\n");
|
|
95
|
+
if (this.config.lint.eslint.outputFile) await this.fs.write(this.config.lint.eslint.outputFile, output);
|
|
96
|
+
else this.info(output);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { MessageSeverity, plugin as default, plugin, formatMessage };
|
|
103
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { getParentPath } from \"@stryke/fs/get-parent-path\";\nimport { isPackageExists } from \"@stryke/fs/package-fns\";\nimport { readFile } from \"@stryke/fs/read-file\";\nimport { parseVersion } from \"@stryke/fs/semver-fns\";\nimport { findFileName } from \"@stryke/path/find\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { defu } from \"defu\";\nimport type { ESLint as FlatESLint } from \"eslint\";\nimport type { LegacyESLint } from \"eslint/use-at-your-own-risk\";\nimport { Plugin } from \"powerlines\";\nimport { formatMessage } from \"./helpers/format-message\";\nimport {\n ESLintPluginContext,\n ESLintPluginOptions,\n ESLintPluginResolvedConfig\n} from \"./types/plugin\";\n\nexport * from \"./helpers\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n eslint?: ESLintPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to lint a project's source code with ESLint.\n */\nexport function plugin(\n options: ESLintPluginOptions = {}\n): Plugin<ESLintPluginContext> {\n return {\n name: \"eslint\",\n async config() {\n this.debug(\n \"Providing default configuration for the Powerlines `eslint` build plugin.\"\n );\n\n const configFile = getParentPath(\n [\n \"eslint.config.js\",\n \"eslint.config.mjs\",\n \"eslint.config.cjs\",\n \"eslint.config.ts\",\n \"eslint.config.mts\",\n \"eslint.config.cts\",\n \".eslintrc.js\",\n \".eslintrc.cjs\",\n \".eslintrc.yaml\",\n \".eslintrc.yml\",\n \".eslintrc.json\",\n \".eslintrc\"\n ],\n this.config.root,\n {\n ignoreCase: true,\n skipCwd: false,\n includeNameInResults: true\n }\n );\n\n return {\n eslint: defu(options, {\n configFile,\n reportErrorsOnly: false,\n maxWarnings: 5,\n fix: true,\n outputFile: null,\n type: \"recommended\"\n })\n } as Partial<ESLintPluginResolvedConfig>;\n },\n async configResolved() {\n if (\n !isSetObject(this.packageJson.eslintConfig) &&\n (!this.config.lint.eslint.configFile ||\n !existsSync(this.config.lint.eslint.configFile))\n ) {\n throw new Error(\"No ESLint configuration file could be found\");\n } else if (\n this.config.lint.eslint.configFile &&\n existsSync(this.config.lint.eslint.configFile)\n ) {\n const content = await readFile(this.config.lint.eslint.configFile);\n if (\n content?.trim().replace(/\\s/g, \"\") ||\n content?.trim().replace(/\\s/g, \"\") === \"---\" ||\n content?.trim().replace(/\\s/g, \"\") === \"{}\" ||\n content?.trim().replace(/\\s/g, \"\") === \"module.exports={}\"\n ) {\n throw new Error(\n `The ESLint configuration file at \"${this.config.lint.eslint.configFile}\" is empty`\n );\n }\n }\n\n const isInstalled = isPackageExists(\"eslint\", {\n paths: [this.workspaceConfig.workspaceRoot, this.config.root]\n });\n if (!isInstalled) {\n throw new Error(\n `ESLint must be installed to use the Powerlines ESLint plugin. Please run: npm install --save-dev eslint`\n );\n }\n\n // if (generateReason) {\n // this.log(\n // LogLevelLabel.WARN,\n // `${generateReason}. Generating a default configuration at the project root.`\n // );\n\n // this.devDependencies[\"eslint-config-powerlines\"] = \"*\";\n // this.config.lint.eslint.configFile = joinPaths(\n // this.config.projectRoot,\n // \"eslint.config.js\"\n // );\n\n // await writeFile(\n // this.config.lint.eslint.configFile,\n // `import { defineConfig } from \"eslint-config-powerlines\";\n\n // Error.stackTraceLimit = Number.POSITIVE_INFINITY;\n\n // /** @type {import('eslint').Linter.Config[]} */\n // export default defineConfig({${\n // this.config.name\n // ? `\n // name: \"${this.config.name}\", `\n // : \"\"\n // }\n // powerlines: ${this.config.lint.eslint.type}\n // });\n\n // `\n // );\n // }\n\n const module = await this.resolver.import<typeof import(\"eslint\")>(\n this.resolver.esmResolve(\"eslint\")\n );\n\n const useFlatConfig = this.config.lint.eslint.configFile\n ? findFileName(this.config.lint.eslint.configFile).startsWith(\n \"eslint.config.\"\n )\n : true;\n\n let ESLint!: typeof FlatESLint | typeof LegacyESLint;\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if (\"loadESLint\" in module) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await module.loadESLint({\n useFlatConfig\n });\n }\n\n const eslintVersion = parseVersion(ESLint?.version);\n if (!eslintVersion || eslintVersion.compare(\"8.57.0\") < 0) {\n throw new Error(\n `Error - Your project has an older version of ESLint installed${\n eslintVersion\n ? ` (${eslintVersion.major}.${eslintVersion.minor}.${eslintVersion.patch})`\n : \"\"\n }. Please upgrade to ESLint version 8.57.0 or above`\n );\n }\n\n const options: any = {\n useEslintrc: !useFlatConfig,\n baseConfig: {},\n errorOnUnmatchedPattern: false,\n extensions: [\".js\", \".jsx\", \".ts\", \".tsx\"],\n cache: true\n };\n\n if (eslintVersion?.compare(\"9.0.0\") && useFlatConfig) {\n for (const option of [\n \"useEslintrc\",\n \"extensions\",\n \"ignorePath\",\n \"reportUnusedDisableDirectives\",\n \"resolvePluginsRelativeTo\",\n \"rulePaths\",\n \"inlineConfig\",\n \"maxWarnings\"\n ]) {\n if (option in options) {\n delete options[option];\n }\n }\n }\n\n this.eslint = new ESLint(options);\n },\n async lint() {\n this.debug(\"Linting project files with ESLint.\");\n\n let results = await this.eslint.lintFiles(\n this.tsconfig.fileNames.filter(\n fileName =>\n !fileName.includes(this.artifactsPath) &&\n !fileName.includes(\"node_modules\")\n )\n );\n\n const module = await this.resolver.import<typeof import(\"eslint\")>(\n this.resolver.esmResolve(\"eslint\")\n );\n\n let ESLint!: typeof FlatESLint | typeof LegacyESLint;\n // loadESLint is >= 8.57.0\n // PR https://github.com/eslint/eslint/pull/18098\n // Release https://github.com/eslint/eslint/releases/tag/v8.57.0\n if (\"loadESLint\" in module) {\n // By default, configType is `flat`. If `useFlatConfig` is false, the return value is `LegacyESLint`.\n // https://github.com/eslint/eslint/blob/1def4cdfab1f067c5089df8b36242cdf912b0eb6/lib/types/index.d.ts#L1609-L1613\n ESLint = await module.loadESLint({\n useFlatConfig: this.config.lint.eslint.configFile\n ? findFileName(this.config.lint.eslint.configFile).startsWith(\n \"eslint.config.\"\n )\n : true\n });\n }\n\n if (this.config.lint.eslint.fix) {\n await ESLint.outputFixes(results);\n }\n\n if (this.config.lint.eslint.reportErrorsOnly) {\n results = ESLint.getErrorResults(results);\n }\n\n const resultsWithMessages = results.filter(\n ({ messages }) => messages?.length\n );\n\n const output = resultsWithMessages\n .map(({ messages, filePath }) =>\n formatMessage(this.config.root, messages, filePath)\n )\n .join(\"\\n\");\n\n if (this.config.lint.eslint.outputFile) {\n await this.fs.write(this.config.lint.eslint.outputFile, output);\n } else {\n this.info(output);\n }\n }\n };\n}\n\nexport default plugin;\n"],"mappings":"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"}
|
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig } from "./plugin.cjs";
|
|
2
|
+
export { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig } from "./plugin.mjs";
|
|
2
|
+
export { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
File without changes
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
|
+
import { ESLint } from "eslint";
|
|
3
|
+
import { LegacyESLint } from "eslint/use-at-your-own-risk";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugin.d.ts
|
|
6
|
+
interface ESLintPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The path to the ESLint configuration file.
|
|
9
|
+
*/
|
|
10
|
+
configFile?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to report errors only
|
|
13
|
+
*/
|
|
14
|
+
reportErrorsOnly?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The maximum number of warnings to allow before failing the process
|
|
17
|
+
*/
|
|
18
|
+
maxWarnings?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The output file to write the results to.
|
|
21
|
+
*/
|
|
22
|
+
outputFile?: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to automatically fix problems
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue true
|
|
27
|
+
*/
|
|
28
|
+
fix?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The type of ESLint configuration to use.
|
|
31
|
+
*/
|
|
32
|
+
type?: "base" | "recommended" | "strict";
|
|
33
|
+
/**
|
|
34
|
+
* Options to be passed to the ESLint generator.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* These options will be override any other values passed to the ESLint generator.
|
|
38
|
+
*/
|
|
39
|
+
override?: Partial<ESLint.Options>;
|
|
40
|
+
}
|
|
41
|
+
interface ESLintPluginUserConfig extends UserConfig {
|
|
42
|
+
/**
|
|
43
|
+
* Options for the ESLint plugin.
|
|
44
|
+
*/
|
|
45
|
+
lint?: {
|
|
46
|
+
eslint?: ESLintPluginOptions;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
interface ESLintPluginResolvedConfig extends ResolvedConfig {
|
|
50
|
+
/**
|
|
51
|
+
* Options for the ESLint plugin.
|
|
52
|
+
*/
|
|
53
|
+
lint: {
|
|
54
|
+
eslint: ESLintPluginOptions;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
type ESLintPluginContext<TResolvedConfig extends ESLintPluginResolvedConfig = ESLintPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
|
|
58
|
+
/**
|
|
59
|
+
* The initialized ESLint application.
|
|
60
|
+
*/
|
|
61
|
+
eslint: ESLint | LegacyESLint;
|
|
62
|
+
};
|
|
63
|
+
declare type __ΩESLintPluginOptions = any[];
|
|
64
|
+
declare type __ΩESLintPluginUserConfig = any[];
|
|
65
|
+
declare type __ΩESLintPluginResolvedConfig = any[];
|
|
66
|
+
declare type __ΩESLintPluginContext = any[];
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig };
|
|
69
|
+
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;UAuBiB,mBAAA;EAAA;;;EAIf,UAAA;EAAA;;;EAKA,gBAAA;EAiBA;;;EAZA,WAAA;EAyBmB;;;EApBnB,UAAA;EAuBe;;;;;EAhBf,GAAA;EAqBE;;;EAhBF,IAAA;EAoBe;;;;;;EAZf,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,OAAA;AAAA;AAAA,UAGX,sBAAA,SAA+B,UAAA;EAcjB;AAI/B;;EAdE,IAAA;IACE,MAAA,GAAS,mBAAA;EAAA;AAAA;AAAA,UAII,0BAAA,SAAmC,cAAA;EAgB1C;;;EAZR,IAAA;IACE,MAAA,EAAQ,mBAAA;EAAA;AAAA;AAAA,KAIA,mBAAA,yBACc,0BAAA,GACtB,0BAAA,IACA,aAAA,CAAc,eAAA;EAAA;;;EAIhB,MAAA,EAAQ,MAAA,GAAa,YAAA;AAAA;AAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
|
+
import { ESLint } from "eslint";
|
|
3
|
+
import { LegacyESLint } from "eslint/use-at-your-own-risk";
|
|
4
|
+
|
|
5
|
+
//#region src/types/plugin.d.ts
|
|
6
|
+
interface ESLintPluginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The path to the ESLint configuration file.
|
|
9
|
+
*/
|
|
10
|
+
configFile?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to report errors only
|
|
13
|
+
*/
|
|
14
|
+
reportErrorsOnly?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The maximum number of warnings to allow before failing the process
|
|
17
|
+
*/
|
|
18
|
+
maxWarnings?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The output file to write the results to.
|
|
21
|
+
*/
|
|
22
|
+
outputFile?: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Whether to automatically fix problems
|
|
25
|
+
*
|
|
26
|
+
* @defaultValue true
|
|
27
|
+
*/
|
|
28
|
+
fix?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The type of ESLint configuration to use.
|
|
31
|
+
*/
|
|
32
|
+
type?: "base" | "recommended" | "strict";
|
|
33
|
+
/**
|
|
34
|
+
* Options to be passed to the ESLint generator.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* These options will be override any other values passed to the ESLint generator.
|
|
38
|
+
*/
|
|
39
|
+
override?: Partial<ESLint.Options>;
|
|
40
|
+
}
|
|
41
|
+
interface ESLintPluginUserConfig extends UserConfig {
|
|
42
|
+
/**
|
|
43
|
+
* Options for the ESLint plugin.
|
|
44
|
+
*/
|
|
45
|
+
lint?: {
|
|
46
|
+
eslint?: ESLintPluginOptions;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
interface ESLintPluginResolvedConfig extends ResolvedConfig {
|
|
50
|
+
/**
|
|
51
|
+
* Options for the ESLint plugin.
|
|
52
|
+
*/
|
|
53
|
+
lint: {
|
|
54
|
+
eslint: ESLintPluginOptions;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
type ESLintPluginContext<TResolvedConfig extends ESLintPluginResolvedConfig = ESLintPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
|
|
58
|
+
/**
|
|
59
|
+
* The initialized ESLint application.
|
|
60
|
+
*/
|
|
61
|
+
eslint: ESLint | LegacyESLint;
|
|
62
|
+
};
|
|
63
|
+
declare type __ΩESLintPluginOptions = any[];
|
|
64
|
+
declare type __ΩESLintPluginUserConfig = any[];
|
|
65
|
+
declare type __ΩESLintPluginResolvedConfig = any[];
|
|
66
|
+
declare type __ΩESLintPluginContext = any[];
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ESLintPluginContext, ESLintPluginOptions, ESLintPluginResolvedConfig, ESLintPluginUserConfig, __ΩESLintPluginContext, __ΩESLintPluginOptions, __ΩESLintPluginResolvedConfig, __ΩESLintPluginUserConfig };
|
|
69
|
+
//# sourceMappingURL=plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;UAuBiB,mBAAA;EAAA;;;EAIf,UAAA;EAAA;;;EAKA,gBAAA;EAiBA;;;EAZA,WAAA;EAyBmB;;;EApBnB,UAAA;EAuBe;;;;;EAhBf,GAAA;EAqBE;;;EAhBF,IAAA;EAoBe;;;;;;EAZf,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,OAAA;AAAA;AAAA,UAGX,sBAAA,SAA+B,UAAA;EAcjB;AAI/B;;EAdE,IAAA;IACE,MAAA,GAAS,mBAAA;EAAA;AAAA;AAAA,UAII,0BAAA,SAAmC,cAAA;EAgB1C;;;EAZR,IAAA;IACE,MAAA,EAAQ,mBAAA;EAAA;AAAA;AAAA,KAIA,mBAAA,yBACc,0BAAA,GACtB,0BAAA,IACA,aAAA,CAAc,eAAA;EAAA;;;EAIhB,MAAA,EAAQ,MAAA,GAAa,YAAA;AAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-eslint",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.369",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Powerlines plugin for running ESLint on the codebase.",
|
|
6
6
|
"keywords": ["eslint", "powerlines", "storm-software", "powerlines-plugin"],
|
|
@@ -117,15 +117,15 @@
|
|
|
117
117
|
"types": "./dist/index.d.cts",
|
|
118
118
|
"files": ["dist/**/*"],
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@storm-software/config-tools": "^1.189.
|
|
120
|
+
"@storm-software/config-tools": "^1.189.40",
|
|
121
121
|
"@stryke/fs": "^0.33.63",
|
|
122
122
|
"@stryke/path": "^0.27.2",
|
|
123
123
|
"@stryke/type-checks": "^0.5.41",
|
|
124
124
|
"defu": "^6.1.4",
|
|
125
125
|
"eslint": "^9.39.4",
|
|
126
|
-
"powerlines": "^0.42.
|
|
126
|
+
"powerlines": "^0.42.6"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": { "@types/node": "^25.5.0" },
|
|
129
129
|
"publishConfig": { "access": "public" },
|
|
130
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "af94c1952c9f2d293dac72a2d0ed3627be8d807d"
|
|
131
131
|
}
|