ko-lints 1.0.0-alpha.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -4,6 +4,7 @@ const constants_1 = require("./constants");
4
4
  const utils_1 = require("./utils");
5
5
  const prettier_1 = require("./prettier");
6
6
  const eslint_1 = require("./eslint");
7
+ const stylelint_1 = require("./stylelint");
7
8
  function initKoLintCli(program) {
8
9
  program
9
10
  .command('prettier [patterns]')
@@ -28,5 +29,15 @@ function initKoLintCli(program) {
28
29
  const targetFiles = utils_1.getTargetFiles(patterns, opts.ignorePath);
29
30
  eslint_1.formatFilesWithEslint({ targetFiles, ...opts });
30
31
  });
32
+ program
33
+ .command('stylelint [patterns]')
34
+ .description('use stylelint to format your codes')
35
+ .option('-f, --fix', 'Automatically fix problems')
36
+ .option('-c, --config <configPath>', 'specify eslint config path')
37
+ .option('--ignore-path <ignorePath>', 'specify prettier ignore path')
38
+ .action((patterns = constants_1.defaultPatterns, opts) => {
39
+ const targetFiles = utils_1.getTargetFiles(patterns, opts.ignorePath);
40
+ stylelint_1.formatFilesWithStylelint({ targetFiles, ...opts });
41
+ });
31
42
  }
32
43
  exports.default = initKoLintCli;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.formatFilesWithStylelint = void 0;
23
+ const utils_1 = require("./utils");
24
+ const stylelint = __importStar(require("stylelint"));
25
+ async function formatFilesWithStylelint(opts) {
26
+ const { configPath, fix, targetFiles } = opts;
27
+ const config = configPath
28
+ ? require(utils_1.findRealPath(configPath))
29
+ : require('ko-config/stylelint');
30
+ console.log('stylelint process starting...');
31
+ try {
32
+ let options = {};
33
+ options.files = (targetFiles === null || targetFiles === void 0 ? void 0 : targetFiles.length) ? targetFiles : (config.files || []);
34
+ const result = await stylelint.lint({
35
+ fix,
36
+ config,
37
+ ...options
38
+ });
39
+ if (result.errored) {
40
+ const resultText = stylelint.formatters.string(result.results);
41
+ console.log('Not all matched style files are linted: ');
42
+ console.log(resultText);
43
+ }
44
+ else {
45
+ console.log('All matched style files has been fixed successfully!');
46
+ }
47
+ return true;
48
+ }
49
+ catch (ex) {
50
+ console.log('stylelint failed: ', ex);
51
+ }
52
+ }
53
+ exports.formatFilesWithStylelint = formatFilesWithStylelint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ko-lints",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0",
4
4
  "description": "lint tools used by ko",
5
5
  "keywords": [
6
6
  "ko",
@@ -37,10 +37,10 @@
37
37
  "@types/prettier": "^2.3.2",
38
38
  "commander": "^8.1.0",
39
39
  "fast-glob": "^3.2.7",
40
- "ko-config": "^1.0.0-alpha.2"
40
+ "ko-config": "^1.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "typescript": "^4.3.5"
44
44
  },
45
- "gitHead": "3475f6b659fbde6d6149c34e75678c37ecad6345"
45
+ "gitHead": "3ce5dfb8cb7b50b758ebe6fa0ebfba7a89667a07"
46
46
  }