Skip to content

Commit

Permalink
Define common script for all packages to be able to use `yarn workspa…
Browse files Browse the repository at this point in the history
…ces run x`

Change-Id: I4aced5d5fbe69aec917dbf52cf14bb81e2822fe4
  • Loading branch information
neuracr committed Jul 19, 2024
1 parent 3aeb2c4 commit 4b85dba
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 14 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
5 changes: 3 additions & 2 deletions safety-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 6 additions & 2 deletions test-helpers/expect-violations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
},
"bin": "./bin/index.js",
"scripts": {
"build": "tsc"
}
"clean": "tsc --build --clean",
"build": "tsc",
"lint": "echo TODO",
"test": "echo TODO"
},
"devDependencies": {}
}
7 changes: 5 additions & 2 deletions tests/basic_javascript_eslint9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
6 changes: 4 additions & 2 deletions tests/basic_typescript_eslint8/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
15 changes: 15 additions & 0 deletions tests/basic_typescript_eslint9/lib/index.js
Original file line number Diff line number Diff line change
@@ -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 {};
6 changes: 4 additions & 2 deletions tests/basic_typescript_eslint9/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 4b85dba

Please sign in to comment.