Skip to content

Commit

Permalink
ci: run tests and linting once
Browse files Browse the repository at this point in the history
  • Loading branch information
scagood committed Apr 1, 2024
1 parent 1deb5bc commit baec20a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Packages
run: npm install
- name: Lint
run: npm run -s lint
- run: npm install
- run: npm run -s lint
- run: npm run -s test:types

test:
name: Test
Expand Down Expand Up @@ -64,7 +63,6 @@ jobs:
- name: Install Packages
run: npm install
- name: Install ESLint ${{ matrix.eslint }}
run: |
npm install --no-save --force eslint@${{ matrix.eslint }}
run: npm install --no-save --force eslint@${{ matrix.eslint }}
- name: Test
run: npm run -s test
run: npm run -s test:tests
9 changes: 4 additions & 5 deletions lib/util/get-configured-node-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
*/
"use strict"

const { Range } = require("semver") // eslint-disable-line no-unused-vars
const getPackageJson = require("./get-package-json")
const getSemverRange = require("./get-semver-range")

/**
* Gets `version` property from a given option object.
*
* @param {Record<string, string>|undefined} option - An option object to get.
* @returns {Range|undefined} The `allowModules` value, or `null`.
* @returns {import("semver").Range|undefined} The `allowModules` value, or `null`.
*/
function getVersionRange(option) {
if (option?.version) {
Expand All @@ -25,7 +24,7 @@ function getVersionRange(option) {
/**
* Get the `engines.node` field of package.json.
* @param {import('eslint').Rule.RuleContext} context The path to the current linting file.
* @returns {Range|undefined} The range object of the `engines.node` field.
* @returns {import("semver").Range|undefined} The range object of the `engines.node` field.
*/
function getEnginesNode(context) {
const filename = context.filename ?? context.getFilename()
Expand All @@ -45,15 +44,15 @@ function getEnginesNode(context) {
*
* @param {import('eslint').Rule.RuleContext} context The version range text.
* This will be used to look package.json up if `version` is not a valid version range.
* @returns {Range} The configured version range.
* @returns {import("semver").Range} The configured version range.
*/
module.exports = function getConfiguredNodeVersion(context) {
return (
getVersionRange(context.options?.[0]) ??
getVersionRange(context.settings?.n) ??
getVersionRange(context.settings?.node) ??
getEnginesNode(context) ??
/** @type {Range} */ (getSemverRange(">=16.0.0"))
/** @type {import("semver").Range} */ (getSemverRange(">=16.0.0"))
)
}

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,10 @@
"prepack": "tsc --emitDeclarationOnly",
"prepare": "husky",
"preversion": "npm test",
"test": "run-p test:types test:lint test:tests",
"test:lint": "npm run -s lint",
"test": "run-p lint:* test:types test:tests",
"test:mocha": "_mocha --reporter progress --timeout 4000",
"test:tests": "npm run test:mocha \"tests/lib/**/*.js\"",
"test:types": "tsc --noEmit --emitDeclarationOnly false",
"test:mocha": "_mocha --reporter progress --timeout 4000",
"update:eslint-docs": "eslint-doc-generator",
"version": "npm run -s build && eslint lib/rules --fix && git add .",
"watch": "npm run test:_mocha -- --watch --growl"
Expand Down

0 comments on commit baec20a

Please sign in to comment.