Skip to content

Commit

Permalink
Merge pull request #2207 from bmish/remove-print-pending-option
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Nov 24, 2021
2 parents da65486 + 318e16f commit 9b0b88b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 211 deletions.
65 changes: 11 additions & 54 deletions bin/ember-template-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const {
getTodoConfig,
validateConfig,
} = require('@ember-template-lint/todo-utils');
const chalk = require('chalk');
const ci = require('ci-info');
const getStdin = require('get-stdin');
const globby = require('globby');
Expand Down Expand Up @@ -172,12 +171,6 @@ function parseArgv(_argv) {
'Does not use the local template-lintrc, will use a blank template-lintrc instead',
boolean: true,
},
'print-pending': {
describe:
'Print list of formatted rules for use with `pending` in config file (deprecated)',
boolean: true,
hidden: true,
},
'update-todo': {
describe: 'Update list of linting todos by transforming lint errors to todos',
default: false,
Expand Down Expand Up @@ -241,38 +234,6 @@ function parseArgv(_argv) {
}
}

const PENDING_RULES = new Set(['invalid-pending-module', 'invalid-pending-module-rule']);
function printPending(results, options) {
let pendingList = [];
for (let filePath in results.files) {
let fileResults = results.files[filePath];
let failingRules = fileResults.messages.reduce((memo, error) => {
if (!PENDING_RULES.has(error.rule)) {
memo.add(error.rule);
}

return memo;
}, new Set());

if (failingRules.size > 0) {
pendingList.push({ moduleId: removeExt(filePath), only: [...failingRules] });
}
}
let pendingListString = JSON.stringify(pendingList, null, 2);

if (options.format === 'json') {
console.log(pendingListString);
} else {
console.log(chalk.yellow('WARNING: Print pending is deprecated. Use --update-todo instead.\n'));

console.log(
'Add the following to your `.template-lintrc.js` file to mark these files as pending.\n\n'
);

console.log(`pending: ${pendingListString}`);
}
}

function getTodoConfigFromCommandLineOptions(options) {
let todoConfig = {};

Expand Down Expand Up @@ -451,21 +412,17 @@ async function run() {
process.exitCode = 1;
}

if (options.printPending) {
return printPending(results, options);
} else {
let hasErrors = results.errorCount > 0;
let hasWarnings = results.warningCount > 0;
let hasTodos = options.includeTodo && results.todoCount;
let hasUpdatedTodos = options.updateTodo;

let Printer = require('../lib/formatters/default');
let printer = new Printer({
...options,
hasResultData: hasErrors || hasWarnings || hasTodos || hasUpdatedTodos,
});
printer.print(results, todoInfo);
}
let hasErrors = results.errorCount > 0;
let hasWarnings = results.warningCount > 0;
let hasTodos = options.includeTodo && results.todoCount;
let hasUpdatedTodos = options.updateTodo;

let Printer = require('../lib/formatters/default');
let printer = new Printer({
...options,
hasResultData: hasErrors || hasWarnings || hasTodos || hasUpdatedTodos,
});
printer.print(results, todoInfo);
}

// exports are for easier unit testing
Expand Down
157 changes: 0 additions & 157 deletions test/acceptance/cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1301,163 +1301,6 @@ describe('ember-template-lint executable', function () {
});
});

describe('with --print-pending param', function () {
it('should print a list of pending modules', async function () {
project.setConfig({
rules: {
'no-bare-strings': true,
'no-html-comments': true,
},
pending: [
{
moduleId: 'app/templates/application',
only: ['no-html-comments'],
},
],
});
project.write({
app: {
templates: {
'application.hbs':
'<h2>Here too!!</h2><div>Bare strings are bad...</div><!-- bad html comment! -->',
},
},
});

let result = await run(['.', '--print-pending']);

expect(result.stdout).toMatchInlineSnapshot(`
"WARNING: Print pending is deprecated. Use --update-todo instead.
Add the following to your \`.template-lintrc.js\` file to mark these files as pending.
pending: [
{
\\"moduleId\\": \\"app/templates/application\\",
\\"only\\": [
\\"no-bare-strings\\",
\\"no-html-comments\\"
]
}
]"
`);
expect(result.stderr).toBeFalsy();
});

it('should ignore existing pending modules that have no lint errors', async function () {
project.setConfig({
rules: {
'no-html-comments': false,
},
pending: [
{
moduleId: 'app/templates/application',
only: ['no-html-comments'],
},
],
});

project.write({
app: {
templates: {
'application.hbs':
'<h2>Here too!!</h2><div>Bare strings are bad...</div><!-- bad html comment! -->',
},
},
});

let result = await run(['.', '--print-pending']);

expect(result.stdout).toMatchInlineSnapshot(`
"WARNING: Print pending is deprecated. Use --update-todo instead.
Add the following to your \`.template-lintrc.js\` file to mark these files as pending.
pending: []"
`);
expect(result.stderr).toBeFalsy();
});

it('should ignore existing pending modules that have partially passing rules', async function () {
project.setConfig({
rules: {
'no-html-comments': true,
'no-bare-strings': true,
},
pending: [
{
moduleId: 'app/templates/application',
only: ['no-html-comments', 'no-bare-strings'],
},
],
});
project.write({
app: {
templates: {
'application.hbs': '<h2>Here too!!</h2><div>Bare strings are bad...</div>',
},
},
});
let result = await run(['.', '--print-pending']);

expect(result.stdout).toMatchInlineSnapshot(`
"WARNING: Print pending is deprecated. Use --update-todo instead.
Add the following to your \`.template-lintrc.js\` file to mark these files as pending.
pending: [
{
\\"moduleId\\": \\"app/templates/application\\",
\\"only\\": [
\\"no-bare-strings\\"
]
}
]"
`);
expect(result.stderr).toBeFalsy();
});
});

describe('with --print-pending and --format=json params', function () {
it('should print json of pending modules', async function () {
project.setConfig({
rules: {
'no-bare-strings': true,
'no-html-comments': true,
},
pending: [
{
moduleId: 'app/templates/application',
only: ['no-html-comments'],
},
],
});
project.write({
app: {
templates: {
'application.hbs':
'<h2>Here too!!</h2><div>Bare strings are bad...</div><!-- bad html comment! -->',
},
},
});

let result = await run(['.', '--print-pending', '--format=json']);

let expectedOutputData = [
{
moduleId: 'app/templates/application',
only: ['no-bare-strings', 'no-html-comments'],
},
];

expect(JSON.parse(result.stdout)).toEqual(expectedOutputData);
expect(result.stderr).toBeFalsy();
});
});

describe('with --max-warnings param', function () {
it('should exit with error if warning count is greater than max-warnings', async function () {
project.setConfig({
Expand Down

0 comments on commit 9b0b88b

Please sign in to comment.