Skip to content

Commit

Permalink
Upgrade prettier to v2
Browse files Browse the repository at this point in the history
Prettier v2 has the following breaking changes:
* enforces spaces between `function` and params
* enforces trailing commas by default
  • Loading branch information
jaylinski committed Oct 29, 2022
1 parent f6ff3bf commit e534a91
Show file tree
Hide file tree
Showing 104 changed files with 1,868 additions and 1,893 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module.exports = {
extends: ['eslint:recommended', 'plugin:compat/recommended', 'prettier'],
globals: {
self: false
self: false,
},
env: {
node: true,
es2020: true
es2020: true,
},
parserOptions: {
sourceType: 'module'
sourceType: 'module',
},
rules: {
'no-console': 'warn',
Expand Down Expand Up @@ -59,6 +59,6 @@ module.exports = {

// ECMAScript 6 //
//--------------//
'no-var': 'error'
}
'no-var': 'error',
},
};
85 changes: 45 additions & 40 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-process-env */
module.exports = function(grunt) {
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

Expand All @@ -8,76 +8,81 @@ module.exports = function(grunt) {
copy: {
dist: {
options: {
processContent: function(content) {
processContent: function (content) {
return (
grunt.template.process(
'/**!\n\n @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n'
) +
content +
'\n// @license-end\n'
);
}
},
},
files: [{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/' }]
files: [{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/' }],
},
components: {
files: [
{
expand: true,
cwd: 'components/',
src: ['**'],
dest: 'dist/components'
dest: 'dist/components',
},
{
expand: true,
cwd: 'dist/',
src: ['*.js'],
dest: 'dist/components',
},
{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/components' }
]
}
],
},
},

babel: {
options: {
sourceMaps: 'inline',
loose: ['es6.modules'],
auxiliaryCommentBefore: 'istanbul ignore next'
auxiliaryCommentBefore: 'istanbul ignore next',
},
cjs: {
files: [
{
cwd: 'lib/',
expand: true,
src: '**/!(index).js',
dest: 'dist/cjs/'
}
]
}
dest: 'dist/cjs/',
},
],
},
},
webpack: {
options: {
context: __dirname,
output: {
path: 'dist/',
library: 'Handlebars',
libraryTarget: 'umd'
}
libraryTarget: 'umd',
},
},
handlebars: {
entry: './dist/cjs/handlebars.js',
output: {
filename: 'handlebars.js'
}
filename: 'handlebars.js',
},
},
runtime: {
entry: './dist/cjs/handlebars.runtime.js',
output: {
filename: 'handlebars.runtime.js'
}
}
filename: 'handlebars.runtime.js',
},
},
},

uglify: {
options: {
mangle: true,
compress: true,
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/
preserveComments: /(?:^!|@(?:license|preserve|cc_on))/,
},
dist: {
files: [
Expand All @@ -86,47 +91,47 @@ module.exports = function(grunt) {
expand: true,
src: ['handlebars*.js', '!*.min.js'],
dest: 'dist/',
rename: function(dest, src) {
rename: function (dest, src) {
return dest + src.replace(/\.js$/, '.min.js');
}
}
]
}
},
},
],
},
},

concat: {
tests: {
src: ['spec/!(require).js'],
dest: 'tmp/tests.js'
}
dest: 'tmp/tests.js',
},
},

connect: {
server: {
options: {
base: '.',
hostname: '*',
port: 9999
}
}
port: 9999,
},
},
},

shell: {
integrationTests: {
command: './tests/integration/run-integration-tests.sh'
}
command: './tests/integration/run-integration-tests.sh',
},
},

watch: {
scripts: {
options: {
atBegin: true
atBegin: true,
},

files: ['src/*', 'lib/**/*.js', 'spec/**/*.js'],
tasks: ['on-file-change']
}
}
tasks: ['on-file-change'],
},
},
});

// Load tasks from npm
Expand All @@ -148,15 +153,15 @@ module.exports = function(grunt) {
'uglify',
'test:min',
'copy:dist',
'copy:components'
'copy:components',
]);

// Requires secret properties from .travis.yaml
grunt.registerTask('extensive-tests-and-publish-to-aws', [
'default',
'shell:integrationTests',
'metrics',
'publish-to-aws'
'publish-to-aws',
]);

grunt.registerTask('on-file-change', ['build', 'concat:tests', 'test']);
Expand All @@ -174,6 +179,6 @@ module.exports = function(grunt) {
);
grunt.registerTask('integration-tests', [
'default',
'shell:integrationTests'
'shell:integrationTests',
]);
};
40 changes: 20 additions & 20 deletions bin/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,103 +5,103 @@ const yargs = require('yargs')
.option('f', {
type: 'string',
description: 'Output File',
alias: 'output'
alias: 'output',
})
.option('map', {
type: 'string',
description: 'Source Map File'
description: 'Source Map File',
})
.option('a', {
type: 'boolean',
description: 'Exports amd style (require.js)',
alias: 'amd'
alias: 'amd',
})
.option('c', {
type: 'string',
description: 'Exports CommonJS style, path to Handlebars module',
alias: 'commonjs',
default: null
default: null,
})
.option('h', {
type: 'string',
description: 'Path to handlebar.js (only valid for amd-style)',
alias: 'handlebarPath',
default: ''
default: '',
})
.option('k', {
type: 'string',
description: 'Known helpers',
alias: 'known'
alias: 'known',
})
.option('o', {
type: 'boolean',
description: 'Known helpers only',
alias: 'knownOnly'
alias: 'knownOnly',
})
.option('m', {
type: 'boolean',
description: 'Minimize output',
alias: 'min'
alias: 'min',
})
.option('n', {
type: 'string',
description: 'Template namespace',
alias: 'namespace',
default: 'Handlebars.templates'
default: 'Handlebars.templates',
})
.option('s', {
type: 'boolean',
description: 'Output template function only.',
alias: 'simple'
alias: 'simple',
})
.option('N', {
type: 'string',
description:
'Name of passed string templates. Optional if running in a simple mode. Required when operating on multiple templates.',
alias: 'name'
alias: 'name',
})
.option('i', {
type: 'string',
description:
'Generates a template from the passed CLI argument.\n"-" is treated as a special value and causes stdin to be read for the template value.',
alias: 'string'
alias: 'string',
})
.option('r', {
type: 'string',
description:
'Template root. Base value that will be stripped from template names.',
alias: 'root'
alias: 'root',
})
.option('p', {
type: 'boolean',
description: 'Compiling a partial template',
alias: 'partial'
alias: 'partial',
})
.option('d', {
type: 'boolean',
description: 'Include data when compiling',
alias: 'data'
alias: 'data',
})
.option('e', {
type: 'string',
description: 'Template extension.',
alias: 'extension',
default: 'handlebars'
default: 'handlebars',
})
.option('b', {
type: 'boolean',
description:
'Removes the BOM (Byte Order Mark) from the beginning of the templates.',
alias: 'bom'
alias: 'bom',
})
.option('v', {
type: 'boolean',
description: 'Prints the current compiler version',
alias: 'version'
alias: 'version',
})
.option('help', {
type: 'boolean',
description: 'Outputs this message'
description: 'Outputs this message',
})
.wrap(120);

Expand All @@ -110,7 +110,7 @@ argv.files = argv._;
delete argv._;

const Precompiler = require('../dist/cjs/precompiler');
Precompiler.loadTemplates(argv, function(err, opts) {
Precompiler.loadTemplates(argv, function (err, opts) {
if (err) {
throw err;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
module.exports = {
env: {
// Handlebars should run natively in the browser
node: false
}
node: false,
},
};
6 changes: 3 additions & 3 deletions lib/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
parser as Parser,
parse,
parseWithoutProcessing,
Visitor
Visitor,
} from '@handlebars/parser';

import runtime from './handlebars.runtime';
Expand All @@ -18,10 +18,10 @@ let _create = runtime.create;
function create() {
let hb = _create();

hb.compile = function(input, options) {
hb.compile = function (input, options) {
return compile(input, options, hb);
};
hb.precompile = function(input, options) {
hb.precompile = function (input, options) {
return precompile(input, options, hb);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/handlebars.runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function create() {
hb.escapeExpression = Utils.escapeExpression;

hb.VM = runtime;
hb.template = function(spec) {
hb.template = function (spec) {
return runtime.template(spec, hb);
};

Expand Down
Loading

0 comments on commit e534a91

Please sign in to comment.