Skip to content

Commit ff2b8dd

Browse files
authored
Merge pull request #145 from microsoft/users/rbitting/prettier-eslint-setup
Set up prettier to run as an eslint rule
2 parents 0292570 + 6f0d531 commit ff2b8dd

11 files changed

+56
-26
lines changed

.eslintrc.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ module.exports = {
99
"eslint:recommended",
1010
"plugin:eslint-plugin/recommended",
1111
"plugin:node/recommended",
12-
"prettier",
13-
"plugin:eslint-plugin/recommended"
12+
"plugin:prettier/recommended" // Prettier plugin must be last in the extensions
1413
],
1514
plugins: ["header"],
1615
env: {
@@ -59,4 +58,3 @@ module.exports = {
5958
},
6059
ignorePatterns: ["node_modules", "dist/", "scripts"]
6160
};
62-

.prettierrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"arrowParens": "avoid",
3-
"bracketSpacing": true,
4-
"endOfLine": "crlf",
53
"bracketSameLine": true,
4+
"bracketSpacing": true,
5+
"endOfLine": "auto",
66
"printWidth": 140,
77
"semi": true,
88
"tabWidth": 4,

lib/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,3 @@ module.exports = {
9393
module.exports.processors = {
9494
// add your processors here
9595
};
96-

lib/rules/accordion-item-needs-header-and-panel.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
2525
create(context) {
2626
return {
2727
JSXOpeningElement(node: TSESTree.JSXOpeningElement) {
28-
const isAccordionItem =
29-
node.name.type === AST_NODE_TYPES.JSXIdentifier &&
30-
node.name.name === "AccordionItem";
28+
const isAccordionItem = node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name === "AccordionItem";
3129

3230
if (!isAccordionItem) return;
3331

lib/rules/counter-badge-needs-count.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,3 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
8989
});
9090

9191
export default rule;
92-

lib/rules/dialogbody-needs-title-content-and-actions.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
2525
create(context) {
2626
return {
2727
JSXOpeningElement(node: TSESTree.JSXOpeningElement) {
28-
const isDialogBody =
29-
node.name.type === AST_NODE_TYPES.JSXIdentifier &&
30-
node.name.name === "DialogBody";
28+
const isDialogBody = node.name.type === AST_NODE_TYPES.JSXIdentifier && node.name.name === "DialogBody";
3129

3230
if (!isDialogBody) {
3331
return;

lib/rules/rating-needs-name.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
1414
meta: {
1515
// possible error messages for the rule
1616
messages: {
17-
missingAriaLabel: 'Accessibility - ratings must have an accessible name or an itemLabel that generates an aria label'
17+
missingAriaLabel: "Accessibility - ratings must have an accessible name or an itemLabel that generates an aria label"
1818
},
1919
// "problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior: https://eslint.org/docs/latest/developer-guide/working-with-rules
2020
type: "problem",
2121
// docs for the rule
2222
docs: {
23-
description: "Accessibility: Ratings must have accessible labelling: name, aria-label, aria-labelledby or itemLabel which generates aria-label",
23+
description:
24+
"Accessibility: Ratings must have accessible labelling: name, aria-label, aria-labelledby or itemLabel which generates aria-label",
2425
recommended: "strict",
2526
url: "https://www.w3.org/TR/html-aria/" // URL to the documentation page for this rule
2627
},
@@ -32,9 +33,7 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
3233
// visitor functions for different types of nodes
3334
JSXOpeningElement(node: TSESTree.JSXOpeningElement) {
3435
// if it is not a listed component, return
35-
if (
36-
elementType(node as JSXOpeningElement) !== "Rating"
37-
) {
36+
if (elementType(node as JSXOpeningElement) !== "Rating") {
3837
return;
3938
}
4039

lib/rules/tooltip-not-recommended.ts

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

4-
import {ESLintUtils, TSESTree} from '@typescript-eslint/utils';
4+
import { ESLintUtils, TSESTree } from "@typescript-eslint/utils";
55
import { elementType } from "jsx-ast-utils";
66
import { hasToolTipParent } from "../util/hasTooltipParent";
7-
import { JSXOpeningElement } from 'estree-jsx';
7+
import { JSXOpeningElement } from "estree-jsx";
88

99
//------------------------------------------------------------------------------
1010
// Rule Definition
@@ -22,7 +22,7 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
2222
type: "suggestion", // `problem`, `suggestion`, or `layout`
2323
docs: {
2424
description: `Accessibility: Prefer text content or aria over a tooltip for these components ${allowedComponents.join(", ")}`,
25-
recommended: 'strict',
25+
recommended: "strict"
2626
},
2727
schema: [] // Add a schema if the rule has options
2828
},
@@ -50,6 +50,4 @@ const rule = ESLintUtils.RuleCreator.withoutDocs({
5050
}
5151
});
5252

53-
54-
55-
export default rule;
53+
export default rule;

package-lock.json

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"eslint-doc-generator": "^1.7.1",
7272
"eslint-plugin-eslint-plugin": "^5.0.8",
7373
"eslint-plugin-node": "^11.1.0",
74+
"eslint-plugin-prettier": "^4.2.5",
7475
"husky": "^9.1.6",
7576
"jest": "^29.7.0",
7677
"jscodeshift": "^17.0.0",

0 commit comments

Comments
 (0)