Skip to content

Commit

Permalink
Update the eslint rules and fix the vitest config.
Browse files Browse the repository at this point in the history
  • Loading branch information
shammowla committed Dec 6, 2024
1 parent 8191d05 commit d22709e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 53 deletions.
60 changes: 14 additions & 46 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ export default [
plugins: {
"unused-imports": unusedImports,
},
settings: {
"import/resolver": {
alias: {
map: [
["@src", "./src"],
["@test", "./test"]
],
extensions: [".js", ".jsx", ".mjs"]
},
node: {
extensions: [".js", ".jsx", ".mjs"],
paths: [path.resolve(__dirname)]
}
}
},
languageOptions: {
parser: babelParser,
parserOptions: {
Expand All @@ -61,16 +46,8 @@ export default [
globals: {
...globals.browser,
...globals.node,
describe: true,
it: true,
expect: true,
beforeAll: true,
beforeEach: true,
afterAll: true,
afterEach: true,
vi: true,
fixture: true,
test: true,
fixture: true
},
},
rules: {
Expand All @@ -97,10 +74,12 @@ export default [
controlComponents: ["WrappedField"],
},
],
// Has been deprecated in favor of label-has-associated-control
"jsx-a11y/label-has-for": "off",
"import/no-extraneous-dependencies": ["error", {
"devDependencies": ["**/*.test.js", "**/*.spec.js", "**/vitest.config.js", "**/test/**/*"]
}],
// Turning this off allows us to import devDependencies in our build tools.
// We enable the rule in src/.eslintrc.js since that's the only place we
// want to disallow importing extraneous dependencies.
"import/no-extraneous-dependencies": "off",
"prefer-destructuring": "off",
"import/prefer-default-export": "off",
"no-console": [
Expand All @@ -109,6 +88,13 @@ export default [
allow: ["error"],
},
],
// This rule typically shows an error if a Link component
// doesn't have an href. We use React-Spectrum's Link
// component, however, which doesn't have an href prop
// (Link expects a anchor element as a child). We have
// to provide an empty components array here to get around
// eslint complaining about this. eslint still checks
// anchor elements though.
"jsx-a11y/anchor-is-valid": [
"error",
{
Expand All @@ -126,29 +112,11 @@ export default [
2,
{ namedComponents: "arrow-function" },
],

"import/no-named-as-default-member": "off",
"import/no-named-as-default": "off",
"import/no-unresolved": ["error", {
"ignore": ["vitest", "vitest/config"]
}]
},
},
{
files: ["test/**/*.{js,jsx,mjs}"],
languageOptions: {
globals: {
describe: true,
it: true,
expect: true,
beforeAll: true,
beforeEach: true,
afterAll: true,
afterEach: true,
vi: true,
test: true
}
}
},
{
files: ["src/**/*.{mjs,js,jsx}"],
languageOptions: {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"prepare": "husky",
"prepush-msg": "echo 'Running pre-push scripts...' && exit 0",
"sandbox": "./scripts/buildExtensionManifest.mjs && reactor-sandbox",
"test:unit": "vitest --config ./vitest.config.js run",
"test:watch": "vitest --config ./vitest.config.js",
"test:unit": "vitest --config ./vitest.config.mjs run",
"test:watch": "vitest --config ./vitest.config.mjs",
"test:coverage": "vitest run --coverage",
"test:unit:watch:chrome": "vitest --config ./vitest.config.js --environment jsdom",
"test:unit:watch:chrome": "vitest --config ./vitest.config.mjs --environment jsdom",
"test:functional": "npm run build && testcafe chrome --esm test/functional/specs",
"test:functional:component": "npm run build:componentFixtures && testcafe --esm chrome test/functional/specs/component",
"test:functional:runtime": "npm-run-all -p build:alloy build:lib && testcafe --esm chrome test/functional/specs/runtime",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/lib/actions/setConsent/createSetConsent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.
*/

import { describe, it, expect, vi } from "vitest";
import createSetConsent from "@src/lib/actions/setConsent/createSetConsent";
import createSetConsent from "../../../../../src/lib/actions/setConsent/createSetConsent";

describe("Set Consent", () => {
["in", "out"].forEach((generalConsent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.
*/

import { describe, it, expect, beforeEach, vi } from "vitest";
import createInstanceManager from "@src/lib/instanceManager/createInstanceManager";
import createInstanceManager from "../../../../src/lib/instanceManager/createInstanceManager";

describe("Instance Manager", () => {
let instanceManager;
Expand Down
4 changes: 2 additions & 2 deletions vitest.config.js → vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from "vitest/config";
import { defineConfig } from "vitest/dist/config.js";
import react from "@vitejs/plugin-react";
import path from "path";
import { fileURLToPath } from "url";
Expand Down Expand Up @@ -40,4 +40,4 @@ export default defineConfig({
web: [/\.[jt]sx?$/],
},
},
});
});

0 comments on commit d22709e

Please sign in to comment.