Skip to content

Commit

Permalink
Merge pull request #1993 from ember-template-lint/decay-by-rule
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Jun 16, 2021
2 parents 0acfbea + b5a31bd commit 55e92c9
Show file tree
Hide file tree
Showing 6 changed files with 790 additions and 618 deletions.
32 changes: 23 additions & 9 deletions bin/ember-template-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const fs = require('fs');
const path = require('path');
const { promisify } = require('util');

const { getTodoStorageDirPath, getTodoConfig } = require('@ember-template-lint/todo-utils');
const {
getTodoStorageDirPath,
getTodoConfig,
validateConfig,
} = require('@ember-template-lint/todo-utils');
const chalk = require('chalk');
const getStdin = require('get-stdin');
const globby = require('globby');
Expand Down Expand Up @@ -296,14 +300,6 @@ async function run() {
let positional = options._;
let config;
let isOverridingConfig = _isOverridingConfig(options);
let todoInfo = {
added: 0,
removed: 0,
todoConfig: getTodoConfig(
options.workingDirectory,
getTodoConfigFromCommandLineOptions(options)
),
};

if (options.config) {
try {
Expand All @@ -319,7 +315,25 @@ async function run() {
options.configPath = false;
}

let todoConfigResult = validateConfig(options.workingDirectory);

if (!todoConfigResult.isValid) {
console.error(todoConfigResult.message);
process.exitCode = 1;
return;
}

let linter;
let todoInfo = {
added: 0,
removed: 0,
todoConfig: getTodoConfig(
options.workingDirectory,
'ember-template-lint',
getTodoConfigFromCommandLineOptions(options)
),
};

try {
linter = new Linter({
workingDir: options.workingDirectory,
Expand Down
12 changes: 6 additions & 6 deletions lib/formatters/pretty.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ class PrettyPrinter {
todoSummary += `, ${todoInfo.removed} todos removed`;
}

if (todoInfo.todoConfig) {
let todoConfig = todoInfo.todoConfig;
if (todoInfo.todoConfig && todoInfo.todoConfig.daysToDecay) {
let daysToDecay = todoInfo.todoConfig.daysToDecay;
let todoConfigSummary = [];

if (todoConfig.warn) {
todoConfigSummary.push(`warn after ${todoConfig.warn}`);
if (daysToDecay.warn) {
todoConfigSummary.push(`warn after ${daysToDecay.warn}`);
}

if (todoConfig.error) {
todoConfigSummary.push(`error after ${todoConfig.error}`);
if (daysToDecay.error) {
todoConfigSummary.push(`error after ${daysToDecay.error}`);
}

if (todoConfigSummary.length) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
]
},
"dependencies": {
"@ember-template-lint/todo-utils": "^8.1.0",
"@ember-template-lint/todo-utils": "^9.1.2",
"chalk": "^4.1.1",
"date-fns": "^2.22.1",
"ember-template-recast": "^5.0.3",
Expand Down
Loading

0 comments on commit 55e92c9

Please sign in to comment.