babel-plugin-htmlbars-inline-precompile
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -11,3 +11,3 @@ 'use strict'; | ||
describe('htmlbars-inline-precompile', function() { | ||
describe('htmlbars-inline-precompile', function () { | ||
let precompile, plugins, optionsReceived; | ||
@@ -24,3 +24,3 @@ | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
optionsReceived = undefined; | ||
@@ -44,3 +44,3 @@ precompile = (template, options) => { | ||
it('passes options when used as a call expression', function() { | ||
it('passes options when used as a call expression', function () { | ||
let source = 'hello'; | ||
@@ -54,3 +54,3 @@ transform(`import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs('${source}');`); | ||
it('allows static userland options when used as a call expression', function() { | ||
it('allows static userland options when used as a call expression', function () { | ||
let source = 'hello'; | ||
@@ -75,3 +75,3 @@ transform( | ||
it('adds a comment with the original template string', function() { | ||
it('adds a comment with the original template string', function () { | ||
let transformed = transform(stripIndent` | ||
@@ -95,3 +95,3 @@ import hbs from 'htmlbars-inline-precompile'; | ||
it('avoids a build time error when passed `insertRuntimeErrors`', function() { | ||
it('avoids a build time error when passed `insertRuntimeErrors`', function () { | ||
precompile = () => { | ||
@@ -112,3 +112,3 @@ throw new Error('NOOOOOOOOOOOOOOOOOOOOOO'); | ||
it('escapes any */ included in the template string', function() { | ||
it('escapes any */ included in the template string', function () { | ||
let transformed = transform(stripIndent` | ||
@@ -132,3 +132,3 @@ import hbs from 'htmlbars-inline-precompile'; | ||
it('passes options when used as a tagged template string', function() { | ||
it('passes options when used as a tagged template string', function () { | ||
let source = 'hello'; | ||
@@ -142,3 +142,3 @@ transform(`import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs\`${source}\`;`); | ||
it("strips import statement for 'htmlbars-inline-precompile' module", function() { | ||
it("strips import statement for 'htmlbars-inline-precompile' module", function () { | ||
let transformed = transform( | ||
@@ -151,3 +151,3 @@ "import hbs from 'htmlbars-inline-precompile';\nimport Ember from 'ember';" | ||
it('throws error when import statement is not using default specifier', function() { | ||
it('throws error when import statement is not using default specifier', function () { | ||
expect(() => transform("import { hbs } from 'htmlbars-inline-precompile'")).toThrow( | ||
@@ -164,3 +164,3 @@ /Only `import hbs from 'htmlbars-inline-precompile'` is supported/, | ||
it('throws error when import statement is not using custom specifier', function() { | ||
it('throws error when import statement is not using custom specifier', function () { | ||
plugins[0][1].modules = { | ||
@@ -181,3 +181,3 @@ 'foo-bar': 'baz', | ||
it('replaces tagged template expressions with precompiled version', function() { | ||
it('replaces tagged template expressions with precompiled version', function () { | ||
let transformed = transform( | ||
@@ -193,3 +193,3 @@ "import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs`hello`;" | ||
it('replaces tagged template expressions with precompiled version for custom import paths with named exports', function() { | ||
it('replaces tagged template expressions with precompiled version for custom import paths with named exports', function () { | ||
plugins[0][1].modules = { | ||
@@ -206,3 +206,3 @@ 'foo-bar': 'baz', | ||
it('replaces tagged template expressions with precompiled version for custom import paths', function() { | ||
it('replaces tagged template expressions with precompiled version for custom import paths', function () { | ||
plugins[0][1].modulePaths = ['ember-cli-htmlbars-inline-precompile']; | ||
@@ -219,3 +219,3 @@ | ||
it('does not cause an error when no import is found', function() { | ||
it('does not cause an error when no import is found', function () { | ||
expect(() => transform('something("whatever")')).not.toThrow(); | ||
@@ -225,3 +225,3 @@ expect(() => transform('something`whatever`')).not.toThrow(); | ||
it('works with multiple imports', function() { | ||
it('works with multiple imports', function () { | ||
let transformed = transform(` | ||
@@ -239,3 +239,3 @@ import hbs from 'htmlbars-inline-precompile'; | ||
it('works properly when used along with modules transform', function() { | ||
it('works properly when used along with modules transform', function () { | ||
plugins.push([TransformModules]); | ||
@@ -252,3 +252,3 @@ let transformed = transform( | ||
it('works properly when used after modules transform', function() { | ||
it('works properly when used after modules transform', function () { | ||
plugins.unshift([TransformModules]); | ||
@@ -265,3 +265,3 @@ let transformed = transform( | ||
it('replaces tagged template expressions when before babel-plugin-transform-es2015-template-literals', function() { | ||
it('replaces tagged template expressions when before babel-plugin-transform-es2015-template-literals', function () { | ||
plugins.push([TransformTemplateLiterals]); | ||
@@ -278,3 +278,3 @@ let transformed = transform( | ||
it("doesn't replace unrelated tagged template strings", function() { | ||
it("doesn't replace unrelated tagged template strings", function () { | ||
let transformed = transform( | ||
@@ -290,3 +290,3 @@ 'import hbs from "htmlbars-inline-precompile";\nvar compiled = anotherTag`hello`;' | ||
it('warns when the tagged template string contains placeholders', function() { | ||
it('warns when the tagged template string contains placeholders', function () { | ||
expect(() => | ||
@@ -299,4 +299,4 @@ transform( | ||
describe('caching', function() { | ||
it('include `baseDir` function for caching', function() { | ||
describe('caching', function () { | ||
it('include `baseDir` function for caching', function () { | ||
expect(HTMLBarsInlinePrecompile.baseDir()).toEqual(path.resolve(__dirname, '..')); | ||
@@ -306,4 +306,4 @@ }); | ||
describe('single string argument', function() { | ||
it("works with a plain string as parameter hbs('string')", function() { | ||
describe('single string argument', function () { | ||
it("works with a plain string as parameter hbs('string')", function () { | ||
let transformed = transform( | ||
@@ -319,3 +319,3 @@ "import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs('hello');" | ||
it('warns when the second argument is not an object', function() { | ||
it('warns when the second argument is not an object', function () { | ||
expect(() => | ||
@@ -330,3 +330,3 @@ transform( | ||
it('warns when argument is not a string', function() { | ||
it('warns when argument is not a string', function () { | ||
expect(() => | ||
@@ -337,3 +337,3 @@ transform("import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs(123);") | ||
it('warns when no argument is passed', function() { | ||
it('warns when no argument is passed', function () { | ||
expect(() => | ||
@@ -345,6 +345,6 @@ transform("import hbs from 'htmlbars-inline-precompile';\nvar compiled = hbs();") | ||
describe('with ember-source', function() { | ||
describe('with ember-source', function () { | ||
const compiler = require('ember-source/dist/ember-template-compiler'); | ||
beforeEach(function() { | ||
beforeEach(function () { | ||
precompile = (template, options) => { | ||
@@ -355,3 +355,3 @@ return compiler.precompile(template, options); | ||
it('includes the original template content', function() { | ||
it('includes the original template content', function () { | ||
let transformed = transform(stripIndent` | ||
@@ -358,0 +358,0 @@ import hbs from 'htmlbars-inline-precompile'; |
@@ -0,1 +1,14 @@ | ||
## v4.0.0 (2020-05-06) | ||
#### :boom: Breaking Change | ||
* [#210](https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile/pull/210) Drop Node 8 support. ([@rwjblue](https://github.com/rwjblue)) | ||
#### :house: Internal | ||
* [#211](https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile/pull/211) Update release automation dependencies and settings. ([@rwjblue](https://github.com/rwjblue)) | ||
#### Committers: 2 | ||
- Robert Jackson ([@rwjblue](https://github.com/rwjblue)) | ||
- [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview) | ||
## v3.1.0 (2020-05-06) | ||
@@ -2,0 +15,0 @@ |
16
index.js
'use strict'; | ||
module.exports = function(babel) { | ||
module.exports = function (babel) { | ||
let t = babel.types; | ||
@@ -46,3 +46,3 @@ | ||
function buildArrayExpression(array) { | ||
return t.arrayExpression(array.map(i => buildExpression(i))); | ||
return t.arrayExpression(array.map((i) => buildExpression(i))); | ||
} | ||
@@ -69,3 +69,3 @@ | ||
function parseArrayExpression(buildError, node) { | ||
let result = node.elements.map(element => parseExpression(buildError, element)); | ||
let result = node.elements.map((element) => parseExpression(buildError, element)); | ||
@@ -78,3 +78,3 @@ return result; | ||
node.properties.forEach(property => { | ||
node.properties.forEach((property) => { | ||
if (property.computed || !['Identifier', 'StringLiteral'].includes(property.key.type)) { | ||
@@ -142,7 +142,7 @@ throw buildError('hbs can only accept static options'); | ||
modulePaths.forEach(path => (modules[path] = 'default')); | ||
modulePaths.forEach((path) => (modules[path] = 'default')); | ||
} | ||
let modulePaths = Object.keys(modules); | ||
let matchingModulePath = modulePaths.find(value => t.isLiteral(node.source, { value })); | ||
let matchingModulePath = modulePaths.find((value) => t.isLiteral(node.source, { value })); | ||
let modulePathExport = modules[matchingModulePath]; | ||
@@ -196,3 +196,3 @@ | ||
let template = path.node.quasi.quasis.map(quasi => quasi.value.cooked).join(''); | ||
let template = path.node.quasi.quasis.map((quasi) => quasi.value.cooked).join(''); | ||
@@ -258,4 +258,4 @@ path.replaceWith(compileTemplate(state.opts.precompile, template)); | ||
module.exports.baseDir = function() { | ||
module.exports.baseDir = function () { | ||
return __dirname; | ||
}; |
{ | ||
"name": "babel-plugin-htmlbars-inline-precompile", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "Babel plugin to replace tagged template strings with precompiled HTMLBars templates", | ||
@@ -12,7 +12,2 @@ "repository": "https://github.com/ember-cli/babel-plugin-htmlbars-inline-precompile", | ||
}, | ||
"jest": { | ||
"projects": [ | ||
"<rootDir>/jest-test.config.js" | ||
] | ||
}, | ||
"devDependencies": { | ||
@@ -23,3 +18,3 @@ "@babel/core": "^7.9.6", | ||
"common-tags": "^1.8.0", | ||
"ember-source": "^3.17.3", | ||
"ember-source": "^3.18.1", | ||
"eslint": "^6.8.0", | ||
@@ -29,9 +24,9 @@ "eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jest": "^24.9.0", | ||
"prettier": "^1.19.1", | ||
"release-it": "^12.4.3", | ||
"release-it-lerna-changelog": "^1.0.3" | ||
"jest": "^26.0.1", | ||
"prettier": "^2.0.5", | ||
"release-it": "^13.5.7", | ||
"release-it-lerna-changelog": "^2.3.0" | ||
}, | ||
"engines": { | ||
"node": "8.* || 10.* || >= 12.*" | ||
"node": "10.* || >= 12.*" | ||
}, | ||
@@ -44,3 +39,4 @@ "publishConfig": { | ||
"release-it-lerna-changelog": { | ||
"infile": "CHANGELOG.md" | ||
"infile": "CHANGELOG.md", | ||
"launchEditor": true | ||
} | ||
@@ -52,5 +48,6 @@ }, | ||
"github": { | ||
"release": true | ||
"release": true, | ||
"tokenRef": "GITHUB_AUTH" | ||
} | ||
} | ||
} |
@@ -17,3 +17,3 @@ # Release | ||
[keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall | ||
guiding principles here is that changelogs are for humans, not machines. | ||
guiding principle here is that changelogs are for humans, not machines. | ||
@@ -51,12 +51,12 @@ When reviewing merged PR's the labels to be used are: | ||
``` | ||
# using yarn | ||
yarn install | ||
# using npm | ||
npm install | ||
``` | ||
* And last (but not least π) do your release: | ||
* And last (but not least π) do your release. It requires a | ||
[GitHub personal access token](https://github.com/settings/tokens) as | ||
`$GITHUB_AUTH` environment variable. Only "repo" access is needed; no "admin" | ||
or other scopes are required. | ||
``` | ||
export GITHUB_AUTH="f941e0..." | ||
release-it | ||
@@ -66,3 +66,5 @@ ``` | ||
[release-it](https://github.com/release-it/release-it/) manages the actual | ||
release process. It will prompt you through the process of choosing the version | ||
number, tagging, pushing the tag and commits, etc. | ||
release process. It will prompt you to to choose the version number after which | ||
you will have the chance to hand tweak the changelog to be used (for the | ||
`CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging, | ||
pushing the tag and commits, etc. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39473