diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000000..d350c894265 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,126 @@ +{ + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ], + "overrides": [ + { + "extends": ["plugin:jsonc/recommended-with-jsonc"], + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "jsonc/sort-keys": ["warn"] + } + }, + { + "extends": ["plugin:jsonc/recommended-with-jsonc"], + "files": ["package.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "jsonc/sort-keys": [ + "warn", + { + "hasProperties": ["type"], + "order": [ + "$schema", + "name", + "version", + "private", + "description", + "license", + "author", + "maintainers", + "contributors", + "homepage", + "repository", + "bugs", + "type", + "exports", + "main", + "module", + "browser", + "man", + "preferGlobal", + "bin", + "files", + "directories", + "scripts", + "config", + "sideEffects", + "types", + "typings", + "workspaces", + "resolutions", + "dependencies", + "bundleDependencies", + "bundledDependencies", + "peerDependencies", + "peerDependenciesMeta", + "optionalDependencies", + "devDependencies", + "keywords", + "engines", + "engineStrict", + "os", + "cpu", + "publishConfig" + ], + "pathPattern": "^$" + }, + { + "order": { "type": "asc" }, + "pathPattern": "^(?!exports\\[).*" + } + ] + } + }, + { + "extends": ["./first-gen/.eslintrc.json"], + "files": ["first-gen/**/*"], + "rules": { + "notice/notice": [ + "error", + { + "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", + "templateFile": "config/license.js" + } + ] + } + }, + { + "extends": ["./second-gen/.eslintrc.json"], + "files": ["second-gen/**/*"], + "rules": { + "notice/notice": [ + "error", + { + "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", + "templateFile": "../../../config/license.js" + } + ] + } + } + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": ["@typescript-eslint"], + "root": true, + "rules": { + "no-console": [ + "error", + { + "allow": ["warn", "error"] + } + ], + "no-debugger": 2 + } +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a2176b65a78..914016401df 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -122,4 +122,4 @@ jobs: level: error reporter: github-pr-review filter_mode: diff_context - eslint_flags: '${{ needs.changed_files.outputs.eslint_added_files }} ${{ needs.changed_files.outputs.eslint_modified_files }}' + eslint_flags: '--config .eslintrc.json ${{ needs.changed_files.outputs.eslint_added_files }} ${{ needs.changed_files.outputs.eslint_modified_files }}' diff --git a/first-gen/config/license.js b/config/license.js similarity index 100% rename from first-gen/config/license.js rename to config/license.js diff --git a/first-gen/.eslintrc.json b/first-gen/.eslintrc.json index c0ff95c84a1..61d9acef760 100755 --- a/first-gen/.eslintrc.json +++ b/first-gen/.eslintrc.json @@ -103,12 +103,11 @@ ], "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 2020, + "ecmaVersion": "latest", "sourceType": "module" }, "plugins": [ "@typescript-eslint", - "notice", "@spectrum-web-components", "import", "require-extensions" @@ -150,13 +149,6 @@ } ], "no-debugger": 2, - "notice/notice": [ - "error", - { - "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", - "templateFile": "first-gen/config/license.js" - } - ], "sort-imports": [ "error", { diff --git a/first-gen/package.json b/first-gen/package.json index 0dd61c2951a..05793c08d9a 100644 --- a/first-gen/package.json +++ b/first-gen/package.json @@ -18,6 +18,7 @@ "scripts": { "analyze": "lit-analyzer \"{packages,tools}/*/src/**/!(*.css).ts\"", "build": "wireit", + "prebuild": "wireit", "build:clear-cache": "rimraf packages/*/tsconfig.tsbuildinfo && rimraf tools/*/tsconfig.tsbuildinfo", "build:confirm": "node ./scripts/confirm-build.js", "build:css": "wireit", @@ -62,7 +63,8 @@ "process-icons": "wireit", "publish:react": "yarn changeset publish --no-git-tag --tag latest --no-push", "push-to-remote": "git add . && git commit -m \"chore: release new versions #publish\" && git push", - "start": "yarn storybook", + "dev:core": "yarn workspace @swc/core dev", + "start": "run-p dev:core storybook", "storybook": "wireit", "storybook:build": "NODE_ENV=production storybook build -o projects/documentation/dist/storybook -c storybook", "storybook:quick": "run-p build:watch storybook:run", @@ -82,7 +84,7 @@ "test:visual:clean:current": "rimraf test/visual/screenshots-current", "test:watch": "yarn test:watch:focus unit", "test:watch:flags:focus": "yarn build && run-p build:watch \"test:start --watch --group {1} --config web-test-runner.config.ci-chromium-flags.js\" --", - "test:watch:focus": "yarn build && run-p build:watch \"test:start --watch --group {1}\" --", + "test:watch:focus": "yarn dev:core & yarn build && run-p build:watch \"test:start --watch --group {1}\" --", "version:update": "genversion --verbose --semi --esm ./tools/base/src/version.js", "vrt:preview": "yarn wds --config test/visual/wds-vrt.config.js" }, @@ -221,10 +223,21 @@ "wireit": { "build": { "dependencies": [ + "prebuild", "build:ts", "build:types" ] }, + "prebuild": { + "command": "yarn workspace @swc/core build", + "files": [ + "../second-gen/packages/core/components/**/*", + "../second-gen/packages/core/shared/**/*", + "../second-gen/packages/core/package.json", + "../second-gen/packages/core/vite.config.js", + "../second-gen/packages/core/tsconfig.json" + ] + }, "build:css": { "clean": "if-file-deleted", "command": "node ./scripts/build-css.js", @@ -396,6 +409,7 @@ "storybook": { "command": "storybook dev -p 8080 -c storybook", "dependencies": [ + "build:ts", "build:watch", "prestorybook" ], diff --git a/first-gen/packages/.eslintrc.json b/first-gen/packages/.eslintrc.json index cb52c22842c..ec0a155288c 100644 --- a/first-gen/packages/.eslintrc.json +++ b/first-gen/packages/.eslintrc.json @@ -142,48 +142,30 @@ "@spectrum-web-components", "import" ], - "root": true, "rules": { - "import/no-extraneous-dependencies": [ - "error", - { - "devDependencies": false, - "optionalDependencies": false, - "peerDependencies": false - } - ], - "no-debugger": 2, - "no-console": [ - "error", - { - "allow": ["warn", "error"] - } - ], + "@spectrum-web-components/document-active-element": ["error"], "@spectrum-web-components/prevent-argument-names": [ "error", ["e", "ev", "evt", "err"] ], - "@spectrum-web-components/document-active-element": ["error"], - "notice/notice": [ - "error", - { - "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", - "templateFile": "first-gen/config/license.js" - } - ], "@typescript-eslint/explicit-function-return-type": [ 1, { "allowExpressions": true } ], - "sort-imports": [ + "@typescript-eslint/no-unused-vars": [ "error", { - "ignoreCase": true, - "ignoreDeclarationSort": true, - "ignoreMemberSort": false, - "allowSeparatedGroups": false + "argsIgnorePattern": "^_" + } + ], + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": false, + "optionalDependencies": false, + "peerDependencies": false } ], "lit-a11y/click-events-have-key-events": [ @@ -201,10 +183,27 @@ ] } ], - "@typescript-eslint/no-unused-vars": [ + "no-console": [ "error", { - "argsIgnorePattern": "^_" + "allow": ["warn", "error"] + } + ], + "no-debugger": 2, + "notice/notice": [ + "error", + { + "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", + "templateFile": "config/license.js" + } + ], + "sort-imports": [ + "error", + { + "allowSeparatedGroups": false, + "ignoreCase": true, + "ignoreDeclarationSort": true, + "ignoreMemberSort": false } ] } diff --git a/first-gen/tools/.eslintrc.json b/first-gen/tools/.eslintrc.json index 8b8ca21721f..e81cd6d1bbc 100644 --- a/first-gen/tools/.eslintrc.json +++ b/first-gen/tools/.eslintrc.json @@ -1,80 +1,15 @@ { - "root": true, "env": { "browser": true, - "node": false, - "es6": true + "es6": true, + "node": false }, - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint", - "notice", - "@spectrum-web-components", - "require-extensions" - ], "extends": [ "plugin:@typescript-eslint/recommended", "prettier", "plugin:lit-a11y/recommended", "plugin:require-extensions/recommended" ], - "rules": { - "no-debugger": 2, - "no-console": [ - "error", - { - "allow": ["warn", "error"] - } - ], - "@spectrum-web-components/prevent-argument-names": [ - "error", - ["e", "ev", "evt", "err"] - ], - "@spectrum-web-components/document-active-element": ["error"], - "notice/notice": [ - "error", - { - "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", - "templateFile": "first-gen/config/license.js" - } - ], - "@typescript-eslint/explicit-function-return-type": [ - 1, - { - "allowExpressions": true - } - ], - "sort-imports": [ - "error", - { - "ignoreCase": true, - "ignoreDeclarationSort": true, - "ignoreMemberSort": false, - "allowSeparatedGroups": false - } - ], - "lit-a11y/click-events-have-key-events": [ - "error", - { - "allowList": [ - "sp-button", - "sp-action-button", - "sp-checkbox", - "sp-radio", - "sp-switch", - "sp-menu-item", - "sp-clear-button", - "sp-underlay" - ] - } - ], - "@typescript-eslint/no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_" - } - ] - }, "overrides": [ { "files": [ @@ -85,9 +20,9 @@ ], "rules": { "@spectrum-web-components/document-active-element": ["off"], + "import/no-extraneous-dependencies": ["off"], "lit-a11y/no-autofocus": ["off"], - "lit-a11y/tabindex-no-positive": ["off"], - "import/no-extraneous-dependencies": ["off"] + "lit-a11y/tabindex-no-positive": ["off"] } }, { @@ -199,5 +134,70 @@ ] } } - ] + ], + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint", + "notice", + "@spectrum-web-components", + "require-extensions" + ], + "root": true, + "rules": { + "@spectrum-web-components/document-active-element": ["error"], + "@spectrum-web-components/prevent-argument-names": [ + "error", + ["e", "ev", "evt", "err"] + ], + "@typescript-eslint/explicit-function-return-type": [ + 1, + { + "allowExpressions": true + } + ], + "@typescript-eslint/no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_" + } + ], + "lit-a11y/click-events-have-key-events": [ + "error", + { + "allowList": [ + "sp-button", + "sp-action-button", + "sp-checkbox", + "sp-radio", + "sp-switch", + "sp-menu-item", + "sp-clear-button", + "sp-underlay" + ] + } + ], + "no-console": [ + "error", + { + "allow": ["warn", "error"] + } + ], + "no-debugger": 2, + "notice/notice": [ + "error", + { + "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", + "templateFile": "config/license.js" + } + ], + "sort-imports": [ + "error", + { + "allowSeparatedGroups": false, + "ignoreCase": true, + "ignoreDeclarationSort": true, + "ignoreMemberSort": false + } + ] + } } diff --git a/package.json b/package.json index 6e887cd851e..bf6fa03171c 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,19 @@ }, "type": "module", "scripts": { - "build": "yarn workspace @adobe/spectrum-web-components build", - "test": "yarn workspace @adobe/spectrum-web-components test", - "start": "yarn workspace @adobe/spectrum-web-components storybook", - "lint": "yarn workspace @adobe/spectrum-web-components lint", - "postinstall": "husky || true && patch-package" + "build": "yarn build:first-gen && yarn build:second-gen", + "build:first-gen": "yarn workspace @adobe/spectrum-web-components build", + "build:second-gen": "yarn workspace @adobe/swc build", + "lint": "yarn lint:first-gen && yarn lint:second-gen", + "lint:first-gen": "yarn workspace @adobe/spectrum-web-components lint", + "lint:second-gen": "yarn workspace @adobe/swc lint", + "postinstall": "husky || true && patch-package", + "start": "yarn start:first-gen & yarn start:second-gen", + "start:first-gen": "yarn workspace @adobe/spectrum-web-components start", + "start:second-gen": "yarn workspace @adobe/swc start", + "test": "yarn test:first-gen & yarn test:second-gen", + "test:first-gen": "yarn workspace @adobe/spectrum-web-components test", + "test:second-gen": "yarn workspace @adobe/swc test" }, "workspaces": [ "first-gen", @@ -32,6 +40,15 @@ "resolutions": { "playwright": "1.53.1" }, + "devDependencies": { + "@changesets/cli": "2.29.7", + "@commitlint/cli": "19.8.1", + "@commitlint/config-conventional": "^19.8.1", + "husky": "9.1.7", + "lint-staged": "^16.1.2", + "patch-package": "^8.0.0", + "replace-in-file": "^8.3.0" + }, "keywords": [ "design-system", "spectrum", @@ -42,15 +59,6 @@ "lit-element", "lit-html" ], - "devDependencies": { - "@changesets/cli": "2.29.7", - "@commitlint/cli": "19.8.1", - "@commitlint/config-conventional": "^19.8.1", - "husky": "9.1.7", - "lint-staged": "^16.1.2", - "patch-package": "^8.0.0", - "replace-in-file": "^8.3.0" - }, "engines": { "node": ">=20.10.0", "yarn": ">=4.6.0" diff --git a/second-gen/.eslintrc.json b/second-gen/.eslintrc.json index bdfe92ddeeb..08282209432 100644 --- a/second-gen/.eslintrc.json +++ b/second-gen/.eslintrc.json @@ -103,7 +103,7 @@ ], "parser": "@typescript-eslint/parser", "parserOptions": { - "ecmaVersion": 2020, + "ecmaVersion": "latest", "sourceType": "module" }, "plugins": [ @@ -113,7 +113,6 @@ "import", "simple-import-sort" ], - "root": true, "rules": { "@spectrum-web-components/prevent-argument-names": [ "error", @@ -121,21 +120,7 @@ ], "curly": ["error", "all"], "import/prefer-default-export": "off", - "lit-a11y/click-events-have-key-events": [ - "error", - { - "allowList": [ - "sp-button", - "sp-action-button", - "sp-checkbox", - "sp-radio", - "sp-switch", - "sp-menu-item", - "sp-clear-button", - "sp-underlay" - ] - } - ], + "lit-a11y/click-events-have-key-events": ["error"], "no-console": [ "error", { @@ -143,13 +128,6 @@ } ], "no-debugger": 2, - "notice/notice": [ - "error", - { - "mustMatch": "Copyright [0-9]{0,4} Adobe. All rights reserved.", - "templateFile": "first-gen/config/license.js" - } - ], "simple-import-sort/imports": [ "error", { diff --git a/second-gen/package.json b/second-gen/package.json index c437d2faeda..c32a510d6e9 100644 --- a/second-gen/package.json +++ b/second-gen/package.json @@ -1,5 +1,5 @@ { - "name": "@adobe/spectrum-web-components-2nd-gen", + "name": "@adobe/swc", "version": "0.0.1", "private": true, "description": "Second generation Spectrum Web Components with modern tooling and architecture", @@ -16,10 +16,10 @@ }, "type": "module", "scripts": { - "build": "yarn workspaces foreach --from '@swc/*' run build", - "clean": "yarn workspaces foreach --from '@swc/*' run clean", + "build": "yarn workspaces foreach --from '@swc/*' --recursive run build", + "clean": "yarn workspaces foreach --from '@swc/*' --recursive run clean", "lint": "eslint . --ext .ts,.js,.json", - "storybook": "yarn workspace @swc/components storybook", + "start": "yarn workspace @swc/core dev & yarn workspace @swc/components analyze:watch & yarn workspace @swc/components storybook", "storybook:build": "yarn workspace @swc/components storybook:build", "test": "yarn workspace @swc/components test" }, @@ -27,6 +27,7 @@ "packages/*" ], "devDependencies": { + "eslint": "8.57.1", "eslint-plugin-simple-import-sort": "12.1.1" }, "keywords": [ diff --git a/second-gen/packages/swc/package.json b/second-gen/packages/swc/package.json index eaba4fe8443..d1a7a87fc8a 100644 --- a/second-gen/packages/swc/package.json +++ b/second-gen/packages/swc/package.json @@ -6,16 +6,14 @@ "author": "Adobe", "homepage": "https://opensource.adobe.com/spectrum-web-components/", "repository": { + "directory": "second-gen/packages/swc", "type": "git", - "url": "https://github.com/adobe/spectrum-web-components.git", - "directory": "second-gen/packages/swc" + "url": "https://github.com/adobe/spectrum-web-components.git" }, "bugs": { "url": "https://github.com/adobe/spectrum-web-components/issues" }, "type": "module", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", @@ -30,20 +28,24 @@ "import": "./dist/components/*/index.js" } }, + "main": "./dist/index.js", "files": [ "dist/" ], "scripts": { "analyze": "cem analyze --config cem.config.js", + "analyze:watch": "cem analyze --config cem.config.js --watch", "build": "vite build", "clean": "rimraf dist", "dev": "vite build --watch", "storybook": "yarn analyze && storybook dev -p 6006", "storybook:build": "yarn analyze && storybook build", - "test": "vitest", + "test": "vitest --run", "test:coverage": "vitest --coverage", - "test:ui": "vitest --ui" + "test:ui": "vitest --ui", + "test:watch": "yarn workspace @swc/core dev & vitest" }, + "types": "./dist/index.d.ts", "dependencies": { "@swc/core": "workspace:*", "lit": "^2.5.0 || ^3.1.3" diff --git a/yarn.lock b/yarn.lock index f6ba0dfe87a..45a0a5fb9cc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -170,14 +170,6 @@ __metadata: languageName: node linkType: hard -"@adobe/spectrum-web-components-2nd-gen@workspace:second-gen": - version: 0.0.0-use.local - resolution: "@adobe/spectrum-web-components-2nd-gen@workspace:second-gen" - dependencies: - eslint-plugin-simple-import-sort: "npm:12.1.1" - languageName: unknown - linkType: soft - "@adobe/spectrum-web-components-monorepo@workspace:.": version: 0.0.0-use.local resolution: "@adobe/spectrum-web-components-monorepo@workspace:." @@ -308,6 +300,15 @@ __metadata: languageName: unknown linkType: soft +"@adobe/swc@workspace:second-gen": + version: 0.0.0-use.local + resolution: "@adobe/swc@workspace:second-gen" + dependencies: + eslint: "npm:8.57.1" + eslint-plugin-simple-import-sort: "npm:12.1.1" + languageName: unknown + linkType: soft + "@ampproject/remapping@npm:^2.3.0": version: 2.3.0 resolution: "@ampproject/remapping@npm:2.3.0"