Skip to content

Commit

Permalink
ci: add linting step
Browse files Browse the repository at this point in the history
  • Loading branch information
lsndr committed Dec 25, 2023
1 parent 75b508f commit 7089eb7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,21 @@ concurrency:
on:
pull_request: null
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'yarn'
- name: Install
run: |
yarn install --frozen-lockfile
- name: Lint
run: |
yarn lint
build_and_test:
uses: ./.github/workflows/build-and-test.yml
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
"typescript": "^4.9.4"
},
"pre-commit": [
"lint:fix-staged",
"test"
"lint:fix-staged"
],
"lint-staged": {
"**/*.{js,ts,json}": "eslint --fix --max-warnings=0"
"**/*.{js,ts,json}": "eslint --fix --max-warnings=0",
"**/*.rs": "rustfmt"
},
"engines": {
"node": ">= 10"
Expand All @@ -78,8 +78,8 @@
"universal": "napi universal",
"version": "napi version",
"benchmark": "ts-node ./benchmark/index.ts",
"lint": "eslint \"**/*.{js,ts,json}\" --max-warnings=0",
"lint:fix": "yarn lint --fix",
"lint": "cargo fmt --all -- --check && eslint \"**/*.{js,ts,json}\" --max-warnings=0",
"lint:fix": "cargo fmt --all && yarn lint --fix",
"lint:fix-staged": "lint-staged"
}
}
16 changes: 13 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,13 @@ impl JsRRule {
}

pub fn validate(&self, dt_start: DateTime<Tz>) -> napi::Result<RRule> {
return Ok(self.rrule.clone().validate(dt_start).map_err(|e| napi::Error::new(napi::Status::GenericFailure, e))?);
return Ok(
self
.rrule
.clone()
.validate(dt_start)
.map_err(|e| napi::Error::new(napi::Status::GenericFailure, e))?,
);
}
}

Expand All @@ -320,7 +326,9 @@ impl JsRRuleSet {

#[napi(factory, ts_return_type = "RRuleSet")]
pub fn parse(str: String) -> napi::Result<Self> {
let rrule_set: RRuleSet = str.parse().map_err(|e| napi::Error::new(napi::Status::GenericFailure, e))?;
let rrule_set: RRuleSet = str
.parse()
.map_err(|e| napi::Error::new(napi::Status::GenericFailure, e))?;
let dtstart = rrule_set.get_dt_start();
let tz = dtstart.timezone();

Expand Down Expand Up @@ -549,7 +557,9 @@ fn map_rust_month(month: &u8) -> JsMonth {
}

fn map_js_tz(tz: &str) -> napi::Result<Tz> {
let chrono_tz = tz.parse().map_err(|e| napi::Error::new(napi::Status::GenericFailure, e))?;
let chrono_tz = tz
.parse()
.map_err(|e| napi::Error::new(napi::Status::GenericFailure, e))?;
Ok(Tz::Tz(chrono_tz))
}

Expand Down

0 comments on commit 7089eb7

Please sign in to comment.