Skip to content

Commit

Permalink
Merge pull request #50 from CesiumGS/tooling
Browse files Browse the repository at this point in the history
Add prettier and eslint for consistent code
  • Loading branch information
ggetz authored Jan 4, 2024
2 parents 2abd7af + 0a1f3d5 commit a2b7342
Show file tree
Hide file tree
Showing 16 changed files with 515 additions and 405 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/**
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": ["cesium/node"]
}
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ 16, 18 ]
node: [18, 20]
name: Node ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- name: install node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node }}
- name: install
run: npm install
- name: lint *.js
run: npm run eslint
- name: format code
run: npm run prettier-check
- name: build
run: npm run build

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/dist/
/node_modules/
package-lock.json
.DS_Store
.DS_Store
.eslintcache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
webpack.config.js
15 changes: 15 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

# Ignore everything
*

# Unignore directories (to all depths) and unignore code and style files in these directories
!.github/**/
!.vscode/**/
!src/**/
!doc/**/

!**/*.js
!**/*.css
!**/*.html
!**/*.md
!**/*.json
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
56 changes: 30 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,66 @@ A minimal recommended setup for an applications using [Cesium](https://cesium.co

## Running this application

````sh
```sh
npm install
npm start
````
```

Navigate to `localhost:8080`.

### Available scripts

* `npm start` - Runs a webpack build with `webpack.config.js` and starts a development server
* `npm run build` - Runs a webpack build with `webpack.config.js`
- `npm start` - Runs a webpack build with `webpack.config.js` and starts a development server
- `npm run build` - Runs a webpack build with `webpack.config.js`

## Requiring Cesium in your application

We recommend [importing named exports](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) from the Cesium ES module, via the `import` keyword. This allows webpack to [tree shake](https://webpack.js.org/guides/tree-shaking/) your application automatically.

### Import named modules from Cesium

````js
import { Color } from 'cesium';
```js
import { Color } from "cesium";
var c = Color.fromRandom();
````
```

### Import Cesium static asset files

````js
```js
import "cesium/Build/Cesium/Widgets/widgets.css";
````
```

## Removing pragmas

To remove pragmas such as a traditional Cesium release build, use the [`strip-pragma-loader`](https://www.npmjs.com/package/strip-pragma-loader).

Install the plugin with npm,

````sh
```sh
npm install strip-pragma-loader --save-dev
````
```

and include the loader in `module.rules` with `debug` set to `false`.

````js
rules: [{
test: /\.js$/,
enforce: 'pre',
include: path.resolve(__dirname, cesiumSource),
use: [{
loader: 'strip-pragma-loader',
options: {
pragmas: {
debug: false
}
}
}]
}]
````
```js
rules: [
{
test: /\.js$/,
enforce: "pre",
include: path.resolve(__dirname, cesiumSource),
use: [
{
loader: "strip-pragma-loader",
options: {
pragmas: {
debug: false,
},
},
},
],
},
];
```

## Contributions

Expand Down
Loading

0 comments on commit a2b7342

Please sign in to comment.