diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..b9d48d491 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*.js] +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.yml] +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.eslintignore b/.eslintignore index 714d84019..46c3a2d3a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,7 +4,6 @@ *.sublime-project *.sublime-workspace npm-debug.log -sauce_connect.log* .idea yarn-error.log node_modules @@ -12,10 +11,9 @@ node_modules .nyc_output # Generated files -lib/handlebars/compiler/parser.js /coverage/ /dist/ -/integration-testing/*/dist/ +/tests/integration/*/dist/ # Third-party or files that must remain unchanged /spec/expected/ diff --git a/.eslintrc.js b/.eslintrc.js index 2ac729358..f03eac32f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,11 +1,14 @@ module.exports = { extends: ['eslint:recommended', 'plugin:compat/recommended', 'prettier'], globals: { - self: false + self: false, }, env: { node: true, - es6: true + es2020: true, + }, + parserOptions: { + sourceType: 'module', }, rules: { 'no-console': 'warn', @@ -56,11 +59,6 @@ module.exports = { // ECMAScript 6 // //--------------// - 'no-var': 'error' + 'no-var': 'error', }, - parserOptions: { - sourceType: 'module', - ecmaVersion: 6, - ecmaFeatures: {} - } }; diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..a6ae06ee2 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Upgrade to Prettier 2.7 +3d228334530860a6e3f99dc10777c84bf22292c1 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..6cd73dafe --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,11 @@ +Before filing issues, please check the following points first: + +- [ ] Please don't open issues for security issues. Instead, file a report at https://www.npmjs.com/advisories/report?package=handlebars +- [ ] Have a look at https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md +- [ ] Read the FAQ at https://github.com/handlebars-lang/handlebars.js/blob/master/FAQ.md +- [ ] Use the jsfiddle-template at https://jsfiddle.net/4nbwjaqz/4/ to reproduce problems or bugs + +This will probably help you to get a solution faster. +For bugs, it would be great to have a PR with a failing test-case. + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..7b0c5f177 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +Before creating a pull-request, please check https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md first. + +Generally we like to see pull requests that + +- [ ] Please don't start pull requests for security issues. Instead, file a report at https://www.npmjs.com/advisories/report?package=handlebars +- [ ] Maintain the existing code style +- [ ] Are focused on a single change (i.e. avoid large refactoring or style adjustments in untouched code if not the primary goal of the pull request) +- [ ] Have good commit messages +- [ ] Have tests +- [ ] Have the [typings](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) (lib/handlebars.d.ts) updated on every API change. If you need help, updating those, please mention that in the PR description. +- [ ] Don't significantly decrease the current code coverage (see coverage/lcov-report/index.html) +- [ ] Currently, the `4.x`-branch contains the latest version. Please target that branch in the PR. \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..c73c050af --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + open-pull-requests-limit: 0 + schedule: + interval: weekly + allow: + - dependency-type: production diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..d7af2072c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,112 @@ +name: CI + +on: + push: + branches: + - master + pull_request: {} + +jobs: + lint: + name: Lint + runs-on: 'ubuntu-latest' + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install dependencies + run: npm ci + + - name: Lint + run: npm run lint + + dependencies: + name: Test (dependencies) + runs-on: 'ubuntu-latest' + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + # Node 14 ships with npm v6, which doesn't install peer-dependencies by default. + # Starting with npm v7 (which is shipped with Node >= 16), peer-dependencies are + # automatically installed. So this test (check for unmet peer-dependencies) only + # works with Node <= 14. + node-version: '14' + + # Simulate an installation by a dependent package + - name: Install dependencies + run: | + rm package-lock.json + npm install --production + + - name: Check dependency tree + run: npm ls + + test: + name: Test (Node) + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: ['ubuntu-latest', 'windows-latest'] + # https://nodejs.org/en/about/releases/ + node-version: ['12', '14', '16', '18', '20'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm ci + + - name: Test + run: npm run test + + - name: Test (Integration) + run: | + cd ./tests/integration/rollup-test && ./test.sh && cd - + cd ./tests/integration/webpack-babel-test && ./test.sh && cd - + cd ./tests/integration/webpack-test && ./test.sh && cd - + + browser: + name: Test (Browser) + runs-on: 'ubuntu-latest' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: true + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '18' + + - name: Install dependencies + run: npm ci + + - name: Install Playwright + run: | + npx playwright install-deps + npx playwright install + + - name: Build + run: npx grunt prepare + + - name: Test + run: npm run test:browser diff --git a/.gitignore b/.gitignore index 97e44f885..0674f3e77 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ *.sublime-project *.sublime-workspace npm-debug.log -sauce_connect.log* .idea /yarn-error.log /yarn.lock @@ -13,8 +12,7 @@ node_modules .nyc_output # Generated files -lib/handlebars/compiler/parser.js /coverage/ /dist/ -/integration-testing/*/dist/ -/spec/tmp/* \ No newline at end of file +/tests/integration/*/dist/ +/spec/tmp/* diff --git a/.gitmodules b/.gitmodules index 1739275a8..09cc7fdfd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "spec/mustache"] path = spec/mustache - url = git://github.com/mustache/spec.git + url = https://github.com/mustache/spec.git diff --git a/.prettierignore b/.prettierignore index 724620669..7c9924e64 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,10 +12,9 @@ node_modules .nyc_output # Generated files -lib/handlebars/compiler/parser.js /coverage/ /dist/ -/integration-testing/*/dist/ +/tests/integration/*/dist/ # Third-party or files that must remain unchanged /spec/expected/ diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e7d347e27..000000000 --- a/.travis.yml +++ /dev/null @@ -1,39 +0,0 @@ -language: node_js -jobs: - include: - - stage: test - name: check javascript (eslint) - node_js: lts/* - script: npm run lint - - stage: test - name: check formatting (prettier) - node_js: lts/* - script: npm run check-format - - stage: test - name: check typescript definitions (dtslint) - node_js: lts/* - script: npm run dtslint - - stage: test - name: extensive tests and publish to aws - script: npm run extensive-tests-and-publish-to-aws - env: - - S3_BUCKET_NAME=builds.handlebarsjs.com - - secure: ckyEe5dzjdFDjmZ6wIrhGm0CFBEnKq8c1dYptfgVV/Q5/nJFGzu8T0yTjouS/ERxzdT2H327/63VCxhFnLCRHrsh4rlW/rCy4XI3O/0TeMLgFPa4TXkO8359qZ4CB44TBb3NsJyQXNMYdJpPLTCVTMpuiqqkFFOr+6OeggR7ufA= - - secure: Nm4AgSfsgNB21kgKrF9Tl7qVZU8YYREhouQunFracTcZZh2NZ2XH5aHuSiXCj88B13Cr/jGbJKsZ4T3QS3wWYtz6lkyVOx3H3iI+TMtqhD9RM3a7A4O+4vVN8IioB2YjhEu0OKjwgX5gp+0uF+pLEi7Hpj6fupD3AbbL5uYcKg8= - - SAUCE_USERNAME=handlebars - - secure: 1VkLQhbsEug4ZMQ52tTOus/WLvW3Etqe7GbCzZfzsI8d2ygJPjFfzU8fNm4pVVwoTI21MaM5AQq7SVPu8DWN1YbDjJycMdY1zO3DsB9aZBxTal98fIB7ZIUce9r5z2EP6mETrsbYjZkeckzIBI0A4UVa+F2BO4KbRDXP1Db3u3I= - node_js: '10' - - stage: test - name: test with latest nodejs-lts - node_js: lts/* - script: npm run test - - stage: test - name: test with active nodejs - node_js: node - script: npm run test -cache: npm -email: - on_failure: change - on_success: never -git: - depth: 100 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5386e6a23..9b6631195 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,20 +1,28 @@ # How to Contribute +## Reporting security issues + +Please don't open issues for security issues. Instead, file a report at https://www.npmjs.com/advisories/report?package=handlebars + ## Reporting Issues -Please see our [FAQ](https://github.com/wycats/handlebars.js/blob/master/FAQ.md) for common issues that people run into. +Please see our [FAQ](https://github.com/handlebars-lang/handlebars.js/blob/master/FAQ.md) for common issues that people run into. -Should you run into other issues with the project, please don't hesitate to let us know by filing an [issue][issue]! In general we are going to ask for an example of the problem failing, which can be as simple as a jsfiddle/jsbin/etc. We've put together a jsfiddle [template][jsfiddle] to ease this. (We will keep this link up to date as new releases occur, so feel free to check back here) +Should you run into other issues with the project, please don't hesitate to let us know by filing an [issue][issue]! + +In general we are going to ask for an **example** of the problem failing, which can be as simple as a jsfiddle/jsbin/etc. We've put together a jsfiddle **[template][jsfiddle]** to ease this. (We will keep this link up to date as new releases occur, so feel free to check back here). Pull requests containing only failing tests demonstrating the issue are welcomed and this also helps ensure that your issue won't regress in the future once it's fixed. -Documentation issues on the handlebarsjs.com site should be reported on [handlebars-site](https://github.com/wycats/handlebars-site). +Documentation issues on the [handlebarsjs.com](https://handlebarsjs.com) site should be reported on [handlebars-lang/docs](https://github.com/handlebars-lang/docs). ## Branches - The branch `4.x` contains the currently released version. Bugfixes should be made in this branch. - The branch `master` contains the next version. A release date is not yet specified. Maintainers should merge the branch `4.x` into the master branch regularly. +- The branch `3.x` contains the legacy version `3.x`. Bugfixes are applied separately (if needed). The branch will not + be merged with any of the other branches. ## Pull Requests @@ -47,9 +55,9 @@ You can also run our set of benchmarks with `grunt bench`. The `grunt dev` implements watching for tests and allows for in browser testing at `http://localhost:9999/spec/`. If you notice any problems, please report them to the GitHub issue tracker at -[http://github.com/wycats/handlebars.js/issues](http://github.com/wycats/handlebars.js/issues). +[http://github.com/handlebars-lang/handlebars.js/issues](http://github.com/handlebars-lang/handlebars.js/issues). -##Running Tests +## Running Tests To run tests locally, first install all dependencies. @@ -78,14 +86,14 @@ We do linting and formatting in two phases: - Committed files are linted and formatted in a pre-commit hook. In this stage eslint-errors are forbidden, while warnings are allowed. -- The travis-ci job also lints all files and checks if they are formatted correctly. In this stage, warnings +- The GitHub CI job also lints all files and checks if they are formatted correctly. In this stage, warnings are forbidden. -You can use the following scripts to make sure that the travis-job does not fail: +You can use the following scripts to make sure that the CI job does not fail: - **npm run lint** will run `eslint` and fail on warnings - **npm run format** will run `prettier` on all files -- **npm run check-before-pull-request** will perform all most checks that travis does in its build-job, excluding the "integration-test". +- **npm run check-before-pull-request** will perform all most checks that our CI job does in its build-job, excluding the "integration-test". - **npm run integration-test** will run integration tests (using old NodeJS versions and integrations with webpack, babel and so on) These tests only work on a Linux-machine with `nvm` installed (for running tests in multiple versions of NodeJS). @@ -93,7 +101,7 @@ You can use the following scripts to make sure that the travis-job does not fail Before attempting the release Handlebars, please make sure that you have the following authorizations: -- Push-access to `wycats/handlebars.js` +- Push-access to `handlebars-lang/handlebars.js` - Publishing rights on npmjs.com for the `handlebars` package - Publishing rights on gemfury for the `handlebars-source` package - Push-access to the repo for legacy package managers: `components/handlebars` @@ -101,15 +109,12 @@ Before attempting the release Handlebars, please make sure that you have the fol _When releasing a previous version of Handlebars, please look into the CONTRIBUNG.md in the corresponding branch._ -Handlebars utilizes the [release yeoman generator][generator-release] to perform most release tasks. - A full release may be completed with the following: ``` npm ci -yo release +npx grunt npm publish -yo release:publish components handlebars.js dist/components/ cd dist/components/ gem build handlebars-source.gemspec @@ -126,13 +131,13 @@ in those places still point to the latest version When everything is OK, the **handlebars site** needs to be updated. -Go to the master branch of the repo [handlebars-lang/handlebarsjs.com-github-pages](https://github.com/handlebars-lang/handlebarsjs.com-github-pages/tree/master) +Go to the master branch of the repo [handlebars-lang/docs](https://github.com/handlebars-lang/docs/tree/master) and make a minimal change to the README. This will invoke a github-action that redeploys the site, fetching the latest version-number from the npm-registry. (note that the default-branch of this repo is not the master and regular changes are done in the `handlebars-lang/docs`-repo). [generator-release]: https://github.com/walmartlabs/generator-release -[pull-request]: https://github.com/wycats/handlebars.js/pull/new/master -[issue]: https://github.com/wycats/handlebars.js/issues/new -[jsfiddle]: https://jsfiddle.net/9D88g/180/ +[pull-request]: https://github.com/handlebars-lang/handlebars.js/pull/new/master +[issue]: https://github.com/handlebars-lang/handlebars.js/issues/new +[jsfiddle]: https://jsfiddle.net/4nbwjaqz/4/ diff --git a/FAQ.md b/FAQ.md index 108e839af..4edcb8ba4 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,22 +1,22 @@ # Frequently Asked Questions -1. How can I file a bug report: +## How can I file a bug report: - See our guidelines on [reporting issues](https://github.com/wycats/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues). + See our guidelines on [reporting issues](https://github.com/handlebars-lang/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues). -1. Why isn't my Mustache template working? +## Why isn't my Mustache template working? - Handlebars deviates from Mustache slightly on a few behaviors. These variations are documented in our [readme](https://github.com/wycats/handlebars.js#differences-between-handlebarsjs-and-mustache). + Handlebars deviates from Mustache slightly on a few behaviors. These variations are documented in our [readme](https://github.com/handlebars-lang/handlebars.js#differences-between-handlebarsjs-and-mustache). -1. Why is it slower when compiling? +## Why is it slower when compiling? The Handlebars compiler must parse the template and construct a JavaScript program which can then be run. Under some environments such as older mobile devices this can have a performance impact which can be avoided by precompiling. Generally it's recommended that precompilation and the runtime library be used on all clients. -1. Why doesn't this work with Content Security Policy restrictions? +## Why doesn't this work with Content Security Policy restrictions? When not using the precompiler, Handlebars generates a dynamic function for each template which can cause issues with pages that have enabled Content Policy. It's recommended that templates are precompiled or the `unsafe-eval` policy is enabled for sites that must generate dynamic templates at runtime. -1. How can I include script tags in my template? +## How can I include script tags in my template? If loading the template via an inlined ` - - - - - - - - - - - - -
- - -