From 090a06bc52564b9ce98c24680db794b287292eba Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Tue, 8 May 2018 22:56:19 -0700 Subject: [PATCH 1/2] [CHORE] cull unnecessary files left from previous build setups --- lib/babel-build.js | 84 ------------------- lib/enable-optional-features-via-url/index.js | 35 -------- .../package.json | 6 -- ...allow-multiple-var-decl-with-assignment.js | 43 ---------- .../disallow-space-before-semicolon.js | 29 ------- ...-inside-round-braces-in-call-expression.js | 71 ---------------- ...ing-parenthesis-in-function-declaration.js | 57 ------------- lib/stripped-build.js | 8 -- package.json | 3 - tests/index.html | 1 - 10 files changed, 337 deletions(-) delete mode 100644 lib/babel-build.js delete mode 100644 lib/enable-optional-features-via-url/index.js delete mode 100644 lib/enable-optional-features-via-url/package.json delete mode 100644 lib/jscs-rules/disallow-multiple-var-decl-with-assignment.js delete mode 100644 lib/jscs-rules/disallow-space-before-semicolon.js delete mode 100644 lib/jscs-rules/disallow-space-inside-round-braces-in-call-expression.js delete mode 100644 lib/jscs-rules/require-spaces-after-closing-parenthesis-in-function-declaration.js delete mode 100644 lib/stripped-build.js diff --git a/lib/babel-build.js b/lib/babel-build.js deleted file mode 100644 index 89ac0e7854c..00000000000 --- a/lib/babel-build.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -var babel = require('broccoli-babel-transpiler'); -var moduleResolve = require('amd-name-resolver').moduleResolve; - -function getDebugMacroPlugins() { - const DebugMacros = require('babel-plugin-debug-macros').default; - const isProduction = process.env.EMBER_ENV === 'production'; - - let options = { - envFlags: { - source: '@glimmer/env', - flags: { DEBUG: !isProduction, CI: !!process.env.CI }, - }, - - externalizeHelpers: { - global: 'Ember', - }, - - debugTools: { - source: '@ember/debug', - }, - }; - - return [DebugMacros, options]; -} - -function babelOptions(libraryName, _options) { - _options = _options || {}; - - var options = { - plugins: [], - postTransformPlugins: [], - sourceMaps: false, - moduleRoot: libraryName, - moduleIds: true, - // Transforms /index.js files to use their containing directory name - getModuleId: function(name) { - return name.replace(/\/index$/g, ''); - }, - resolveModuleSource: function(source, fileName) { - return moduleResolve.call(this, source, libraryName + '/' + fileName); - }, - }; - - Object.keys(_options).forEach(function(opt) { - options[opt] = _options[opt]; - }); - - options.plugins = options.plugins - .concat( - [ - getDebugMacroPlugins(), - [ - 'ember-modules-api-polyfill', - { blacklist: { '@ember/debug': ['assert', 'deprecate', 'warn'] } }, - ], - ['transform-es2015-modules-amd', { noInterop: true, loose: true }], - 'transform-es2015-arrow-functions', - 'transform-es2015-computed-properties', - 'transform-es2015-shorthand-properties', - 'transform-es2015-template-literals', - 'transform-es2015-parameters', - 'transform-es2015-destructuring', - 'transform-es2015-spread', - 'transform-es2015-block-scoping', - 'transform-es2015-constants', - ['transform-es2015-classes', { loose: true }], - ], - options.postTransformPlugins - ) - .filter(Boolean); - - // this is not a "real" babel option, so we delete it - delete options.postTransformPlugins; - - return options; -} - -module.exports = function(packageName, tree, _options) { - var options = babelOptions(packageName, _options); - - return babel(tree, options); -}; diff --git a/lib/enable-optional-features-via-url/index.js b/lib/enable-optional-features-via-url/index.js deleted file mode 100644 index 2819bec72c2..00000000000 --- a/lib/enable-optional-features-via-url/index.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = { - name: 'enable-optional-features-via-url', - - /** - So the ENABLE_OPTIONAL_FEATURES flag is considered correctly within the - index.html, it needs to be set before Ember.js is loaded. Since there is - currently no way to access the `window` object within config/environment.js - (and hereby check if there is a query parameter present for the checkbox), - a script is injected, before Ember.js is loaded. The script checks if there - is no value yet for the ENABLE_OPTIONAL_FEATURES flag, and if so, it sets - the flag to true when there is a `enableoptionalfeatures` query parameter. - */ - contentFor: function(name) { - if (name === 'enable-optional-features') { - var array = [ - '', - ]; - - return array.join('\n'); - } - }, -}; diff --git a/lib/enable-optional-features-via-url/package.json b/lib/enable-optional-features-via-url/package.json deleted file mode 100644 index ea6c08dab4d..00000000000 --- a/lib/enable-optional-features-via-url/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "enable-optional-features-via-url", - "keywords": [ - "ember-addon" - ] -} diff --git a/lib/jscs-rules/disallow-multiple-var-decl-with-assignment.js b/lib/jscs-rules/disallow-multiple-var-decl-with-assignment.js deleted file mode 100644 index dd851874a4d..00000000000 --- a/lib/jscs-rules/disallow-multiple-var-decl-with-assignment.js +++ /dev/null @@ -1,43 +0,0 @@ -var assert = require('assert'); - -module.exports = function() {}; - -module.exports.prototype = { - configure: function(disallowMultipleVarDeclWithAssignment) { - assert( - typeof disallowMultipleVarDeclWithAssignment === 'boolean', - 'disallowMultipleVarDeclWithAssignment option requires boolean value' - ); - assert( - disallowMultipleVarDeclWithAssignment === true, - 'disallowMultipleVarDeclWithAssignment option requires true value or should be removed' - ); - }, - - getOptionName: function() { - return 'disallowMultipleVarDeclWithAssignment'; - }, - - check: function(file, errors) { - file.iterateNodesByType('VariableDeclaration', function(node) { - // allow multiple var declarations in for statement - // for (var i = 0, j = myArray.length; i < j; i++) {} - if (node.parentNode.type === 'ForStatement') { - return; - } - - var hasAssignment = false; - var multiDeclaration = node.declarations.length > 1; - - node.declarations.forEach(function(declaration) { - if (declaration.init) { - hasAssignment = true; - } - }); - - if (hasAssignment && multiDeclaration) { - errors.add('Multiple assigning variable declarations', node.loc.start); - } - }); - }, -}; diff --git a/lib/jscs-rules/disallow-space-before-semicolon.js b/lib/jscs-rules/disallow-space-before-semicolon.js deleted file mode 100644 index c7c711b38c2..00000000000 --- a/lib/jscs-rules/disallow-space-before-semicolon.js +++ /dev/null @@ -1,29 +0,0 @@ -var assert = require('assert'); - -module.exports = function() {}; - -module.exports.prototype = { - configure: function(disallowSpacesBeforeSemicolons) { - assert( - typeof disallowSpacesBeforeSemicolons === 'boolean', - 'disallowSpacesBeforeSemicolons option requires boolean value' - ); - assert( - disallowSpacesBeforeSemicolons === true, - 'disallowSpacesBeforeSemicolons option requires true value or should be removed' - ); - }, - - getOptionName: function() { - return 'disallowSpacesBeforeSemicolons'; - }, - - check: function(file, errors) { - var lines = file.getLines(); - for (var i = 0; i < lines.length; i++) { - if (lines[i].match(/\s+;$/)) { - errors.add('Spaces are disallowed before semicolons.', i + 1, lines[i].length - 2); - } - } - }, -}; diff --git a/lib/jscs-rules/disallow-space-inside-round-braces-in-call-expression.js b/lib/jscs-rules/disallow-space-inside-round-braces-in-call-expression.js deleted file mode 100644 index cae0a4d67b1..00000000000 --- a/lib/jscs-rules/disallow-space-inside-round-braces-in-call-expression.js +++ /dev/null @@ -1,71 +0,0 @@ -var assert = require('assert'); - -function spaceAfterBrace(arg, braceToken) { - if (arg) { - var supportedArgs = arg.type !== 'UnaryExpression' && arg.type !== 'BinaryExpression'; - - return supportedArgs && braceToken.value === '(' && braceToken.range[1] + 1 === arg.range[0]; - } - - return false; -} - -function spaceBeforeBrace(arg, braceToken) { - if (arg) { - var supportedArgs = arg.type !== 'UnaryExpression' && arg.type !== 'BinaryExpression'; - - return supportedArgs && braceToken.value === ')' && braceToken.range[0] === arg.range[1] + 1; - } - - return false; -} - -module.exports = function() {}; - -module.exports.prototype = { - configure: function(requireSpacesInsideRoundBracesInCallExpression) { - assert( - requireSpacesInsideRoundBracesInCallExpression === true, - 'disallowSpacesInsideRoundBracesInCallExpression option requires true value or should be removed' - ); - }, - - getOptionName: function() { - return 'disallowSpacesInsideRoundBracesInCallExpression'; - }, - - check: function(file, errors) { - file.iterateNodesByType('CallExpression', function(node) { - var nodeBeforeRoundBrace = node; - - if (node.callee) { - nodeBeforeRoundBrace = node.callee; - } - - var roundBraceTokenStart = file.getTokenByRangeStart(nodeBeforeRoundBrace.range[0]); - var roundBraceTokenEnd = file.getTokenByRangeStart(nodeBeforeRoundBrace.range[0]); - - do { - roundBraceTokenStart = file.findNextToken(roundBraceTokenStart, 'Punctuator', '('); - roundBraceTokenEnd = file.findNextToken(roundBraceTokenEnd, 'Punctuator', ')'); - } while (roundBraceTokenStart.range[0] < nodeBeforeRoundBrace.range[1]); - - var firstArg = nodeBeforeRoundBrace.parentNode.arguments[0]; - var lastArg = - nodeBeforeRoundBrace.parentNode.arguments[ - nodeBeforeRoundBrace.parentNode.arguments.length - 1 - ]; - - var spaceAfterOpeningRoundBraceExists = spaceAfterBrace(firstArg, roundBraceTokenStart); - var spaceBeforeClosingRoundBraceExists = spaceBeforeBrace(lastArg, roundBraceTokenEnd); - - if (spaceAfterOpeningRoundBraceExists) { - errors.add('Illegal space after opening round brace', roundBraceTokenStart.loc.start); - } - - if (spaceBeforeClosingRoundBraceExists) { - errors.add('Illegal space before closing round brace', roundBraceTokenEnd.loc.start); - } - }); - }, -}; diff --git a/lib/jscs-rules/require-spaces-after-closing-parenthesis-in-function-declaration.js b/lib/jscs-rules/require-spaces-after-closing-parenthesis-in-function-declaration.js deleted file mode 100644 index 62120235446..00000000000 --- a/lib/jscs-rules/require-spaces-after-closing-parenthesis-in-function-declaration.js +++ /dev/null @@ -1,57 +0,0 @@ -var assert = require('assert'); - -module.exports = function() {}; - -module.exports.prototype = { - configure: function(options) { - assert( - typeof options === 'object', - 'requireSpacesAfterClosingParenthesisInFunctionDeclaration option must be the object' - ); - - assert( - options.beforeOpeningCurlyBrace || options.beforeOpeningRoundBrace, - 'requireSpacesAfterClosingParenthesisInFunctionDeclaration must have beforeOpeningCurlyBrace or beforeOpeningRoundBrace property' - ); - - this._beforeOpeningRoundBrace = Boolean(options.beforeOpeningRoundBrace); - this._beforeOpeningCurlyBrace = Boolean(options.beforeOpeningCurlyBrace); - }, - - getOptionName: function() { - return 'requireSpacesAfterClosingParenthesisInFunctionDeclaration'; - }, - - check: function(file, errors) { - var beforeOpeningRoundBrace = this._beforeOpeningRoundBrace; - var beforeOpeningCurlyBrace = this._beforeOpeningCurlyBrace; - - file.iterateNodesByType(['FunctionDeclaration'], function(node) { - var functionToken = file.getFirstNodeToken(node.id || node); - var nextToken = file.getNextToken(functionToken); - - if (beforeOpeningRoundBrace) { - if (nextToken) { - errors.add('Missing space before opening round brace', nextToken.loc.start); - } - } else { - if (!nextToken) { - errors.add('Illegal space before opening round brace', functionToken.loc.end); - } - } - - // errors if no token is found unless `includeComments` is passed - var tokenBeforeBody = file.getPrevToken(node.body, { includeComments: true }); - - if (beforeOpeningCurlyBrace) { - if (tokenBeforeBody) { - errors.add('Missing space before opening curly brace', tokenBeforeBody.loc.start); - } - } else { - if (!tokenBeforeBody) { - errors.add('Illegal space before opening curly brace', node.body.loc.end); - } - } - }); - }, -}; diff --git a/lib/stripped-build.js b/lib/stripped-build.js deleted file mode 100644 index f70e7a8723c..00000000000 --- a/lib/stripped-build.js +++ /dev/null @@ -1,8 +0,0 @@ -var babelBuild = require('./babel-build'); -var strippedBuildPlugins = require('./stripped-build-plugins'); - -module.exports = function(packageName, tree, environmentBuildingFor) { - var options = strippedBuildPlugins(environmentBuildingFor); - - return babelBuild(packageName, tree, options); -}; diff --git a/package.json b/package.json index 375a360cd77..a6723173982 100644 --- a/package.json +++ b/package.json @@ -122,9 +122,6 @@ ], "ember-addon": { "configPath": "tests/dummy/config", - "paths": [ - "lib/enable-optional-features-via-url" - ], "after": "ember-cli-mocha" } } diff --git a/tests/index.html b/tests/index.html index 1f02805e3bf..5209b852321 100644 --- a/tests/index.html +++ b/tests/index.html @@ -20,7 +20,6 @@ {{content-for "body"}} {{content-for "test-body"}} - {{content-for "enable-optional-features"}} From 5a67afa840b6b3ed51b1b23eb39cd5973a82b03f Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Tue, 8 May 2018 22:58:25 -0700 Subject: [PATCH 2/2] dont need to be after mocha for detection --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index a6723173982..52c9b27ac05 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,6 @@ "ember-addon" ], "ember-addon": { - "configPath": "tests/dummy/config", - "after": "ember-cli-mocha" + "configPath": "tests/dummy/config" } }