diff --git a/.eslintrc.js b/.eslintrc.js index 4e41fd6..a18692a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,26 @@ module.exports = { { files: ["tests/**/*.js"], env: { mocha: true } + }, + { + files: ["tests/**/*.ts"], + env: { jest: true } + }, + { + files: ["**/*.ts"], + parser: "@typescript-eslint/parser", + plugins: ["@typescript-eslint"], + parserOptions: { + ecmaVersion: 2021, + sourceType: "module", + project: "./tsconfig.json" + }, + rules: { + // Disable Node.js rules that conflict with TypeScript + "node/no-missing-import": "off", + "node/no-unsupported-features/es-syntax": "off", + "node/no-extraneous-import": "off" + } } ], rules: { diff --git a/lib/applicableComponents/labelBasedComponents.ts b/lib/applicableComponents/labelBasedComponents.ts index 4f847a8..4729d19 100644 --- a/lib/applicableComponents/labelBasedComponents.ts +++ b/lib/applicableComponents/labelBasedComponents.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + const labelBasedComponents = ["Label", "label"]; const elementsUsedAsLabels = ["div", "span", "p", "h1", "h2", "h3", "h4", "h5", "h6"]; diff --git a/lib/rules/field-needs-labelling.ts b/lib/rules/field-needs-labelling.ts index cc0536b..cb2887d 100644 --- a/lib/rules/field-needs-labelling.ts +++ b/lib/rules/field-needs-labelling.ts @@ -3,7 +3,7 @@ "use strict"; -const { hasNonEmptyProp } = require("../util/hasNonEmptyProp"); +import { hasNonEmptyProp } from "../util/hasNonEmptyProp"; const elementType = require("jsx-ast-utils").elementType; import { ESLintUtils, TSESTree } from "@typescript-eslint/utils"; diff --git a/lib/rules/index.ts b/lib/rules/index.ts index 1222566..ec59318 100644 --- a/lib/rules/index.ts +++ b/lib/rules/index.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + export { default as accordionHeaderNeedsLabelling } from "./accordion-header-needs-labelling"; export { default as accordionItemNeedsHeaderAndPanel } from "./accordion-item-needs-header-and-panel"; export { default as avatarNeedsName } from "./avatar-needs-name"; diff --git a/tests/lib/rules/utils/hasFieldParent.test.ts b/tests/lib/rules/utils/hasFieldParent.test.ts index 5e5d06c..8b521a9 100644 --- a/tests/lib/rules/utils/hasFieldParent.test.ts +++ b/tests/lib/rules/utils/hasFieldParent.test.ts @@ -25,9 +25,11 @@ const createMockContext = (ancestors: TSESTree.Node[]): TSESLint.RuleContext ancestors, getSourceCode: jest.fn(), + // eslint-disable-next-line no-unused-vars getDeclaredVariables: function (node: TSESTree.Node): readonly TSESLint.Scope.Variable[] { throw new Error("Function not implemented."); }, + // eslint-disable-next-line no-unused-vars markVariableAsUsed: function (name: string): boolean { throw new Error("Function not implemented."); } diff --git a/tests/lib/rules/utils/hasLabelledChilImage.test.ts b/tests/lib/rules/utils/hasLabelledChilImage.test.ts index 1c514e3..07a9f45 100644 --- a/tests/lib/rules/utils/hasLabelledChilImage.test.ts +++ b/tests/lib/rules/utils/hasLabelledChilImage.test.ts @@ -1,4 +1,6 @@ -// Import necessary dependencies and mock functions +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + import { hasLabelledChildImage, isImageHidden, diff --git a/tsconfig.json b/tsconfig.json index 8bde47e..64c2068 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,6 +19,6 @@ "rootDir": ".", "allowJs": true }, - "include": ["lib"], + "include": ["lib", "tests/lib"], "exclude": ["node_modules", "dist"] }