Skip to content

Commit d322617

Browse files
committed
Fixed create rule script
1 parent ff2b8dd commit d322617

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

scripts/boilerplate/doc.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
const docBoilerplateGenerator = (name, description) => `# ${description} (@microsoft/fluentui-jsx-a11y/${name})
4+
const { withCRLF } = require("./util");
5+
6+
const docBoilerplateGenerator = (name, description) =>
7+
withCRLF(`# ${description} (@microsoft/fluentui-jsx-a11y/${name})
58
69
Write a useful explanation here!
710
@@ -18,5 +21,5 @@ Write more details here!
1821
\`\`\`
1922
2023
## Further Reading
21-
`;
24+
`);
2225
module.exports = docBoilerplateGenerator;

scripts/boilerplate/rule.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
const ruleBoilerplate = (name, description) => `// Copyright (c) Microsoft Corporation.
4+
const { withCRLF } = require("./util");
5+
6+
const ruleBoilerplate = (name, description) =>
7+
withCRLF(`// Copyright (c) Microsoft Corporation.
58
// Licensed under the MIT License.
69
710
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
@@ -41,5 +44,5 @@ const rule = createRule({
4144
});
4245
4346
export default rule;
44-
`;
47+
`);
4548
module.exports = ruleBoilerplate;

scripts/boilerplate/test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
const testBoilerplate = name => `// Copyright (c) Microsoft Corporation.
4+
const { withCRLF } = require("./util");
5+
6+
const testBoilerplate = name =>
7+
withCRLF(`// Copyright (c) Microsoft Corporation.
58
// Licensed under the MIT License.
69
710
import { Rule } from "eslint";
@@ -20,5 +23,5 @@ ruleTester.run("${name}", rule as unknown as Rule.RuleModule, {
2023
/* ... */
2124
]
2225
});
23-
`;
26+
`);
2427
module.exports = testBoilerplate;

scripts/boilerplate/util.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Helper method to convert LF line endings to CRLF line endings
3+
* @remarks This is needed to avoid prettier formatting issues on generation of the files
4+
* @param text The text to convert
5+
* @returns The converted text
6+
*/
7+
const withCRLF = text => text.replace(/\n/g, "\r\n");
8+
9+
module.exports = { withCRLF };

scripts/create-rule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const author = argv.author || "$AUTHOR";
3434
const description = argv.description || "$DESCRIPTION";
3535

3636
const rulePath = resolve(`lib/rules/${ruleName}.ts`);
37-
const testPath = resolve(`tests/lib/rules/${ruleName}-test.ts`);
37+
const testPath = resolve(`tests/lib/rules/${ruleName}.test.ts`);
3838
const docsPath = resolve(`docs/rules/${ruleName}.md`);
3939

4040
// Validate

0 commit comments

Comments
 (0)