Skip to content

Commit

Permalink
baml-core-napi addition
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvg committed Mar 6, 2024
1 parent e112a01 commit 164784a
Show file tree
Hide file tree
Showing 54 changed files with 7,373 additions and 0 deletions.
466 changes: 466 additions & 0 deletions .github/workflows/baml-core-napi-ci.yml

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions .github/workflows/baml-core-napi-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint

on:
push:
branches:
- canary
- log-jest
tags-ignore:
- "**"
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: "yarn"

- name: Install
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt

- name: Install dependencies
run: yarn install

- name: ESLint
run: yarn lint

- name: Cargo fmt
run: cargo fmt -- --check

- name: Clippy
run: cargo clippy
3 changes: 3 additions & 0 deletions engine/baml-core-napi/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static"]
15 changes: 15 additions & 0 deletions engine/baml-core-napi/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors or IDEs
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
169 changes: 169 additions & 0 deletions engine/baml-core-napi/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
parser: '@typescript-eslint/parser'

parserOptions:
ecmaFeatures:
jsx: true
ecmaVersion: latest
sourceType: module
project: ./tsconfig.json

env:
browser: true
es6: true
node: true
jest: true

ignorePatterns: ['index.js']

plugins:
- import
- '@typescript-eslint'

extends:
- eslint:recommended
- plugin:prettier/recommended

rules:
# 0 = off, 1 = warn, 2 = error
'space-before-function-paren': 0
'no-useless-constructor': 0
'no-undef': 2
'no-console': [2, { allow: ['error', 'warn', 'info', 'assert'] }]
'comma-dangle': ['error', 'only-multiline']
'no-unused-vars': 0
'no-var': 2
'one-var-declaration-per-line': 2
'prefer-const': 2
'no-const-assign': 2
'no-duplicate-imports': 2
'no-use-before-define': [2, { 'functions': false, 'classes': false }]
'eqeqeq': [2, 'always', { 'null': 'ignore' }]
'no-case-declarations': 0
'no-restricted-syntax':
[
2,
{
'selector': 'BinaryExpression[operator=/(==|===|!=|!==)/][left.raw=true], BinaryExpression[operator=/(==|===|!=|!==)/][right.raw=true]',
'message': Don't compare for equality against boolean literals,
},
]

# https://github.com/benmosher/eslint-plugin-import/pull/334
'import/no-duplicates': 2
'import/first': 2
'import/newline-after-import': 2
'import/order':
[
2,
{
'newlines-between': 'always',
'alphabetize': { 'order': 'asc' },
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
},
]

overrides:
- files:
- ./**/*{.ts,.tsx}
rules:
'no-unused-vars': [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
'no-undef': 0
# TypeScript declare merge
'no-redeclare': 0
'no-useless-constructor': 0
'no-dupe-class-members': 0
'no-case-declarations': 0
'no-duplicate-imports': 0
# TypeScript Interface and Type
'no-use-before-define': 0

'@typescript-eslint/adjacent-overload-signatures': 2
'@typescript-eslint/await-thenable': 2
'@typescript-eslint/consistent-type-assertions': 2
'@typescript-eslint/ban-types':
[
'error',
{
'types':
{
'String': { 'message': 'Use string instead', 'fixWith': 'string' },
'Number': { 'message': 'Use number instead', 'fixWith': 'number' },
'Boolean': { 'message': 'Use boolean instead', 'fixWith': 'boolean' },
'Function': { 'message': 'Use explicit type instead' },
},
},
]
'@typescript-eslint/explicit-member-accessibility':
[
'error',
{
accessibility: 'explicit',
overrides:
{
accessors: 'no-public',
constructors: 'no-public',
methods: 'no-public',
properties: 'no-public',
parameterProperties: 'explicit',
},
},
]
'@typescript-eslint/method-signature-style': 2
'@typescript-eslint/no-floating-promises': 2
'@typescript-eslint/no-implied-eval': 2
'@typescript-eslint/no-for-in-array': 2
'@typescript-eslint/no-inferrable-types': 2
'@typescript-eslint/no-invalid-void-type': 2
'@typescript-eslint/no-misused-new': 2
'@typescript-eslint/no-misused-promises': 2
'@typescript-eslint/no-namespace': 2
'@typescript-eslint/no-non-null-asserted-optional-chain': 2
'@typescript-eslint/no-throw-literal': 2
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 2
'@typescript-eslint/prefer-for-of': 2
'@typescript-eslint/prefer-nullish-coalescing': 2
'@typescript-eslint/switch-exhaustiveness-check': 2
'@typescript-eslint/prefer-optional-chain': 2
'@typescript-eslint/prefer-readonly': 2
'@typescript-eslint/prefer-string-starts-ends-with': 0
'@typescript-eslint/no-array-constructor': 2
'@typescript-eslint/require-await': 2
'@typescript-eslint/return-await': 2
'@typescript-eslint/ban-ts-comment':
[2, { 'ts-expect-error': false, 'ts-ignore': true, 'ts-nocheck': true, 'ts-check': false }]
'@typescript-eslint/naming-convention':
[
2,
{
selector: 'memberLike',
format: ['camelCase', 'PascalCase'],
modifiers: ['private'],
leadingUnderscore: 'forbid',
},
]
'@typescript-eslint/no-unused-vars':
[2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
'@typescript-eslint/member-ordering':
[
2,
{
default:
[
'public-static-field',
'protected-static-field',
'private-static-field',
'public-static-method',
'protected-static-method',
'private-static-method',
'public-instance-field',
'protected-instance-field',
'private-instance-field',
'public-constructor',
'protected-constructor',
'private-constructor',
'public-instance-method',
'protected-instance-method',
'private-instance-method',
],
},
]
14 changes: 14 additions & 0 deletions engine/baml-core-napi/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Auto detect text files and perform LF normalization
* text=auto


*.ts text eol=lf merge=union
*.tsx text eol=lf merge=union
*.rs text eol=lf merge=union
*.js text eol=lf merge=union
*.json text eol=lf merge=union
*.debug text eol=lf merge=union

# Generated codes
index.js linguist-detectable=false
index.d.ts linguist-detectable=false
20 changes: 20 additions & 0 deletions engine/baml-core-napi/.github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:base", "group:allNonMajor", ":preserveSemverRanges", ":disablePeerDependencies"],
"labels": ["dependencies"],
"packageRules": [
{
"matchPackageNames": ["@napi/cli", "napi", "napi-build", "napi-derive"],
"addLabels": ["napi-rs"],
"groupName": "napi-rs"
},
{
"matchPackagePatterns": ["^eslint", "^@typescript-eslint"],
"groupName": "linter"
}
],
"commitMessagePrefix": "chore: ",
"commitMessageAction": "bump up",
"commitMessageTopic": "{{depName}} version",
"ignoreDeps": []
}
Loading

0 comments on commit 164784a

Please sign in to comment.