@pi-r/stylelint 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +24 -13
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
- const Document = require("@e-mc/document");
2
+
3
+ const Document = require('@e-mc/document');
3
4
  async function transform(context, value, options) {
4
5
  context = options.upgrade(context, __dirname);
5
6
  const { pathname, filename } = options;
6
7
  const baseConfig = options.toBaseConfig();
7
8
  const timeStamp = Date.now();
8
- const report = await context.lint('config' in baseConfig ? (baseConfig.code = value, baseConfig) : {
9
+ const lint = await context.lint('config' in baseConfig ? (baseConfig.code = value, baseConfig) : {
9
10
  code: value,
10
11
  config: Object.keys(baseConfig).length > 0 ? baseConfig : undefined,
11
12
  cwd: process.env.STYLELINT_OPTIONS_CWD,
@@ -15,19 +16,29 @@ async function transform(context, value, options) {
15
16
  fix: baseConfig.fix ?? process.env.STYLELINT_OPTIONS_FIX === 'true',
16
17
  formatter: baseConfig.formatter ?? process.env.STYLELINT_OPTIONS_FORMATTER
17
18
  });
18
- const result = report.results[0];
19
- if (result?.warnings.length) {
20
- options.out[Document.hasLogType(32768) ? 'logQueued' : 'logAppend'] = Document.generateLintTable(result.warnings.map(item => ({
21
- ruleId: item.rule,
22
- line: item.line,
23
- column: item.column,
24
- message: item.text,
25
- severity: item.severity
26
- })), { leadingText: 'stylelint', pathname, filename, trailingText: 'https://stylelint.io/user-guide/rules', timeStamp });
19
+ const result = lint.results[0];
20
+ result?.deprecations.forEach(item => options.addLog(options.statusType.INFO, item.text, 'stylelint', 'deprecated'));
21
+ if (process.env.STYLELINT_REPORT && lint?.report) {
22
+ console[lint.errored ? 'error' : 'log'](lint.report);
27
23
  }
28
24
  else {
29
- options.out.messageAppend = ` -> valid(${!result || report.errored ? 'NO' : 'YES'})`;
25
+ if (lint.errored) {
26
+ options.addLog(options.statusType.ERROR, lint.report, 'stylelint');
27
+ }
28
+ if (result?.warnings.length) {
29
+ options.out[Document.hasLogType(32768) ? 'logQueued' : 'logAppend'] = Document.generateLintTable(result.warnings.map(item => ({
30
+ ruleId: item.rule,
31
+ line: item.line,
32
+ column: item.column,
33
+ message: item.text,
34
+ severity: item.severity
35
+ })), { leadingText: 'stylelint', pathname, filename, trailingText: 'https://stylelint.io/user-guide/rules', timeStamp });
36
+ }
37
+ else {
38
+ options.out.messageAppend = ` -> valid(${!result || lint.errored ? 'NO' : 'YES'})`;
39
+ }
30
40
  }
31
- return report?.code || value;
41
+ return lint?.code || value;
32
42
  }
43
+
33
44
  module.exports = transform;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-r/stylelint",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
4
4
  "description": "Stylelint transform function for E-mc.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -19,8 +19,8 @@
19
19
  "license": "MIT",
20
20
  "homepage": "https://github.com/anpham6/pi-r#readme",
21
21
  "dependencies": {
22
- "@e-mc/document": "^0.13.9",
23
- "stylelint": "^16.26.1",
24
- "stylelint-config-standard": "^39.0.1"
22
+ "@e-mc/document": "^0.14.0",
23
+ "stylelint": "^17.9.1",
24
+ "stylelint-config-standard": "^40.0.0"
25
25
  }
26
26
  }