Skip to content

Commit

Permalink
Add Prettier to script to help enforce code style
Browse files Browse the repository at this point in the history
Fix the issue eclipse-cdt-cloud#861 regarding code style.
  • Loading branch information
Estelle Foisy committed Apr 19, 2023
1 parent 1acc299 commit b322382
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 46 deletions.
71 changes: 36 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ name: build

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

build-and-test:
runs-on: ${{ matrix.os }}

Expand All @@ -17,49 +16,51 @@ jobs:
node-version: [16.x]

steps:
- name: install dependencies on ubuntu
if: startsWith(matrix.os,'ubuntu')
run: |
sudo apt install -y make gcc pkg-config build-essential libx11-dev libxkbfile-dev
- name: install dependencies on ubuntu
if: startsWith(matrix.os,'ubuntu')
run: |
sudo apt install -y make gcc pkg-config build-essential libx11-dev libxkbfile-dev
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache node_modules with yarn
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node_modules with yarn
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --frozen-lockfile
- run: yarn --frozen-lockfile

- run: yarn test
env:
CI: true
- run: yarn test
env:
CI: true

code-lint:
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2
- name: Check out Git repository
uses: actions/checkout@v2

- uses: actions/setup-node@v3
with:
node-version: '16'

- uses: actions/setup-node@v3
with:
node-version: '16'
# ESLint and Prettier must be in `package.json`
- run: yarn --frozen-lockfile --ignore-scripts

# ESLint and Prettier must be in `package.json`
- run: yarn --frozen-lockfile --ignore-scripts
- run: yarn lint

- run: yarn lint
- run: yarn format
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"endOfLine": "lf",
"semi": false,
"singleQuote": true,
"trailingComma": "es5"
}
12 changes: 3 additions & 9 deletions configs/base.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@
"jsx": true
}
},
"plugins": [
"@typescript-eslint",
"import",
"no-null"
],
"plugins": ["@typescript-eslint", "prettier", "import", "no-null"],
"extends": ["prettier"],
"env": {
"browser": true,
"node": true
},
"ignorePatterns": [
"node_modules",
"*.d.ts"
],
"ignorePatterns": ["node_modules", "*.d.ts"],
"rules": {
"@typescript-eslint/no-namespace": "off"
}
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"lint": "lerna run lint",
"test": "lerna run test --",
"publish:latest": "lerna publish --registry=https://registry.npmjs.org/ --exact --no-git-tag-version --no-push",
"publish:next": "lerna publish --registry=https://registry.npmjs.org/ --exact --canary minor --preid=next.$(git rev-parse --short HEAD) --dist-tag=next --no-git-tag-version --no-push --yes"
"publish:next": "lerna publish --registry=https://registry.npmjs.org/ --exact --canary minor --preid=next.$(git rev-parse --short HEAD) --dist-tag=next --no-git-tag-version --no-push --yes",
"format": "prettier \"./**/*.{ts,tsx,js,md,json}\" --write"
},
"keywords": [
"theia-extension",
Expand All @@ -48,7 +49,8 @@
"@theia/cli": "1.34.2",
"jsonc-parser": "^3.0.0",
"lerna": "^4.0.0",
"typescript": "4.5.5"
"typescript": "4.5.5",
"prettier": "^2.7.1"
},
"workspaces": [
"examples/*",
Expand Down

0 comments on commit b322382

Please sign in to comment.