diff --git a/README.md b/README.md
index 50776e945..03d067d34 100644
--- a/README.md
+++ b/README.md
@@ -81,7 +81,7 @@ for more information about extending configuration files.
| Rule | Description | Recommended | Fixable |
| ------------------------------------------------------------------ | ----------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------ |
| [consistent-test-it](docs/rules/consistent-test-it.md) | Enforce consistent test or it keyword | | ![fixable](https://img.shields.io/badge/-fixable-green.svg) |
-| [lowercase-name](docs/rules/lowercase-name.md) | Disallow capitalized test names | | |
+| [lowercase-name](docs/rules/lowercase-name.md) | Disallow capitalized test names | | ![fixable](https://img.shields.io/badge/-fixable-green.svg) |
| [no-disabled-tests](docs/rules/no-disabled-tests.md) | Disallow disabled tests | ![recommended](https://img.shields.io/badge/-recommended-lightgrey.svg) | |
| [no-focused-tests](docs/rules/no-focused-tests.md) | Disallow focused tests | ![recommended](https://img.shields.io/badge/-recommended-lightgrey.svg) | |
| [no-hooks](docs/rules/no-hooks.md) | Disallow setup and teardown hooks | | |
diff --git a/rules/__tests__/lowercase-name.test.js b/rules/__tests__/lowercase-name.test.js
index cfd574a0d..3908f85a2 100644
--- a/rules/__tests__/lowercase-name.test.js
+++ b/rules/__tests__/lowercase-name.test.js
@@ -21,6 +21,7 @@ ruleTester.run('lowercase-name', rule, {
'it("", function () {})',
'it("123 foo", function () {})',
'it(42, function () {})',
+ 'it(``)',
'test()',
"test('foo', function () {})",
'test("foo", function () {})',
@@ -28,6 +29,7 @@ ruleTester.run('lowercase-name', rule, {
'test("", function () {})',
'test("123 foo", function () {})',
'test("42", function () {})',
+ 'test(``)',
'describe()',
"describe('foo', function () {})",
'describe("foo", function () {})',
@@ -36,11 +38,13 @@ ruleTester.run('lowercase-name', rule, {
'describe("123 foo", function () {})',
'describe("42", function () {})',
'describe(function () {})',
+ 'describe(``)',
],
invalid: [
{
code: "it('Foo', function () {})",
+ output: "it('foo', function () {})",
errors: [
{
message: '`it`s should begin with lowercase',
@@ -51,6 +55,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: 'it("Foo", function () {})',
+ output: 'it("foo", function () {})',
errors: [
{
message: '`it`s should begin with lowercase',
@@ -61,6 +66,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: 'it(`Foo`, function () {})',
+ output: 'it(`foo`, function () {})',
errors: [
{
message: '`it`s should begin with lowercase',
@@ -71,6 +77,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: "test('Foo', function () {})",
+ output: "test('foo', function () {})",
errors: [
{
message: '`test`s should begin with lowercase',
@@ -81,6 +88,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: 'test("Foo", function () {})',
+ output: 'test("foo", function () {})',
errors: [
{
message: '`test`s should begin with lowercase',
@@ -91,6 +99,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: 'test(`Foo`, function () {})',
+ output: 'test(`foo`, function () {})',
errors: [
{
message: '`test`s should begin with lowercase',
@@ -101,6 +110,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: "describe('Foo', function () {})",
+ output: "describe('foo', function () {})",
errors: [
{
message: '`describe`s should begin with lowercase',
@@ -111,6 +121,7 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: 'describe("Foo", function () {})',
+ output: 'describe("foo", function () {})',
errors: [
{
message: '`describe`s should begin with lowercase',
@@ -121,6 +132,18 @@ ruleTester.run('lowercase-name', rule, {
},
{
code: 'describe(`Foo`, function () {})',
+ output: 'describe(`foo`, function () {})',
+ errors: [
+ {
+ message: '`describe`s should begin with lowercase',
+ column: 1,
+ line: 1,
+ },
+ ],
+ },
+ {
+ code: 'describe(`Some longer description`, function () {})',
+ output: 'describe(`some longer description`, function () {})',
errors: [
{
message: '`describe`s should begin with lowercase',
diff --git a/rules/lowercase-name.js b/rules/lowercase-name.js
index 3ad445686..3b2130252 100644
--- a/rules/lowercase-name.js
+++ b/rules/lowercase-name.js
@@ -52,6 +52,7 @@ module.exports = {
docs: {
url: getDocsUrl(__filename),
},
+ fixable: 'code',
},
create(context) {
const ignore = (context.options[0] && context.options[0].ignore) || [];
@@ -72,6 +73,23 @@ module.exports = {
message: '`{{ method }}`s should begin with lowercase',
data: { method: erroneousMethod },
node,
+ fix(fixer) {
+ const firstArg = node.arguments[0];
+ const description = testDescription(node);
+
+ const rangeIgnoringQuotes = [
+ firstArg.start + 1,
+ firstArg.end - 1,
+ ];
+
+ const newDescription =
+ description.substring(0, 1).toLowerCase() +
+ description.substring(1);
+
+ return [
+ fixer.replaceTextRange(rangeIgnoringQuotes, newDescription),
+ ];
+ },
});
}
},