Skip to content

Commit

Permalink
feat: Accommodate marker pipe, directive and forks (bartholomej#5)
Browse files Browse the repository at this point in the history
* fix(pipe-parser) search for pipe in structural directives

* refactor(pipe-parser) simplify handling of pipes in getTranslatablesFromAst

remove expressionIsOrHasBindingPipe - previously this also handled cases like `'World' | translate | upper`,
but it's not actually needed, getTranslatablesFromAst can deal with it by itself

move checks for translate and non-translate pipes together under a common BindingPipe check.

* fix(pipe-parser): find usages of translate pipe in arguments of other pipes

* feat(pipe): accommodate marker directive

* feat(pipe): accommodate forks of marker fn

* feat(pipe): accommodate marker pipe

* chore: initial commit after fork

* fix: fixed some botched imports

* chore: editorconfig, refactoring and bump

* chore: fixed some botched imports

* re-add --marker option

    -m or --marker is an old option that was in
    biesbjerg/ngx-translate-extract

    it was removed and replaced by the ngx-extract-translate-marker
    mechanism but this new mechanism does not allow to easily
    customize what the marker function does
    (some users have use cases where this is not a no-op)

* Create node.js.yml

* chore: update changelog, readme and bump version

* chore: busywork in prep for the lib to move back into vendure's fork

---------

Co-authored-by: P4 <969645+P4@users.noreply.github.com>
Co-authored-by: Christer Olsen <christer.olsen@husbanken.no>
Co-authored-by: Thomas Mijieux <thomas.mijieux@aum.bio>
  • Loading branch information
4 people authored Mar 15, 2023
1 parent 6455593 commit 63eeffd
Show file tree
Hide file tree
Showing 33 changed files with 9,017 additions and 2,267 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single

[*.md]
max_line_length = off
trim_trailing_whitespace = false
229 changes: 229 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"eslint-plugin-import",
"@typescript-eslint",
"@typescript-eslint/tslint"
],
"root": true,
"rules": {
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/indent": [
"error",
"tab"
],
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": [
"camelCase",
"UPPER_CASE",
"PascalCase"
],
"leadingUnderscore": "forbid",
"trailingUnderscore": "forbid"
}
],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-inferrable-types": [
"off",
{
"ignoreParameters": true
}
],
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-shadow": [
"error",
{
"hoist": "all"
}
],
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/quotes": [
"error",
"single"
],
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"arrow-body-style": "error",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"error",
"1tbs"
],
"comma-dangle": "off",
"constructor-super": "error",
"curly": "error",
"dot-notation": "off",
"eol-last": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-denylist": [
"error",
"any",
"Number",
"number",
"String",
"string",
"Boolean",
"boolean",
"Undefined",
"undefined"
],
"id-match": "error",
"import/no-deprecated": "warn",
"indent": "off",
"linebreak-style": "off",
"max-len": [
"error",
{
"code": 220
}
],
"new-parens": "off",
"newline-per-chained-call": "off",
"no-bitwise": "error",
"no-caller": "error",
"no-console": [
"error",
{
"allow": [
"log",
"warn",
"dir",
"timeLog",
"assert",
"clear",
"count",
"countReset",
"group",
"groupEnd",
"table",
"dirxml",
"error",
"groupCollapsed",
"Console",
"profile",
"profileEnd",
"timeStamp",
"context"
]
}
],
"no-debugger": "error",
"no-empty": "off",
"no-empty-function": "off",
"no-eval": "error",
"no-extra-semi": "off",
"no-fallthrough": "error",
"no-irregular-whitespace": "off",
"no-multiple-empty-lines": "off",
"no-new-wrappers": "error",
"no-shadow": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-var": "error",
"padded-blocks": [
"off",
{
"blocks": "never"
},
{
"allowSingleLineBlocks": true
}
],
"prefer-const": "error",
"quote-props": "off",
"quotes": "off",
"radix": "error",
"react/jsx-curly-spacing": "off",
"react/jsx-equals-spacing": "off",
"react/jsx-tag-spacing": [
"off",
{
"afterOpening": "allow",
"closingSlash": "allow"
}
],
"react/jsx-wrap-multilines": "off",
"semi": "off",
"space-before-function-paren": "off",
"space-in-parens": [
"off",
"never"
],
"spaced-comment": [
"error",
"always",
{
"markers": [
"/"
]
}
],
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"import-spacing": true,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}
]
}
}
22 changes: 22 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: build-test
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
36 changes: 0 additions & 36 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
registry=https://registry.npmjs.org
engine-strict=true
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
16
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog


## v8.0.6 (2023-03-TODO)

- Accommodate marker pipe and directive
- Enable support for other marker packages apart from the original from [Kim Biesbjerg](https://github.com/biesbjerg/ngx-translate-extract-marker)
- Merged [P4's](https://github.com/P4) PRs ([#1](https://github.com/vendure-ecommerce/ngx-translate-extract/pull/1), [#2](https://github.com/vendure-ecommerce/ngx-translate-extract/pull/2)) in order to improve the pipe parser when it comes to pipe args and structural directives
- Fixed some botched imports
- Re-added --marker/-m option to CLI thanks to [tmijieux's](https://github.com/tmijieux) [PR](https://github.com/colsen1991/ngx-translate-extract/pull/1)
- Moved to eslint and fixed errors/warnings
- Other minor clerical changes and small refactoring

## v8.0.5 (2023-03-02)

- fix(pipe-parser): Search for pipe in structural directives [#1](https://github.com/vendure-ecommerce/ngx-translate-extract/pull/1)
Expand All @@ -16,7 +27,8 @@

Fixes the following:

```json

```angular2html
{{ 'value' | testPipe: ('test1' | translate) }} // finds nothing, misses 'test1'
{{ 'Hello' | translate: {world: ('World' | translate)} }} // finds 'Hello', misses 'World'
{{ 'previewHeader' | translate:{filename: filename || ('video' | translate)} }} // finds 'previewHeader', misses 'video'
Expand Down
Loading

0 comments on commit 63eeffd

Please sign in to comment.