@powerlines/plugin-eslint 0.8.120 → 0.8.122

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.
@@ -1,2 +1,28 @@
1
- let e=require(`@stryke/path/find`),t=require(`@stryke/path/normalize`),n=function(e){return e[e.Warning=1]=`Warning`,e[e.Error=2]=`Error`,e}({});function r(r,i,a){let o=(0,t.correctPath)((0,e.relative)(r,a));o.startsWith(`.`)||(o=`./${o}`);let s=`\n${o}`;for(let e=0;e<i.length;e++){let{message:t,severity:r,line:a,column:o,ruleId:c}=i[e];s+=`
2
- `,a&&o&&(s=`${s+a.toString()}:${o.toString()} `),r===n.Warning?s+=`Warning: `:s+=`Error: `,s+=t,c&&(s+=` ${c}`)}return s}exports.MessageSeverity=n,exports.formatMessage=r;
1
+ let __stryke_path_find = require("@stryke/path/find");
2
+ let __stryke_path_normalize = require("@stryke/path/normalize");
3
+
4
+ //#region src/helpers/format-message.ts
5
+ let MessageSeverity = /* @__PURE__ */ function(MessageSeverity$1) {
6
+ MessageSeverity$1[MessageSeverity$1["Warning"] = 1] = "Warning";
7
+ MessageSeverity$1[MessageSeverity$1["Error"] = 2] = "Error";
8
+ return MessageSeverity$1;
9
+ }({});
10
+ function formatMessage(dir, messages, filePath) {
11
+ let fileName = (0, __stryke_path_normalize.correctPath)((0, __stryke_path_find.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
+ exports.MessageSeverity = MessageSeverity;
28
+ exports.formatMessage = formatMessage;
@@ -1,2 +1,27 @@
1
- import{relative as e}from"@stryke/path/find";import{correctPath as t}from"@stryke/path/normalize";let n=function(e){return e[e.Warning=1]=`Warning`,e[e.Error=2]=`Error`,e}({});function r(r,i,a){let o=t(e(r,a));o.startsWith(`.`)||(o=`./${o}`);let s=`\n${o}`;for(let e=0;e<i.length;e++){let{message:t,severity:r,line:a,column:o,ruleId:c}=i[e];s+=`
2
- `,a&&o&&(s=`${s+a.toString()}:${o.toString()} `),r===n.Warning?s+=`Warning: `:s+=`Error: `,s+=t,c&&(s+=` ${c}`)}return s}export{n as MessageSeverity,r as formatMessage};
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$1) {
6
+ MessageSeverity$1[MessageSeverity$1["Warning"] = 1] = "Warning";
7
+ MessageSeverity$1[MessageSeverity$1["Error"] = 2] = "Error";
8
+ return MessageSeverity$1;
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 };
@@ -1 +1,4 @@
1
- const e=require(`./format-message.cjs`);exports.MessageSeverity=e.MessageSeverity,exports.formatMessage=e.formatMessage;
1
+ const require_helpers_format_message = require('./format-message.cjs');
2
+
3
+ exports.MessageSeverity = require_helpers_format_message.MessageSeverity;
4
+ exports.formatMessage = require_helpers_format_message.formatMessage;
@@ -1 +1,3 @@
1
- import{MessageSeverity as e,formatMessage as t}from"./format-message.mjs";export{e as MessageSeverity,t as formatMessage};
1
+ import { MessageSeverity, formatMessage } from "./format-message.mjs";
2
+
3
+ export { MessageSeverity, formatMessage };
package/dist/index.cjs CHANGED
@@ -1,2 +1,108 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./helpers/format-message.cjs`);require(`./helpers/index.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/fs/exists`),r=require(`@stryke/fs/get-parent-path`),i=require(`@stryke/fs/package-fns`),a=require(`@stryke/fs/read-file`),o=require(`@stryke/fs/semver-fns`),s=require(`@stryke/path/find`),c=require(`@stryke/type-checks/is-set-object`),l=require(`defu`);function u(u={}){return{name:`eslint`,async config(){return this.log(t.LogLevelLabel.TRACE,"Providing default configuration for the Powerlines `eslint` build plugin."),{lint:{eslint:(0,l.defu)(u,{configFile:(0,r.getParentPath)([`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`eslint.config.mts`,`eslint.config.cts`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.yaml`,`.eslintrc.yml`,`.eslintrc.json`,`.eslintrc`],this.config.projectRoot,{ignoreCase:!0,skipCwd:!1,includeNameInResults:!0}),reportErrorsOnly:!1,maxWarnings:5,fix:!0,outputFile:null,type:`recommended`})}}},async configResolved(){if(!(0,c.isSetObject)(this.packageJson.eslintConfig)&&(!this.config.lint.eslint.configFile||!(0,n.existsSync)(this.config.lint.eslint.configFile)))throw Error(`No ESLint configuration file could be found`);if(this.config.lint.eslint.configFile&&(0,n.existsSync)(this.config.lint.eslint.configFile)){let e=await(0,a.readFile)(this.config.lint.eslint.configFile);if(e?.trim().replace(/\s/g,``)||e?.trim().replace(/\s/g,``)===`---`||e?.trim().replace(/\s/g,``)===`{}`||e?.trim().replace(/\s/g,``)===`module.exports={}`)throw Error(`The ESLint configuration file at "${this.config.lint.eslint.configFile}" is empty`)}if(!(0,i.isPackageExists)(`eslint`,{paths:[this.workspaceConfig.workspaceRoot,this.config.projectRoot]}))throw Error(`ESLint must be installed to use the Powerlines ESLint plugin. Please run: npm install --save-dev eslint`);let e=await this.resolver.import(this.resolver.esmResolve(`eslint`)),t=this.config.lint.eslint.configFile?(0,s.findFileName)(this.config.lint.eslint.configFile).startsWith(`eslint.config.`):!0,r;`loadESLint`in e&&(r=await e.loadESLint({useFlatConfig:t}));let l=(0,o.parseVersion)(r?.version);if(!l||l.compare(`8.57.0`)<0)throw Error(`Error - Your project has an older version of ESLint installed${l?` (${l.major}.${l.minor}.${l.patch})`:``}. Please upgrade to ESLint version 8.57.0 or above`);let u={useEslintrc:!t,baseConfig:{},errorOnUnmatchedPattern:!1,extensions:[`.js`,`.jsx`,`.ts`,`.tsx`],cache:!0};if(l?.compare(`9.0.0`)&&t)for(let e of[`useEslintrc`,`extensions`,`ignorePath`,`reportUnusedDisableDirectives`,`resolvePluginsRelativeTo`,`rulePaths`,`inlineConfig`,`maxWarnings`])e in u&&delete u[e];this.eslint=new r(u)},async lint(){this.log(t.LogLevelLabel.TRACE,`Linting project files with ESLint.`);let n=await this.eslint.lintFiles(this.tsconfig.fileNames.filter(e=>!e.includes(this.artifactsPath)&&!e.includes(`node_modules`))),r=await this.resolver.import(this.resolver.esmResolve(`eslint`)),i;`loadESLint`in r&&(i=await r.loadESLint({useFlatConfig:this.config.lint.eslint.configFile?(0,s.findFileName)(this.config.lint.eslint.configFile).startsWith(`eslint.config.`):!0})),this.config.lint.eslint.fix&&await i.outputFixes(n),this.config.lint.eslint.reportErrorsOnly&&(n=i.getErrorResults(n));let a=n.filter(({messages:e})=>e?.length).map(({messages:t,filePath:n})=>e.formatMessage(this.config.projectRoot,t,n)).join(`
2
- `);this.config.lint.eslint.outputFile?await this.fs.write(this.config.lint.eslint.outputFile,a):this.log(t.LogLevelLabel.INFO,a)}}}var d=u;exports.MessageSeverity=e.MessageSeverity,exports.default=d,exports.formatMessage=e.formatMessage,exports.plugin=u;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+ const require_helpers_format_message = require('./helpers/format-message.cjs');
3
+ require('./helpers/index.cjs');
4
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
5
+ let __stryke_fs_exists = require("@stryke/fs/exists");
6
+ let __stryke_fs_get_parent_path = require("@stryke/fs/get-parent-path");
7
+ let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
8
+ let __stryke_fs_read_file = require("@stryke/fs/read-file");
9
+ let __stryke_fs_semver_fns = require("@stryke/fs/semver-fns");
10
+ let __stryke_path_find = require("@stryke/path/find");
11
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
12
+ let defu = require("defu");
13
+
14
+ //#region src/index.ts
15
+ /**
16
+ * A Powerlines plugin to lint a project's source code with ESLint.
17
+ */
18
+ function plugin(options = {}) {
19
+ return {
20
+ name: "eslint",
21
+ async config() {
22
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `eslint` build plugin.");
23
+ return { lint: { eslint: (0, defu.defu)(options, {
24
+ configFile: (0, __stryke_fs_get_parent_path.getParentPath)([
25
+ "eslint.config.js",
26
+ "eslint.config.mjs",
27
+ "eslint.config.cjs",
28
+ "eslint.config.ts",
29
+ "eslint.config.mts",
30
+ "eslint.config.cts",
31
+ ".eslintrc.js",
32
+ ".eslintrc.cjs",
33
+ ".eslintrc.yaml",
34
+ ".eslintrc.yml",
35
+ ".eslintrc.json",
36
+ ".eslintrc"
37
+ ], this.config.projectRoot, {
38
+ ignoreCase: true,
39
+ skipCwd: false,
40
+ includeNameInResults: true
41
+ }),
42
+ reportErrorsOnly: false,
43
+ maxWarnings: 5,
44
+ fix: true,
45
+ outputFile: null,
46
+ type: "recommended"
47
+ }) } };
48
+ },
49
+ async configResolved() {
50
+ 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");
51
+ else if (this.config.lint.eslint.configFile && (0, __stryke_fs_exists.existsSync)(this.config.lint.eslint.configFile)) {
52
+ const content = await (0, __stryke_fs_read_file.readFile)(this.config.lint.eslint.configFile);
53
+ 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`);
54
+ }
55
+ if (!(0, __stryke_fs_package_fns.isPackageExists)("eslint", { paths: [this.workspaceConfig.workspaceRoot, this.config.projectRoot] })) throw new Error(`ESLint must be installed to use the Powerlines ESLint plugin. Please run: npm install --save-dev eslint`);
56
+ const module$1 = await this.resolver.import(this.resolver.esmResolve("eslint"));
57
+ const useFlatConfig = this.config.lint.eslint.configFile ? (0, __stryke_path_find.findFileName)(this.config.lint.eslint.configFile).startsWith("eslint.config.") : true;
58
+ let ESLint;
59
+ if ("loadESLint" in module$1) ESLint = await module$1.loadESLint({ useFlatConfig });
60
+ const eslintVersion = (0, __stryke_fs_semver_fns.parseVersion)(ESLint?.version);
61
+ 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`);
62
+ const options$1 = {
63
+ useEslintrc: !useFlatConfig,
64
+ baseConfig: {},
65
+ errorOnUnmatchedPattern: false,
66
+ extensions: [
67
+ ".js",
68
+ ".jsx",
69
+ ".ts",
70
+ ".tsx"
71
+ ],
72
+ cache: true
73
+ };
74
+ if (eslintVersion?.compare("9.0.0") && useFlatConfig) {
75
+ for (const option of [
76
+ "useEslintrc",
77
+ "extensions",
78
+ "ignorePath",
79
+ "reportUnusedDisableDirectives",
80
+ "resolvePluginsRelativeTo",
81
+ "rulePaths",
82
+ "inlineConfig",
83
+ "maxWarnings"
84
+ ]) if (option in options$1) delete options$1[option];
85
+ }
86
+ this.eslint = new ESLint(options$1);
87
+ },
88
+ async lint() {
89
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Linting project files with ESLint.`);
90
+ let results = await this.eslint.lintFiles(this.tsconfig.fileNames.filter((fileName) => !fileName.includes(this.artifactsPath) && !fileName.includes("node_modules")));
91
+ const module$1 = await this.resolver.import(this.resolver.esmResolve("eslint"));
92
+ let ESLint;
93
+ if ("loadESLint" in module$1) ESLint = await module$1.loadESLint({ useFlatConfig: this.config.lint.eslint.configFile ? (0, __stryke_path_find.findFileName)(this.config.lint.eslint.configFile).startsWith("eslint.config.") : true });
94
+ if (this.config.lint.eslint.fix) await ESLint.outputFixes(results);
95
+ if (this.config.lint.eslint.reportErrorsOnly) results = ESLint.getErrorResults(results);
96
+ const output = results.filter(({ messages }) => messages?.length).map(({ messages, filePath }) => require_helpers_format_message.formatMessage(this.config.projectRoot, messages, filePath)).join("\n");
97
+ if (this.config.lint.eslint.outputFile) await this.fs.write(this.config.lint.eslint.outputFile, output);
98
+ else this.log(__storm_software_config_tools_types.LogLevelLabel.INFO, output);
99
+ }
100
+ };
101
+ }
102
+ var src_default = plugin;
103
+
104
+ //#endregion
105
+ exports.MessageSeverity = require_helpers_format_message.MessageSeverity;
106
+ exports.default = src_default;
107
+ exports.formatMessage = require_helpers_format_message.formatMessage;
108
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1,2 +1,104 @@
1
- import{MessageSeverity as e,formatMessage as t}from"./helpers/format-message.mjs";import"./helpers/index.mjs";import{LogLevelLabel as n}from"@storm-software/config-tools/types";import{existsSync as r}from"@stryke/fs/exists";import{getParentPath as i}from"@stryke/fs/get-parent-path";import{isPackageExists as a}from"@stryke/fs/package-fns";import{readFile as o}from"@stryke/fs/read-file";import{parseVersion as s}from"@stryke/fs/semver-fns";import{findFileName as c}from"@stryke/path/find";import{isSetObject as l}from"@stryke/type-checks/is-set-object";import{defu as u}from"defu";function d(e={}){return{name:`eslint`,async config(){return this.log(n.TRACE,"Providing default configuration for the Powerlines `eslint` build plugin."),{lint:{eslint:u(e,{configFile:i([`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`eslint.config.mts`,`eslint.config.cts`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.yaml`,`.eslintrc.yml`,`.eslintrc.json`,`.eslintrc`],this.config.projectRoot,{ignoreCase:!0,skipCwd:!1,includeNameInResults:!0}),reportErrorsOnly:!1,maxWarnings:5,fix:!0,outputFile:null,type:`recommended`})}}},async configResolved(){if(!l(this.packageJson.eslintConfig)&&(!this.config.lint.eslint.configFile||!r(this.config.lint.eslint.configFile)))throw Error(`No ESLint configuration file could be found`);if(this.config.lint.eslint.configFile&&r(this.config.lint.eslint.configFile)){let e=await o(this.config.lint.eslint.configFile);if(e?.trim().replace(/\s/g,``)||e?.trim().replace(/\s/g,``)===`---`||e?.trim().replace(/\s/g,``)===`{}`||e?.trim().replace(/\s/g,``)===`module.exports={}`)throw Error(`The ESLint configuration file at "${this.config.lint.eslint.configFile}" is empty`)}if(!a(`eslint`,{paths:[this.workspaceConfig.workspaceRoot,this.config.projectRoot]}))throw Error(`ESLint must be installed to use the Powerlines ESLint plugin. Please run: npm install --save-dev eslint`);let e=await this.resolver.import(this.resolver.esmResolve(`eslint`)),t=this.config.lint.eslint.configFile?c(this.config.lint.eslint.configFile).startsWith(`eslint.config.`):!0,n;`loadESLint`in e&&(n=await e.loadESLint({useFlatConfig:t}));let i=s(n?.version);if(!i||i.compare(`8.57.0`)<0)throw Error(`Error - Your project has an older version of ESLint installed${i?` (${i.major}.${i.minor}.${i.patch})`:``}. Please upgrade to ESLint version 8.57.0 or above`);let u={useEslintrc:!t,baseConfig:{},errorOnUnmatchedPattern:!1,extensions:[`.js`,`.jsx`,`.ts`,`.tsx`],cache:!0};if(i?.compare(`9.0.0`)&&t)for(let e of[`useEslintrc`,`extensions`,`ignorePath`,`reportUnusedDisableDirectives`,`resolvePluginsRelativeTo`,`rulePaths`,`inlineConfig`,`maxWarnings`])e in u&&delete u[e];this.eslint=new n(u)},async lint(){this.log(n.TRACE,`Linting project files with ESLint.`);let e=await this.eslint.lintFiles(this.tsconfig.fileNames.filter(e=>!e.includes(this.artifactsPath)&&!e.includes(`node_modules`))),r=await this.resolver.import(this.resolver.esmResolve(`eslint`)),i;`loadESLint`in r&&(i=await r.loadESLint({useFlatConfig:this.config.lint.eslint.configFile?c(this.config.lint.eslint.configFile).startsWith(`eslint.config.`):!0})),this.config.lint.eslint.fix&&await i.outputFixes(e),this.config.lint.eslint.reportErrorsOnly&&(e=i.getErrorResults(e));let a=e.filter(({messages:e})=>e?.length).map(({messages:e,filePath:n})=>t(this.config.projectRoot,e,n)).join(`
2
- `);this.config.lint.eslint.outputFile?await this.fs.write(this.config.lint.eslint.outputFile,a):this.log(n.INFO,a)}}}var f=d;export{e as MessageSeverity,f as default,t as formatMessage,d as plugin};
1
+ import { MessageSeverity, formatMessage } from "./helpers/format-message.mjs";
2
+ import "./helpers/index.mjs";
3
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
4
+ import { existsSync } from "@stryke/fs/exists";
5
+ import { getParentPath } from "@stryke/fs/get-parent-path";
6
+ import { isPackageExists } from "@stryke/fs/package-fns";
7
+ import { readFile } from "@stryke/fs/read-file";
8
+ import { parseVersion } from "@stryke/fs/semver-fns";
9
+ import { findFileName } from "@stryke/path/find";
10
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
11
+ import { defu } from "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.log(LogLevelLabel.TRACE, "Providing default configuration for the Powerlines `eslint` build plugin.");
22
+ return { lint: { eslint: defu(options, {
23
+ configFile: 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.projectRoot, {
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 (!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");
50
+ else if (this.config.lint.eslint.configFile && existsSync(this.config.lint.eslint.configFile)) {
51
+ const content = await 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 (!isPackageExists("eslint", { paths: [this.workspaceConfig.workspaceRoot, this.config.projectRoot] })) 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 ? 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 = 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$1 = {
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$1) delete options$1[option];
84
+ }
85
+ this.eslint = new ESLint(options$1);
86
+ },
87
+ async lint() {
88
+ this.log(LogLevelLabel.TRACE, `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 ? 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 }) => formatMessage(this.config.projectRoot, messages, filePath)).join("\n");
96
+ if (this.config.lint.eslint.outputFile) await this.fs.write(this.config.lint.eslint.outputFile, output);
97
+ else this.log(LogLevelLabel.INFO, output);
98
+ }
99
+ };
100
+ }
101
+ var src_default = plugin;
102
+
103
+ //#endregion
104
+ export { MessageSeverity, src_default as default, formatMessage, plugin };
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
328
+ /**
329
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
330
+ *
331
+ * @param code - The source code of the builtin file
332
+ * @param id - The unique identifier of the builtin file
333
+ * @param path - An optional path to write the builtin file to
334
+ * @param options - Additional options for writing the builtin file
335
+ */
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
304
337
  /**
305
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
306
339
  *
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
342
  * @param options - Additional options for writing the entry file
310
343
  */
311
344
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
345
+ /**
346
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
347
+ *
348
+ * @param code - The source code of the entry file
349
+ * @param path - An optional path to write the entry file to
350
+ * @param options - Additional options for writing the entry file
351
+ */
352
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
312
353
  /**
313
354
  * A function to update the context fields using a new user configuration options
314
355
  */
@@ -80,10 +80,18 @@ interface ParseOptions extends ParserOptions {
80
80
  */
81
81
  allowReturnOutsideFunction?: boolean;
82
82
  }
83
+ interface EmitOptions extends WriteOptions {
84
+ /**
85
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
86
+ */
87
+ emitWithBundler?: boolean;
88
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
89
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
90
+ }
83
91
  /**
84
92
  * Options for emitting entry virtual files
85
93
  */
86
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
94
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
87
95
  /**
88
96
  * The unresolved Powerlines context.
89
97
  *
@@ -294,6 +302,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
294
302
  * The Powerlines builtin virtual files
295
303
  */
296
304
  getBuiltins: () => Promise<VirtualFile[]>;
305
+ /**
306
+ * Resolves a file and writes it to the VFS if it does not already exist
307
+ *
308
+ * @param code - The source code of the file
309
+ * @param path - The path to write the file to
310
+ * @param options - Additional options for writing the file
311
+ */
312
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
313
+ /**
314
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
315
+ *
316
+ * @param code - The source code of the file
317
+ * @param path - The path to write the file to
318
+ * @param options - Additional options for writing the file
319
+ */
320
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
297
321
  /**
298
322
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
299
323
  *
@@ -302,7 +326,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
302
326
  * @param path - An optional path to write the builtin file to
303
327
  * @param options - Additional options for writing the builtin file
304
328
  */
305
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
329
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
330
+ /**
331
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
332
+ *
333
+ * @param code - The source code of the builtin file
334
+ * @param id - The unique identifier of the builtin file
335
+ * @param path - An optional path to write the builtin file to
336
+ * @param options - Additional options for writing the builtin file
337
+ */
338
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
306
339
  /**
307
340
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
308
341
  *
@@ -311,6 +344,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
311
344
  * @param options - Additional options for writing the entry file
312
345
  */
313
346
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
347
+ /**
348
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
349
+ *
350
+ * @param code - The source code of the entry file
351
+ * @param path - An optional path to write the entry file to
352
+ * @param options - Additional options for writing the entry file
353
+ */
354
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
314
355
  /**
315
356
  * A function to update the context fields using a new user configuration options
316
357
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-eslint",
3
- "version": "0.8.120",
3
+ "version": "0.8.122",
4
4
  "type": "module",
5
5
  "description": "A package containing a Powerlines plugin for running ESLint on the codebase.",
6
6
  "repository": {
@@ -101,17 +101,17 @@
101
101
  "keywords": ["eslint", "powerlines", "storm-software", "powerlines-plugin"],
102
102
  "dependencies": {
103
103
  "@storm-software/config-tools": "^1.188.74",
104
- "@stryke/fs": "^0.33.26",
105
- "@stryke/path": "^0.24.0",
104
+ "@stryke/fs": "^0.33.27",
105
+ "@stryke/path": "^0.24.1",
106
106
  "defu": "^6.1.4",
107
107
  "eslint": "^9.39.2",
108
- "powerlines": "^0.36.21"
108
+ "powerlines": "^0.36.23"
109
109
  },
110
110
  "devDependencies": {
111
- "@powerlines/nx": "^0.11.47",
111
+ "@powerlines/nx": "^0.11.49",
112
112
  "@storm-software/tsup": "^0.2.72",
113
113
  "@types/node": "^24.10.4"
114
114
  },
115
115
  "publishConfig": { "access": "public" },
116
- "gitHead": "b16324cf857ea5743fd7ad06e18607b1ba32abe0"
116
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
117
117
  }