Skip to content

Instantly share code, notes, and snippets.

@alexamies
Last active October 5, 2018 22:26
Show Gist options
  • Select an option

  • Save alexamies/8e7aa81d1078ceadc2298e0df92f9865 to your computer and use it in GitHub Desktop.

Select an option

Save alexamies/8e7aa81d1078ceadc2298e0df92f9865 to your computer and use it in GitHub Desktop.

Revisions

  1. @alexpamies alexpamies renamed this gist Oct 5, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @alexpamies alexpamies renamed this gist Sep 18, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion a-README.md → A-README.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ docker build -t eslint .
    docker run -w /app eslint
    ```

    To run with Cloud Build run
    To run with Cloud Build use the command
    ```
    gcloud builds submit . --config=cloudbuild.yaml
    ```
  3. @alexpamies alexpamies created this gist Sep 18, 2018.
    3 changes: 3 additions & 0 deletions .eslintrc.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    {
    "extends": "google"
    }
    7 changes: 7 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    FROM node:10.10.0

    RUN mkdir /app
    COPY *.js /app/
    COPY *.json /app/
    RUN npm install -g eslint eslint-config-google
    CMD ["/usr/local/bin/npm", "run", "lint"]
    32 changes: 32 additions & 0 deletions a-README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # Cloud Builder JavaScript Lint Example
    This example demonstrates the use of [Cloud
    Build](https://cloud.google.com/cloud-build/docs/)
    to do style checking with [eslint](https://eslint.org/).

    To build and run manually with Docker run
    ```
    docker build -t eslint .
    docker run -w /app eslint
    ```

    To run with Cloud Build run
    ```
    gcloud builds submit . --config=cloudbuild.yaml
    ```

    You will see that there are several style errors reported for the the sum.js
    file, including . Edit sum.js to be like this:

    ```
    /**
    * Add two numbers together
    * @param {number} a - The first operand
    * @param {number} b - The second operand
    * @return {number} The sum of the two operands
    */
    function sum(a, b) {
    return a + b;
    }
    console.log('1 + 1 = ' + sum(1, 1));
    ```
    Then run cloud build again. It should succeed this time.
    5 changes: 5 additions & 0 deletions cloudbuild.yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    steps:
    - name: 'gcr.io/cloud-builders/docker'
    args: [ 'build', '-t', 'gcr.io/$PROJECT_ID/eslint', '.' ]
    - name: gcr.io/cloud-builders/docker
    args: ['run', '-w', '/app', 'gcr.io/$PROJECT_ID/eslint']
    15 changes: 15 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    {
    "name": "javascript",
    "version": "1.0.0",
    "description": "",
    "main": "sum.js",
    "scripts": {
    "lint":"eslint ."
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
    "eslint": "^5.5.0",
    "eslint-config-google": "^0.10.0"
    }
    }
    4 changes: 4 additions & 0 deletions sum.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    function sum(a, b) {
    sum = a + b
    return sum
    }