diff --git a/README.md b/README.md index 7c6ac49..3858ca5 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,29 @@ safety-web is an ESLint plugin that works on TypeScript and JavaScript projects ## Development +This project uses yarn "classic" (Yarn 1) with workspaces. To install the dependencies for all [workspaces](https://classic.yarnpkg.com/en/docs/workspaces/): + ``` yarn install -yarn workspace safety-web build ``` -## Unit testing +The commands `clean`, `build`, `lint`, `test` are defined in all workspaces. This makes it possible to run them in all workspaces: + +``` +# Build all workspaces +yarn workspaces run build +``` + +## safety-web unit testing + +``` +yarn workspaces safety-web test +``` + +## unit tests + integrations tests ``` -yarn workspace safety-web test +yarn run tests ``` ## Updating tsetse diff --git a/package.json b/package.json index 796031f..36d6303 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,6 @@ "scripts": { "unit_tests": "yarn workspace eslint-plugin-safety-web test", "integration_tests": "yarn workspace basic-typescript-eslint9 test && yarn workspace basic-typescript-eslint8 test && yarn workspace basic-javascript-eslint9 test", - "test": "yarn run unit_tests && yarn run integration_tests" + "test": "yarn workspaces run test" } } \ No newline at end of file diff --git a/safety-web/package.json b/safety-web/package.json index 002311f..a0008f4 100644 --- a/safety-web/package.json +++ b/safety-web/package.json @@ -8,8 +8,9 @@ "lib/src/" ], "scripts": { - "clean": "yarn rimraf ./lib", - "build": "yarn clean && tsc -b ./tsconfig.json", + "clean": "tsc --build --clean", + "build": "tsc -b ./tsconfig.json", + "lint": "eslint", "test": "mocha" }, "dependencies": { diff --git a/test-helpers/expect-violations/package.json b/test-helpers/expect-violations/package.json index d125990..1ade343 100644 --- a/test-helpers/expect-violations/package.json +++ b/test-helpers/expect-violations/package.json @@ -8,6 +8,10 @@ }, "bin": "./bin/index.js", "scripts": { - "build": "tsc" - } + "clean": "tsc --build --clean", + "build": "tsc", + "lint": "echo TODO", + "test": "echo TODO" + }, + "devDependencies": {} } diff --git a/tests/basic_javascript_eslint9/package.json b/tests/basic_javascript_eslint9/package.json index a4082cf..7d83e45 100644 --- a/tests/basic_javascript_eslint9/package.json +++ b/tests/basic_javascript_eslint9/package.json @@ -4,12 +4,15 @@ "private": true, "type": "module", "scripts": { - "lint": "eslint", - "test": "yarn --silent lint --format json | npx expect-violations ./expected_violations.json" + "clean": ":", + "build": ":", + "lint": "echo skip lint script for integration test case", + "test": "eslint --format json | yarn run expect-violations ./expected_violations.json" }, "devDependencies": { "eslint": "^9.6.0", "eslint-plugin-safety-web": "0.1.0", + "expect-violations": "^0.0.1", "typescript-eslint": "^7.16.0" } } diff --git a/tests/basic_typescript_eslint8/package.json b/tests/basic_typescript_eslint8/package.json index 34ed438..c1827ad 100644 --- a/tests/basic_typescript_eslint8/package.json +++ b/tests/basic_typescript_eslint8/package.json @@ -4,13 +4,15 @@ "private": true, "type": "module", "scripts": { - "lint": "eslint src/", + "clean": "tsc --build --clean", "build": "tsc", - "test": "yarn --silent lint --format json | npx expect-violations ./expected_violations.json" + "lint": "echo skip lint script for integration test case", + "test": "eslint src/ --format json | npx expect-violations ./expected_violations.json" }, "devDependencies": { "eslint": "^8.0.0", "eslint-plugin-safety-web": "0.1.0", + "expect-violations": "^0.0.1", "typescript": "^5.5.3", "typescript-eslint": "^7.16.0" } diff --git a/tests/basic_typescript_eslint9/lib/index.js b/tests/basic_typescript_eslint9/lib/index.js new file mode 100644 index 0000000..56cce2a --- /dev/null +++ b/tests/basic_typescript_eslint9/lib/index.js @@ -0,0 +1,15 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +document.createElement('script').innerHTML = 'foo'; +export {}; diff --git a/tests/basic_typescript_eslint9/package.json b/tests/basic_typescript_eslint9/package.json index 74fdc8e..cab9a21 100644 --- a/tests/basic_typescript_eslint9/package.json +++ b/tests/basic_typescript_eslint9/package.json @@ -4,13 +4,15 @@ "private": true, "type": "module", "scripts": { - "lint": "eslint", + "clean": "tsc --build --clean", "build": "tsc", - "test": "yarn --silent lint --format json | npx expect-violations ./expected_violations.json" + "lint": "echo skip lint script for integration test case", + "test": "eslint --format json | npx expect-violations ./expected_violations.json" }, "devDependencies": { "eslint": "^9.6.0", "eslint-plugin-safety-web": "0.1.0", + "expect-violations": "^0.0.1", "typescript": "^5.5.3", "typescript-eslint": "^7.15.0" }