From a2b6bea7142930d8143d9ca887e2c56ffa71a669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Carvalho?= Date: Thu, 19 Sep 2024 13:07:48 +0100 Subject: [PATCH] fix: add file extension to Theme imports and respective eslint rule (#4771) --- .eslintrc.json | 13 +++++++++++-- package.json | 1 + tools/.eslintrc.json | 17 ++++++++++++++--- tools/theme/src/Theme.ts | 2 +- tools/theme/test/theme-devmode.test.ts | 2 +- yarn.lock | 7 ++++++- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9bcfd32fc6..0d2d6bea0e 100755 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,6 +1,11 @@ { "root": true, - "plugins": ["notice", "@spectrum-web-components", "import"], + "plugins": [ + "notice", + "@spectrum-web-components", + "import", + "require-extensions" + ], "env": { "browser": true, "node": true, @@ -64,7 +69,11 @@ } ] }, - "extends": ["plugin:prettier/recommended", "plugin:lit-a11y/recommended"], + "extends": [ + "plugin:prettier/recommended", + "plugin:lit-a11y/recommended", + "plugin:require-extensions/recommended" + ], "overrides": [ { "files": ["tasks/*", "scripts/*"], diff --git a/package.json b/package.json index c9a44e5a19..6dfe389ec5 100755 --- a/package.json +++ b/package.json @@ -156,6 +156,7 @@ "eslint-plugin-lit-a11y": "^2.2.2", "eslint-plugin-notice": "^0.9.10", "eslint-plugin-prettier": "^5.1.3", + "eslint-plugin-require-extensions": "^0.1.3", "eslint-plugin-storybook": "^0.8.0", "express": "^4.16.4", "fast-glob": "^3.2.12", diff --git a/tools/.eslintrc.json b/tools/.eslintrc.json index 44d4544fb6..5504ec430f 100644 --- a/tools/.eslintrc.json +++ b/tools/.eslintrc.json @@ -6,15 +6,26 @@ "es6": true }, "parser": "@typescript-eslint/parser", - "plugins": ["@typescript-eslint", "notice", "@spectrum-web-components"], + "plugins": [ + "@typescript-eslint", + "notice", + "@spectrum-web-components", + "require-extensions" + ], "extends": [ "plugin:@typescript-eslint/recommended", "prettier", - "plugin:lit-a11y/recommended" + "plugin:lit-a11y/recommended", + "plugin:require-extensions/recommended" ], "rules": { "no-debugger": 2, - "no-console": ["error", { "allow": ["warn", "error"] }], + "no-console": [ + "error", + { + "allow": ["warn", "error"] + } + ], "@spectrum-web-components/prevent-argument-names": [ "error", ["e", "ev", "evt", "err"] diff --git a/tools/theme/src/Theme.ts b/tools/theme/src/Theme.ts index c641cdf385..1c58618761 100755 --- a/tools/theme/src/Theme.ts +++ b/tools/theme/src/Theme.ts @@ -27,7 +27,7 @@ import { SystemVariant, ThemeFragmentMap, ThemeKindProvider, -} from './theme-interfaces'; +} from './theme-interfaces.js'; export type { ProvideLang, ThemeFragmentMap, Color, Scale, SystemVariant }; /** * @element sp-theme diff --git a/tools/theme/test/theme-devmode.test.ts b/tools/theme/test/theme-devmode.test.ts index 2f4b36900a..f663cfa232 100644 --- a/tools/theme/test/theme-devmode.test.ts +++ b/tools/theme/test/theme-devmode.test.ts @@ -14,7 +14,7 @@ import '@spectrum-web-components/theme/sp-theme.js'; import { Theme } from '@spectrum-web-components/theme'; import { elementUpdated, expect, fixture, html } from '@open-wc/testing'; import { stub } from 'sinon'; -import { testForLitDevWarnings } from '../../../test/testing-helpers'; +import { testForLitDevWarnings } from '../../../test/testing-helpers.js'; describe('Theme', () => { testForLitDevWarnings( diff --git a/yarn.lock b/yarn.lock index c0b68b1faa..0b545460fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5349,7 +5349,7 @@ integrity sha512-rGfd7jqXOdR69bEjrRP58ynuIeJU0czPfwQvzhtCzg7jKVukV+efNHqrs086sC6xutB3W4TF71K/dZMr3oyTyg== "@spectrum-web-components/eslint-plugin@file:./linters/eslint": - version "0.47.2" + version "0.48.0" "@storybook/addon-a11y@^7.5.0": version "7.6.19" @@ -12063,6 +12063,11 @@ eslint-plugin-prettier@^5.1.3: prettier-linter-helpers "^1.0.0" synckit "^0.8.6" +eslint-plugin-require-extensions@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz#394aeab433f996797a6ceba0a3f75640d4846bc8" + integrity sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug== + eslint-plugin-storybook@^0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/eslint-plugin-storybook/-/eslint-plugin-storybook-0.8.0.tgz#23185ecabdc289cae55248c090f0c1d8fbae6c41"