diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 37edaacb7..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,21 +0,0 @@ -# This config is equivalent to both the '.circleci/extended/orb-free.yml' and the base '.circleci/config.yml' -version: 2.1 - -# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects. -# See: https://circleci.com/docs/2.0/orb-intro/ -orbs: - node: circleci/node@4.7 - -# Invoke jobs via workflows -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows -workflows: - sample: # This is the name of the workflow, feel free to change it to better match your workflow. - # Inside the workflow, you define the jobs you want to run. - jobs: - - node/test: - # This is the node version to use for the `cimg/node` tag - # Relevant tags can be found on the CircleCI Developer Hub - # https://circleci.com/developer/images/image/cimg/node - version: '16.10' - # If you are using yarn, change the line below from "npm" to "yarn" - pkg-manager: npm diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..bda819ec8 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Node CI + +on: [push, pull_request] + +jobs: + build: + + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest] + node-version: [12.x, 14.x, 16.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, test + run: | + npm install + npm test + env: + CI: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6e3f9e51f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: node_js -node_js: - - '10' - - '12' - - '13' -cache: - bundler: true - directories: - - node_modules # NPM package -before_script: - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - - chmod +x ./cc-test-reporter - - ./cc-test-reporter before-build -notifications: - email: false - webhooks: - urls: - - https://webhooks.gitter.im/e/f1d48355795bf25a8f9a - on_success: change - on_failure: always - on_start: never -script: npm test -after_success: cat /home/travis/build/glayzzle/php-parser/coverage/lcov.info | /home/travis/build/glayzzle/php-parser/node_modules/coveralls/bin/coveralls.js -after_script: - - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/jest.config.js b/jest.config.js index caa281737..7d0ad8555 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,19 +5,27 @@ const ENABLE_COVERAGE = !!process.env.CI || !!process.env.COVERAGE; module.exports = { collectCoverage: ENABLE_COVERAGE, coverageDirectory: "coverage/", + coverageThreshold: { + global: { + statements: 95.6, + branches: 89.6, + functions: 99, + lines: 96.1, + }, + }, projects: [ { displayName: "test", testEnvironment: "node", }, - //{ - // runner: "jest-runner-eslint", - // displayName: "lint", - // testMatch: ["/**/*.js"], - // testPathIgnorePatterns: [ - // "/node_modules/", - // "/coverage/", - // ], - //}, + { + runner: "jest-runner-eslint", + displayName: "lint", + testMatch: ["/**/*.js"], + testPathIgnorePatterns: [ + "/node_modules/", + "/coverage/", + ], + }, ], }; diff --git a/src/ast.js b/src/ast.js index 93e8b704b..4ddbdb897 100644 --- a/src/ast.js +++ b/src/ast.js @@ -475,7 +475,7 @@ AST.prototype.prepare = function (kind, docs, parser) { AST.prototype.checkNodes = function () { const errors = []; for (const k in AST.stack) { - if (AST.stack.hasOwnProperty(k)) { + if (Object.prototype.hasOwnProperty.call(AST.stack, k)) { errors.push(AST.stack[k]); } } diff --git a/src/index.js b/src/index.js index d3aaec4fa..4818721d3 100644 --- a/src/index.js +++ b/src/index.js @@ -213,7 +213,7 @@ Engine.prototype.tokenGetAll = function (buffer) { const result = []; while (token != EOF) { let entry = this.lexer.yytext; - if (names.hasOwnProperty(token)) { + if (Object.prototype.hasOwnProperty.call(names, token)) { entry = [names[token], entry, this.lexer.yylloc.first_line]; } result.push(entry); diff --git a/src/parser.js b/src/parser.js index 946939d4e..733ff213b 100644 --- a/src/parser.js +++ b/src/parser.js @@ -615,7 +615,12 @@ Parser.prototype.lex = function () { this.token = this.lexer.lex() || this.EOF; if (this.token === this.EOF) return this; let entry = this.lexer.yytext; - if (this.lexer.engine.tokens.values.hasOwnProperty(this.token)) { + if ( + Object.prototype.hasOwnProperty.call( + this.lexer.engine.tokens.values, + this.token + ) + ) { entry = [ this.lexer.engine.tokens.values[this.token], entry, @@ -686,7 +691,7 @@ Parser.prototype.is = function (type) { require("./parser/variable.js"), ].forEach(function (ext) { for (const k in ext) { - if (Parser.prototype.hasOwnProperty(k)) { + if (Object.prototype.hasOwnProperty.call(Parser.prototype, k)) { // @see https://github.com/glayzzle/php-parser/issues/234 throw new Error("Function " + k + " is already defined - collision"); }