mirror of
https://github.com/hanzoai/eslint.git
synced 2026-10-30 19:38:10 +00:00
* chore: remove formatting-related lint rules internally * chore: formatted files with Prettier via trunk fmt * rm .prettierrc.json * chore: correct comment directives and formatting * Apply introduced fmt changes post-merge * Also disable MD010 and MD030 in preparation for 19355 * Also disable MD013 in preparation for 19355 * Updated tools/update-rule-type-headers.js to print tabs * Fix introduced issues from the main merge * Manually format conf/*.json * Switch conf/*.json files back to two spaces, per prettier config * chore: empty commit to hopefully unblock GitHub
157 lines
2.8 KiB
JavaScript
157 lines
2.8 KiB
JavaScript
/**
|
|
* @fileoverview Tests for no-tabs rule
|
|
* @author Gyandeep Singh
|
|
*/
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const rule = require("../../../lib/rules/no-tabs");
|
|
const RuleTester = require("../../../lib/rule-tester/rule-tester");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Tests
|
|
//------------------------------------------------------------------------------
|
|
|
|
const ruleTester = new RuleTester();
|
|
|
|
ruleTester.run("no-tabs", rule, {
|
|
valid: [
|
|
"function test(){\n}",
|
|
"function test(){\n" + " // sdfdsf \n" + "}",
|
|
|
|
{
|
|
code: "\tdoSomething();",
|
|
options: [{ allowIndentationTabs: true }],
|
|
},
|
|
{
|
|
code: "\t// comment",
|
|
options: [{ allowIndentationTabs: true }],
|
|
},
|
|
],
|
|
invalid: [
|
|
{
|
|
code: "function test(){\t}",
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 17,
|
|
endLine: 1,
|
|
endColumn: 18,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "/** \t comment test */",
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 5,
|
|
endLine: 1,
|
|
endColumn: 6,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "function test(){\n" + " //\tsdfdsf \n" + "}",
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 2,
|
|
column: 5,
|
|
endLine: 2,
|
|
endColumn: 6,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "function\ttest(){\n" + " //sdfdsf \n" + "}",
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 9,
|
|
endLine: 1,
|
|
endColumn: 10,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "function test(){\n" + " //\tsdfdsf \n" + "\t}",
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 2,
|
|
column: 5,
|
|
endLine: 2,
|
|
endColumn: 6,
|
|
},
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 3,
|
|
column: 1,
|
|
endLine: 3,
|
|
endColumn: 2,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "\t// Comment with leading tab \t and inline tab",
|
|
options: [{ allowIndentationTabs: true }],
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 30,
|
|
endLine: 1,
|
|
endColumn: 31,
|
|
},
|
|
],
|
|
},
|
|
{
|
|
code: "\t\ta =\t\t\tb +\tc\t\t;\t\t",
|
|
errors: [
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 1,
|
|
endLine: 1,
|
|
endColumn: 3,
|
|
},
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 6,
|
|
endLine: 1,
|
|
endColumn: 9,
|
|
},
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 12,
|
|
endLine: 1,
|
|
endColumn: 13,
|
|
},
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 14,
|
|
endLine: 1,
|
|
endColumn: 16,
|
|
},
|
|
{
|
|
messageId: "unexpectedTab",
|
|
line: 1,
|
|
column: 17,
|
|
endLine: 1,
|
|
endColumn: 19,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|