@plugjs/eslint 0.6.117 → 0.7.1

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/eslint.d.ts CHANGED
@@ -6,3 +6,4 @@ export declare class ESLint implements Plug<void> {
6
6
  constructor(...arg: PipeParameters<'eslint'>);
7
7
  pipe(files: Files, context: Context): Promise<void>;
8
8
  }
9
+ //# sourceMappingURL=eslint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint.d.ts","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAGtE,mDAAmD;AACnD,qBAAa,MAAO,YAAW,IAAI,CAAC,IAAI,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;gBAEtC,GAAG,GAAG,EAAE,cAAc,CAAC,QAAQ,CAAC;IAKtC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA4F1D"}
package/dist/eslint.js ADDED
@@ -0,0 +1,74 @@
1
+ import { assert } from '@plugjs/plug';
2
+ import { $grn, $gry, $p, $ylw, ERROR, WARN } from '@plugjs/plug/logging';
3
+ import { getCurrentWorkingDirectory, resolveAbsolutePath, resolveDirectory, resolveFile } from '@plugjs/plug/paths';
4
+ import { ESLint as RealESLint } from 'eslint';
5
+ /** Runner implementation for the `ESLint` plug. */
6
+ export class ESLint {
7
+ _options;
8
+ constructor(arg = {}) {
9
+ this._options = typeof arg === 'string' ? { configFile: arg } : arg;
10
+ }
11
+ async pipe(files, context) {
12
+ const { directory, configFile, ingoreDeprecatedRules, warnIgnored, cacheLocation, cache, } = this._options;
13
+ const cwd = directory ? context.resolve(directory) : getCurrentWorkingDirectory();
14
+ assert(resolveDirectory(cwd), `ESLint directory ${$p(cwd)} does not exist`);
15
+ const overrideConfigFile = configFile ? context.resolve(configFile) : undefined;
16
+ if (overrideConfigFile) {
17
+ assert(resolveFile(overrideConfigFile), `ESLint configuration ${$p(overrideConfigFile)} does not exist`);
18
+ }
19
+ /* Create our ESLint instance */
20
+ const eslint = new RealESLint({
21
+ globInputPaths: false, // we already have all globs resolved
22
+ overrideConfigFile, // if any override config file was supplied...
23
+ cwd, // current working directory for eslint (where everything starts)
24
+ warnIgnored: !!warnIgnored, // warn when trying to lint ignored files
25
+ cacheLocation: context.resolve(cacheLocation || '.eslintcache'), // cache
26
+ cache: !!cache, // enable caching of eslint results or not
27
+ });
28
+ /* Lint all files */
29
+ const results = await eslint.lintFiles([...files.absolutePaths()]);
30
+ /* Create our report */
31
+ const report = context.log.report('ESLint Report');
32
+ /* Keep an eye on deprecated rules */
33
+ const deprecated = {};
34
+ /* Convert ESLint results into our report records */
35
+ for (const result of results) {
36
+ const { filePath, source, messages } = result;
37
+ const file = resolveAbsolutePath(getCurrentWorkingDirectory(), filePath);
38
+ for (const deprecation of result.usedDeprecatedRules) {
39
+ deprecated[deprecation.ruleId] = deprecation.replacedBy;
40
+ }
41
+ for (const record of messages) {
42
+ const { severity, message: msg, ruleId: tags, suggestions = [], line, column, endLine = line, endColumn = column + 1, } = record;
43
+ const message = [msg];
44
+ for (const suggestion of suggestions) {
45
+ message.push(`- ${suggestion.desc}`);
46
+ }
47
+ /* Severity: 0 => off, 1 => warn, 2 => error */
48
+ const level = severity < 2 ? WARN : ERROR;
49
+ /* Characters (length of -1 is until EOL) */
50
+ const length = endLine === line ? endColumn - column : -1;
51
+ /* Add our report */
52
+ report.add({ level, message, tags, line, column, length, file, source });
53
+ }
54
+ }
55
+ /* Report ESLint deprecated rules */
56
+ if (!ingoreDeprecatedRules) {
57
+ for (const [rule, replacedBy] of Object.entries(deprecated)) {
58
+ if (replacedBy.length) {
59
+ const replacements = replacedBy.map($grn);
60
+ replacements.unshift('');
61
+ const repl = replacements.join(`\n${$gry('*')} `);
62
+ report.add({ level: WARN, message: `Rule ${$ylw(rule)} was deprecated and replaced by ${repl}` });
63
+ }
64
+ else {
65
+ report.add({ level: WARN, message: `Rule ${$ylw(rule)} was deprecated without replacement` });
66
+ }
67
+ }
68
+ }
69
+ /* Emit our report and fail on errors */
70
+ report.done(this._options.showSources);
71
+ context.log.notice('ESLint processed', files.length, 'files');
72
+ }
73
+ }
74
+ //# sourceMappingURL=eslint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../src/eslint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AACxE,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACnH,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAA;AAM7C,mDAAmD;AACnD,MAAM,OAAO,MAAM;IACA,QAAQ,CAAyB;IAGlD,YAAY,MAA8B,EAAE;QAC1C,IAAI,CAAC,QAAQ,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;IACrE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAY,EAAE,OAAgB;QACvC,MAAM,EACJ,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,KAAK,GACN,GAAG,IAAI,CAAC,QAAQ,CAAA;QAEjB,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,0BAA0B,EAA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G,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;oBACzC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;oBACxB,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;oBACjD,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC,IAAI,CAAC,mCAAmC,IAAI,EAAE,EAAE,CAAC,CAAA;gBACnG,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC,IAAI,CAAC,qCAAqC,EAAE,CAAC,CAAA;gBAC/F,CAAC;YACH,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;QACtC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/D,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -7,6 +7,10 @@ export interface ESLintOptions {
7
7
  ingoreDeprecatedRules?: boolean;
8
8
  /** Warn when trying to lint ignored files (default: `false`) */
9
9
  warnIgnored?: boolean;
10
+ /** Whether to cache linting results or not (default: `false`) */
11
+ cache?: boolean;
12
+ /** The file where caching results should be kept (default: `.eslintcache`) */
13
+ cacheLocation?: string;
10
14
  /**
11
15
  * ESLint's _override_ configuration file: configurations specified in this
12
16
  * file will override any other configuration specified elsewhere.
@@ -36,3 +40,4 @@ declare module '@plugjs/plug' {
36
40
  eslint(options: ESLintOptions): Promise<undefined>;
37
41
  }
38
42
  }
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,gDAAgD;IAChD,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,gEAAgE;IAChE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAiB,IAAI;QACnB;;;WAGG;QACH,MAAM,IAAI,OAAO,CAAC,SAAS,CAAC,CAAA;QAE5B;;;;;;WAMG;QACH,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;QAE9C;;;;WAIG;QACH,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;KACnD;CACF"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { installForking } from '@plugjs/plug/fork';
2
+ import { requireResolve } from '@plugjs/plug/paths';
3
+ installForking('eslint', requireResolve(import.meta.filename, './eslint'), 'ESLint');
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAgDnD,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,QAAQ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,39 +1,29 @@
1
1
  {
2
2
  "name": "@plugjs/eslint",
3
- "version": "0.6.117",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
- "main": "./dist/index.cjs",
6
- "module": "./dist/index.mjs",
5
+ "main": "./dist/index.js",
7
6
  "types": "./dist/index.d.ts",
8
7
  "exports": {
9
8
  ".": {
10
- "require": {
11
- "types": "./dist/index.d.ts",
12
- "default": "./dist/index.cjs"
13
- },
14
- "import": {
15
- "types": "./dist/index.d.ts",
16
- "default": "./dist/index.mjs"
17
- }
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
18
11
  },
19
12
  "./eslint": {
20
- "require": {
21
- "types": "./dist/eslint.d.ts",
22
- "default": "./dist/eslint.cjs"
23
- },
24
- "import": {
25
- "types": "./dist/eslint.d.ts",
26
- "default": "./dist/eslint.mjs"
27
- }
13
+ "types": "./dist/eslint.d.ts",
14
+ "default": "./dist/eslint.js"
28
15
  }
29
16
  },
30
17
  "author": "Juit Developers <developers@juit.com>",
31
18
  "license": "Apache-2.0",
19
+ "engines": {
20
+ "node": ">=22.16.0"
21
+ },
32
22
  "dependencies": {
33
23
  "eslint": "^10.8.0"
34
24
  },
35
25
  "peerDependencies": {
36
- "@plugjs/plug": "0.6.117"
26
+ "@plugjs/plug": "0.7.1"
37
27
  },
38
28
  "files": [
39
29
  "*.md",
@@ -42,7 +32,7 @@
42
32
  ],
43
33
  "repository": {
44
34
  "type": "git",
45
- "url": "git+ssh://git@github.com/plugjs/plug.git"
35
+ "url": "git+https://github.com/plugjs/plug.git"
46
36
  },
47
37
  "keywords": [
48
38
  "build",
package/src/eslint.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { assert } from '@plugjs/plug'
2
- import { BuildFailure } from '@plugjs/plug/asserts'
3
- import { readFile } from '@plugjs/plug/fs'
4
- import { $p, $grn, $ylw, ERROR, WARN, $gry } from '@plugjs/plug/logging'
2
+ import { $grn, $gry, $p, $ylw, ERROR, WARN } from '@plugjs/plug/logging'
5
3
  import { getCurrentWorkingDirectory, resolveAbsolutePath, resolveDirectory, resolveFile } from '@plugjs/plug/paths'
6
4
  import { ESLint as RealESLint } from 'eslint'
7
5
 
8
6
  import type { Files } from '@plugjs/plug/files'
9
7
  import type { Context, PipeParameters, Plug } from '@plugjs/plug/pipe'
10
- import type { ESLintOptions } from './index'
8
+ import type { ESLintOptions } from './index.ts'
11
9
 
12
10
  /** Runner implementation for the `ESLint` plug. */
13
11
  export class ESLint implements Plug<void> {
@@ -19,7 +17,14 @@ export class ESLint implements Plug<void> {
19
17
  }
20
18
 
21
19
  async pipe(files: Files, context: Context): Promise<void> {
22
- const { directory, configFile, ingoreDeprecatedRules, warnIgnored } = this._options
20
+ const {
21
+ directory,
22
+ configFile,
23
+ ingoreDeprecatedRules,
24
+ warnIgnored,
25
+ cacheLocation,
26
+ cache,
27
+ } = this._options
23
28
 
24
29
  const cwd = directory ? context.resolve(directory) : getCurrentWorkingDirectory()
25
30
  assert(resolveDirectory(cwd), `ESLint directory ${$p(cwd)} does not exist`)
@@ -34,38 +39,13 @@ export class ESLint implements Plug<void> {
34
39
  globInputPaths: false, // we already have all globs resolved
35
40
  overrideConfigFile, // if any override config file was supplied...
36
41
  cwd, // current working directory for eslint (where everything starts)
42
+ warnIgnored: !! warnIgnored, // warn when trying to lint ignored files
43
+ cacheLocation: context.resolve(cacheLocation || '.eslintcache'), // cache
44
+ cache: !! cache, // enable caching of eslint results or not
37
45
  })
38
46
 
39
- /* Lint all files in parallel */
40
- const paths = [ ...files.absolutePaths() ]
41
- const promises = paths.map(async (filePath) => {
42
- const code = await readFile(filePath, 'utf-8')
43
- return eslint.lintText(code, { filePath, warnIgnored: !!warnIgnored })
44
- })
45
-
46
- /* Await for all promises to be settled */
47
- const settlements = await Promise.allSettled(promises)
48
-
49
- /* Run through all promises settlements */
50
- const summary = settlements.reduce((summary, settlement, i) => {
51
- /* Promise rejected, meaining hard failure */
52
- if (settlement.status === 'rejected') {
53
- context.log.error('Error linting', $p(paths[i]!), settlement.reason)
54
- summary.failures ++
55
- return summary
56
- }
57
-
58
- /* Push all our results in the summary */
59
- summary.results.push(...settlement.value)
60
- return summary
61
- }, {
62
- results: [] as RealESLint.LintResult[],
63
- failures: 0,
64
- })
65
-
66
- /* In case of failures from promises, fail! */
67
- const { results, failures } = summary
68
- if (failures) throw BuildFailure.fail()
47
+ /* Lint all files */
48
+ const results = await eslint.lintFiles([ ...files.absolutePaths() ])
69
49
 
70
50
  /* Create our report */
71
51
  const report = context.log.report('ESLint Report')
package/src/index.ts CHANGED
@@ -10,6 +10,10 @@ export interface ESLintOptions {
10
10
  ingoreDeprecatedRules?: boolean
11
11
  /** Warn when trying to lint ignored files (default: `false`) */
12
12
  warnIgnored?: boolean
13
+ /** Whether to cache linting results or not (default: `false`) */
14
+ cache?: boolean
15
+ /** The file where caching results should be kept (default: `.eslintcache`) */
16
+ cacheLocation?: string
13
17
  /**
14
18
  * ESLint's _override_ configuration file: configurations specified in this
15
19
  * file will override any other configuration specified elsewhere.
@@ -43,4 +47,4 @@ declare module '@plugjs/plug' {
43
47
  }
44
48
  }
45
49
 
46
- installForking('eslint', requireResolve(__fileurl, './eslint'), 'ESLint')
50
+ installForking('eslint', requireResolve(import.meta.filename, './eslint'), 'ESLint')
package/dist/eslint.cjs DELETED
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // eslint.ts
21
- var eslint_exports = {};
22
- __export(eslint_exports, {
23
- ESLint: () => ESLint
24
- });
25
- module.exports = __toCommonJS(eslint_exports);
26
- var import_plug = require("@plugjs/plug");
27
- var import_asserts = require("@plugjs/plug/asserts");
28
- var import_fs = require("@plugjs/plug/fs");
29
- var import_logging = require("@plugjs/plug/logging");
30
- var import_paths = require("@plugjs/plug/paths");
31
- var import_eslint = require("eslint");
32
- var ESLint = class {
33
- _options;
34
- constructor(arg = {}) {
35
- this._options = typeof arg === "string" ? { configFile: arg } : arg;
36
- }
37
- async pipe(files, context) {
38
- const { directory, configFile, ingoreDeprecatedRules, warnIgnored } = this._options;
39
- const cwd = directory ? context.resolve(directory) : (0, import_paths.getCurrentWorkingDirectory)();
40
- (0, import_plug.assert)((0, import_paths.resolveDirectory)(cwd), `ESLint directory ${(0, import_logging.$p)(cwd)} does not exist`);
41
- const overrideConfigFile = configFile ? context.resolve(configFile) : void 0;
42
- if (overrideConfigFile) {
43
- (0, import_plug.assert)((0, import_paths.resolveFile)(overrideConfigFile), `ESLint configuration ${(0, import_logging.$p)(overrideConfigFile)} does not exist`);
44
- }
45
- const eslint = new import_eslint.ESLint({
46
- globInputPaths: false,
47
- // we already have all globs resolved
48
- overrideConfigFile,
49
- // if any override config file was supplied...
50
- cwd
51
- // current working directory for eslint (where everything starts)
52
- });
53
- const paths = [...files.absolutePaths()];
54
- const promises = paths.map(async (filePath) => {
55
- const code = await (0, import_fs.readFile)(filePath, "utf-8");
56
- return eslint.lintText(code, { filePath, warnIgnored: !!warnIgnored });
57
- });
58
- const settlements = await Promise.allSettled(promises);
59
- const summary = settlements.reduce((summary2, settlement, i) => {
60
- if (settlement.status === "rejected") {
61
- context.log.error("Error linting", (0, import_logging.$p)(paths[i]), settlement.reason);
62
- summary2.failures++;
63
- return summary2;
64
- }
65
- summary2.results.push(...settlement.value);
66
- return summary2;
67
- }, {
68
- results: [],
69
- failures: 0
70
- });
71
- const { results, failures } = summary;
72
- if (failures) throw import_asserts.BuildFailure.fail();
73
- const report = context.log.report("ESLint Report");
74
- const deprecated = {};
75
- for (const result of results) {
76
- const { filePath, source, messages } = result;
77
- const file = (0, import_paths.resolveAbsolutePath)((0, import_paths.getCurrentWorkingDirectory)(), filePath);
78
- for (const deprecation of result.usedDeprecatedRules) {
79
- deprecated[deprecation.ruleId] = deprecation.replacedBy;
80
- }
81
- for (const record of messages) {
82
- const {
83
- severity,
84
- message: msg,
85
- ruleId: tags,
86
- suggestions = [],
87
- line,
88
- column,
89
- endLine = line,
90
- endColumn = column + 1
91
- } = record;
92
- const message = [msg];
93
- for (const suggestion of suggestions) {
94
- message.push(`- ${suggestion.desc}`);
95
- }
96
- const level = severity < 2 ? import_logging.WARN : import_logging.ERROR;
97
- const length = endLine === line ? endColumn - column : -1;
98
- report.add({ level, message, tags, line, column, length, file, source });
99
- }
100
- }
101
- if (!ingoreDeprecatedRules) {
102
- for (const [rule, replacedBy] of Object.entries(deprecated)) {
103
- if (replacedBy.length) {
104
- const replacements = replacedBy.map(import_logging.$grn);
105
- replacements.unshift("");
106
- const repl = replacements.join(`
107
- ${(0, import_logging.$gry)("*")} `);
108
- report.add({ level: import_logging.WARN, message: `Rule ${(0, import_logging.$ylw)(rule)} was deprecated and replaced by ${repl}` });
109
- } else {
110
- report.add({ level: import_logging.WARN, message: `Rule ${(0, import_logging.$ylw)(rule)} was deprecated without replacement` });
111
- }
112
- }
113
- }
114
- report.done(this._options.showSources);
115
- context.log.notice("ESLint processed", files.length, "files");
116
- }
117
- };
118
- // Annotate the CommonJS export names for ESM import in node:
119
- 0 && (module.exports = {
120
- ESLint
121
- });
122
- //# sourceMappingURL=eslint.cjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/eslint.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAuB;AACvB,qBAA6B;AA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Q,qBAAK,IAAI,CAAC,mCAAmC,IAAI,GAAG,CAAC;AAAA,QAClG,OAAO;AACL,iBAAO,IAAI,EAAE,OAAO,qBAAM,SAAS,YAAQ,qBAAK,IAAI,CAAC,sCAAsC,CAAC;AAAA,QAC9F;AAAA,MACF;AAAA,IACF;AAGA,WAAO,KAAK,KAAK,SAAS,WAAW;AACrC,YAAQ,IAAI,OAAO,oBAAoB,MAAM,QAAQ,OAAO;AAAA,EAC9D;AACF;",
5
- "names": ["RealESLint", "summary"]
6
- }
package/dist/eslint.mjs DELETED
@@ -1,97 +0,0 @@
1
- // eslint.ts
2
- import { assert } from "@plugjs/plug";
3
- import { BuildFailure } from "@plugjs/plug/asserts";
4
- import { readFile } from "@plugjs/plug/fs";
5
- import { $p, $grn, $ylw, ERROR, WARN, $gry } from "@plugjs/plug/logging";
6
- import { getCurrentWorkingDirectory, resolveAbsolutePath, resolveDirectory, resolveFile } from "@plugjs/plug/paths";
7
- import { ESLint as RealESLint } from "eslint";
8
- var ESLint = class {
9
- _options;
10
- constructor(arg = {}) {
11
- this._options = typeof arg === "string" ? { configFile: arg } : arg;
12
- }
13
- async pipe(files, context) {
14
- const { directory, configFile, ingoreDeprecatedRules, warnIgnored } = this._options;
15
- const cwd = directory ? context.resolve(directory) : getCurrentWorkingDirectory();
16
- assert(resolveDirectory(cwd), `ESLint directory ${$p(cwd)} does not exist`);
17
- const overrideConfigFile = configFile ? context.resolve(configFile) : void 0;
18
- if (overrideConfigFile) {
19
- assert(resolveFile(overrideConfigFile), `ESLint configuration ${$p(overrideConfigFile)} does not exist`);
20
- }
21
- const eslint = new RealESLint({
22
- globInputPaths: false,
23
- // we already have all globs resolved
24
- overrideConfigFile,
25
- // if any override config file was supplied...
26
- cwd
27
- // current working directory for eslint (where everything starts)
28
- });
29
- const paths = [...files.absolutePaths()];
30
- const promises = paths.map(async (filePath) => {
31
- const code = await readFile(filePath, "utf-8");
32
- return eslint.lintText(code, { filePath, warnIgnored: !!warnIgnored });
33
- });
34
- const settlements = await Promise.allSettled(promises);
35
- const summary = settlements.reduce((summary2, settlement, i) => {
36
- if (settlement.status === "rejected") {
37
- context.log.error("Error linting", $p(paths[i]), settlement.reason);
38
- summary2.failures++;
39
- return summary2;
40
- }
41
- summary2.results.push(...settlement.value);
42
- return summary2;
43
- }, {
44
- results: [],
45
- failures: 0
46
- });
47
- const { results, failures } = summary;
48
- if (failures) throw BuildFailure.fail();
49
- const report = context.log.report("ESLint Report");
50
- const deprecated = {};
51
- for (const result of results) {
52
- const { filePath, source, messages } = result;
53
- const file = resolveAbsolutePath(getCurrentWorkingDirectory(), filePath);
54
- for (const deprecation of result.usedDeprecatedRules) {
55
- deprecated[deprecation.ruleId] = deprecation.replacedBy;
56
- }
57
- for (const record of messages) {
58
- const {
59
- severity,
60
- message: msg,
61
- ruleId: tags,
62
- suggestions = [],
63
- line,
64
- column,
65
- endLine = line,
66
- endColumn = column + 1
67
- } = record;
68
- const message = [msg];
69
- for (const suggestion of suggestions) {
70
- message.push(`- ${suggestion.desc}`);
71
- }
72
- const level = severity < 2 ? WARN : ERROR;
73
- const length = endLine === line ? endColumn - column : -1;
74
- report.add({ level, message, tags, line, column, length, file, source });
75
- }
76
- }
77
- if (!ingoreDeprecatedRules) {
78
- for (const [rule, replacedBy] of Object.entries(deprecated)) {
79
- if (replacedBy.length) {
80
- const replacements = replacedBy.map($grn);
81
- replacements.unshift("");
82
- const repl = replacements.join(`
83
- ${$gry("*")} `);
84
- report.add({ level: WARN, message: `Rule ${$ylw(rule)} was deprecated and replaced by ${repl}` });
85
- } else {
86
- report.add({ level: WARN, message: `Rule ${$ylw(rule)} was deprecated without replacement` });
87
- }
88
- }
89
- }
90
- report.done(this._options.showSources);
91
- context.log.notice("ESLint processed", files.length, "files");
92
- }
93
- };
94
- export {
95
- ESLint
96
- };
97
- //# sourceMappingURL=eslint.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/eslint.ts"],
4
- "mappings": ";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,OAAO,aAAa,KAAK;AAAA,EAAK,KAAK,GAAG,CAAC,GAAG;AAChD,iBAAO,IAAI,EAAE,OAAO,MAAM,SAAS,QAAQ,KAAK,IAAI,CAAC,mCAAmC,IAAI,GAAG,CAAC;AAAA,QAClG,OAAO;AACL,iBAAO,IAAI,EAAE,OAAO,MAAM,SAAS,QAAQ,KAAK,IAAI,CAAC,sCAAsC,CAAC;AAAA,QAC9F;AAAA,MACF;AAAA,IACF;AAGA,WAAO,KAAK,KAAK,SAAS,WAAW;AACrC,YAAQ,IAAI,OAAO,oBAAoB,MAAM,QAAQ,OAAO;AAAA,EAC9D;AACF;",
5
- "names": ["summary"]
6
- }
package/dist/index.cjs DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // index.ts
17
- var index_exports = {};
18
- module.exports = __toCommonJS(index_exports);
19
- var import_fork = require("@plugjs/plug/fork");
20
- var import_paths = require("@plugjs/plug/paths");
21
- (0, import_fork.installForking)("eslint", (0, import_paths.requireResolve)(__filename, "./eslint"), "ESLint");
22
- //# sourceMappingURL=index.cjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAA+B;AAC/B,mBAA+B;AAAA,IA4C/B,4BAAe,cAAU,6BAAe,YAAW,UAAU,GAAG,QAAQ;",
5
- "names": []
6
- }
package/dist/index.mjs DELETED
@@ -1,5 +0,0 @@
1
- // index.ts
2
- import { installForking } from "@plugjs/plug/fork";
3
- import { requireResolve } from "@plugjs/plug/paths";
4
- installForking("eslint", requireResolve(import.meta.url, "./eslint"), "ESLint");
5
- //# sourceMappingURL=index.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.ts"],
4
- "mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AA4C/B,eAAe,UAAU,eAAe,iBAAW,UAAU,GAAG,QAAQ;",
5
- "names": []
6
- }