From c06f72992406612e83afe091830ea0d2d30224b5 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Tue, 19 Sep 2017 00:09:12 +0200 Subject: [PATCH 01/12] Port code to ember-rfc176-data new format This PR adapts the code to the new format in ember-cli/ember-rfc176-data#37 This also removes a line testing an old shims not ported to new format. --- lib/rules/new-module-imports.js | 30 +++++++++++++++++++++++------- lib/rules/no-old-shims.js | 29 +++++++++++++++++++++++------ package.json | 2 +- tests/lib/rules/no-old-shims.js | 6 ------ 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/lib/rules/new-module-imports.js b/lib/rules/new-module-imports.js index 7187d0c3ca..9ff7066a30 100644 --- a/lib/rules/new-module-imports.js +++ b/lib/rules/new-module-imports.js @@ -1,7 +1,21 @@ 'use strict'; const EMBER_NAMESPACES = ['inject.controller', 'inject.service']; -const GLOBALS = require('ember-rfc176-data/globals.json'); +const MAPPING = require('ember-rfc176-data'); + +const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { + if (exportDefinition.deprecated) { + return memo; + } + + if (exportDefinition.global in memo) { + return memo; + } + + memo[exportDefinition.global] = exportDefinition; // eslint-disable-line no-param-reassign + + return memo; +}, Object.create(null)); //------------------------------------------------------------------------------ // General rule - Use "New Module Imports" from Ember RFC #176 @@ -67,7 +81,7 @@ module.exports = { fullName = fullNames[i]; const key = fullName.replace(/^Ember\./, ''); - const match = GLOBALS[key]; + const match = GLOBALS[fullName]; const reportedError = populateMessage({ node, fullName, key, match }); @@ -108,18 +122,20 @@ module.exports = { // Ex: import { inject as service } from '@ember/service'; const isNamespace = EMBER_NAMESPACES.indexOf(`${obj.parent}.${obj.key}`) !== -1; + const isNamedExport = obj.match.export !== 'default'; + let importSpecifier; let message; - if (obj.match[1] && !isNamespace) { - importSpecifier = obj.match[2] ? `{ ${obj.match[1]} as ${obj.match[2]} }` : `{ ${obj.match[1]} }`; - } else if (obj.match[1] && isNamespace) { + if (isNamedExport && !isNamespace) { + importSpecifier = obj.match.localName ? `{ ${obj.match.export} as ${obj.match.localName} }` : `{ ${obj.match.export} }`; + } else if (isNamedExport && isNamespace) { importSpecifier = `{ ${obj.parent} as ${obj.key} }`; } else { - importSpecifier = obj.match[2] || obj.customKey || obj.key; + importSpecifier = obj.match.localName || obj.customKey || obj.key; } - const replacement = `import ${importSpecifier} from '${obj.match[0]}';`; + const replacement = `import ${importSpecifier} from '${obj.match.module}';`; if (obj.type === 'Property') { message = `Use ${replacement} instead of using Ember destructuring`; diff --git a/lib/rules/no-old-shims.js b/lib/rules/no-old-shims.js index 6398db4268..789462a2ab 100644 --- a/lib/rules/no-old-shims.js +++ b/lib/rules/no-old-shims.js @@ -1,6 +1,22 @@ 'use strict'; -const oldShimsData = require('ember-rfc176-data/old-shims.json'); +const MAPPING = require('ember-rfc176-data'); + +const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { + if (!exportDefinition.deprecated) { + return memo; + } + + const { export: exportName, module: moduleName } = exportDefinition; + + if (!(moduleName in memo)) { + memo[moduleName] = {}; // eslint-disable-line no-param-reassign + } + + memo[moduleName][exportName] = exportDefinition; // eslint-disable-line no-param-reassign + + return memo; +}, Object.create(null)); //------------------------------------------------------------------------------ // General rule - Don't use import paths from ember-cli-shims @@ -23,11 +39,11 @@ module.exports = { return { ImportDeclaration(node) { const moduleName = node.source.value; - if (!(moduleName in oldShimsData)) { + if (!(moduleName in GLOBALS)) { return; } - const moduleMappings = oldShimsData[moduleName]; + const moduleMappings = GLOBALS[moduleName]; const fix = function (fixer) { const newImports = {}; @@ -43,12 +59,13 @@ module.exports = { } let module; - const moduleMapping = moduleMappings[importedName]; + let moduleMapping = moduleMappings[importedName]; if (!moduleMapping) { module = moduleName; } else { - module = moduleMapping[0]; - importedName = moduleMapping[1] || 'default'; + moduleMapping = moduleMapping.replacement; + module = moduleMapping.module; + importedName = moduleMapping.export; } newImports[module] = newImports[module] || []; diff --git a/package.json b/package.json index a158fc40b8..9d96bba637 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lerna-changelog": "^0.7.0" }, "dependencies": { - "ember-rfc176-data": "^0.2.7", + "ember-rfc176-data": "^0.3.0", "snake-case": "^2.1.0" }, "changelog": { diff --git a/tests/lib/rules/no-old-shims.js b/tests/lib/rules/no-old-shims.js index ec34c8bc6b..f1a4df745e 100644 --- a/tests/lib/rules/no-old-shims.js +++ b/tests/lib/rules/no-old-shims.js @@ -52,12 +52,6 @@ eslintTester.run('no-old-shims', rule, { parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, - { - code: 'import Sortable from \'ember-controllers/sortable\';', - output: 'import Sortable from \'ember-controllers/sortable\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], - }, { code: 'import Service from \'ember-service\';\nimport inject from \'ember-service/inject\';', output: 'import Service from \'@ember/service\';\nimport { inject } from \'@ember/service\';', From 9d4a9011f8939a06a1b684a028faf43b598d540a Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 20 Sep 2017 15:47:05 +0200 Subject: [PATCH 02/12] Point ember-rfc176-data to PR branch --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index dddc8efa88..bc4aeb663e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -896,9 +896,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -ember-rfc176-data@^0.2.7: +ember-rfc176-data@Turbo87/ember-rfc176-data#new-structure: version "0.2.7" - resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.2.7.tgz#bd355bc9b473e08096b518784170a23388bc973b" + resolved "https://codeload.github.com/Turbo87/ember-rfc176-data/tar.gz/e590c95e6d68145263dc5820637bdd6726407a37" encoding@^0.1.11: version "0.1.12" From 25b8561f32f7e8290c7825b7555f088e365e1dfa Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 20 Sep 2017 16:19:42 +0200 Subject: [PATCH 03/12] Undo destructuring to support Node 4 :'( --- lib/rules/no-old-shims.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-old-shims.js b/lib/rules/no-old-shims.js index 789462a2ab..010cadbe61 100644 --- a/lib/rules/no-old-shims.js +++ b/lib/rules/no-old-shims.js @@ -7,7 +7,8 @@ const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { return memo; } - const { export: exportName, module: moduleName } = exportDefinition; + const exportName = exportDefinition.export; + const moduleName = exportDefinition.module; if (!(moduleName in memo)) { memo[moduleName] = {}; // eslint-disable-line no-param-reassign From 4046121077b28ac31890c976816796f7818f92a5 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 20 Sep 2017 16:58:56 +0200 Subject: [PATCH 04/12] Create no-deprecated-modules rule and deprecate no-old-shims rule. --- lib/rules/no-deprecated-modules.js | 102 +++++++++++++++++++++++ lib/rules/no-old-shims.js | 1 + tests/lib/rules/no-deprecated-modules.js | 67 +++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 lib/rules/no-deprecated-modules.js create mode 100644 tests/lib/rules/no-deprecated-modules.js diff --git a/lib/rules/no-deprecated-modules.js b/lib/rules/no-deprecated-modules.js new file mode 100644 index 0000000000..ba882130b1 --- /dev/null +++ b/lib/rules/no-deprecated-modules.js @@ -0,0 +1,102 @@ +'use strict'; + +const MAPPING = require('ember-rfc176-data'); + +const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { + if (!exportDefinition.deprecated) { + return memo; + } + + const exportName = exportDefinition.export; + const moduleName = exportDefinition.module; + + if (!(moduleName in memo)) { + memo[moduleName] = {}; // eslint-disable-line no-param-reassign + } + + memo[moduleName][exportName] = exportDefinition; // eslint-disable-line no-param-reassign + + return memo; +}, Object.create(null)); + +//------------------------------------------------------------------------------ +// General rule - Don't use deprecated modules +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: 'Prevents usage of deprecated modules', + category: 'General', + recommended: false + }, + fixable: 'code', + }, + + create(context) { + const message = 'Don\'t use deprecated import paths'; + + return { + ImportDeclaration(node) { + const moduleName = node.source.value; + if (!(moduleName in GLOBALS)) { + return; + } + + const moduleMappings = GLOBALS[moduleName]; + + const fix = function (fixer) { + const newImports = {}; + + node.specifiers.forEach((specifier) => { + const localName = specifier.local.name; + + let importedName; + if (specifier.type === 'ImportDefaultSpecifier') { + importedName = 'default'; + } else { + importedName = specifier.imported.name; + } + + let module; + let moduleMapping = moduleMappings[importedName]; + if (!moduleMapping) { + module = moduleName; + } else { + moduleMapping = moduleMapping.replacement; + module = moduleMapping.module; + importedName = moduleMapping.export; + } + + newImports[module] = newImports[module] || []; + newImports[module].push({ localName, importedName }); + }); + + const lines = Object.keys(newImports).map((module) => { + const newModuleImport = newImports[module]; + + const defaultImport = newModuleImport + .filter(it => it.importedName === 'default') + .map(it => it.localName); + + const namedImports = newModuleImport + .filter(it => it.importedName !== 'default') + .map(it => (it.importedName !== it.localName ? `${it.importedName} as ${it.localName}` : it.importedName)) + .join(', '); + + const specifiers = defaultImport + .concat(namedImports ? `{ ${namedImports} }` : '') + .filter(Boolean) + .join(', '); + + return `import ${specifiers} from '${module}';`; + }); + + return fixer.replaceText(node, lines.join('\n')); + }; + + context.report({ node, message, fix }); + }, + }; + } +}; diff --git a/lib/rules/no-old-shims.js b/lib/rules/no-old-shims.js index 010cadbe61..689af6dbf5 100644 --- a/lib/rules/no-old-shims.js +++ b/lib/rules/no-old-shims.js @@ -32,6 +32,7 @@ module.exports = { url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-old-shims.md' }, fixable: 'code', + deprecated: true }, create(context) { diff --git a/tests/lib/rules/no-deprecated-modules.js b/tests/lib/rules/no-deprecated-modules.js new file mode 100644 index 0000000000..3f5c7be3f8 --- /dev/null +++ b/tests/lib/rules/no-deprecated-modules.js @@ -0,0 +1,67 @@ +// ------------------------------------------------------------------------------ +// Requirements +// ------------------------------------------------------------------------------ + +const rule = require('../../../lib/rules/no-deprecated-modules'); +const RuleTester = require('eslint').RuleTester; + +const message = 'Don\'t use deprecated import paths'; + +// ------------------------------------------------------------------------------ +// Tests +// ------------------------------------------------------------------------------ + +const eslintTester = new RuleTester(); +eslintTester.run('no-old-shims', rule, { + valid: [ + { + code: 'import Ember from \'ember\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + }, + { + code: 'import RSVP from \'rsvp\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + }, + ], + invalid: [ + { + code: 'import Component from \'ember-component\';', + output: 'import Component from \'@ember/component\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ message }], + }, + { + code: 'import { capitalize, dasherize, foo } from \'ember-string\';', + output: 'import { capitalize, dasherize } from \'@ember/string\';\nimport { foo } from \'ember-string\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ message }], + }, + { + code: 'import computed, { not } from \'ember-computed\';', + output: 'import { computed } from \'@ember/object\';\nimport { not } from \'@ember/object/computed\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ message }], + }, + { + code: 'import { log } from \'ember-debug\';', + output: 'import { debug as log } from \'@ember/debug\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ message }], + }, + { + code: 'import { log as debug } from \'ember-debug\';', + output: 'import { debug } from \'@ember/debug\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ message }], + }, + { + code: 'import Service from \'ember-service\';\nimport inject from \'ember-service/inject\';', + output: 'import Service from \'@ember/service\';\nimport { inject } from \'@ember/service\';', + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [ + { message }, + { message }, + ], + }, + ], +}); From 7f25c2b65f2259db7a2055782d7c4bab91f86e35 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Fri, 29 Sep 2017 14:07:08 +0200 Subject: [PATCH 05/12] Update no-old-shims rule --- lib/rules/no-deprecated-modules.js | 4 ++ lib/rules/no-old-shims.js | 70 ++++++++---------------------- tests/lib/rules/no-old-shims.js | 37 ++++++++-------- yarn.lock | 2 +- 4 files changed, 41 insertions(+), 72 deletions(-) diff --git a/lib/rules/no-deprecated-modules.js b/lib/rules/no-deprecated-modules.js index ba882130b1..fd802b2c3e 100644 --- a/lib/rules/no-deprecated-modules.js +++ b/lib/rules/no-deprecated-modules.js @@ -7,6 +7,10 @@ const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { return memo; } + if (!exportDefinition.replacement) { + return memo; + } + const exportName = exportDefinition.export; const moduleName = exportDefinition.module; diff --git a/lib/rules/no-old-shims.js b/lib/rules/no-old-shims.js index 689af6dbf5..0eae45e8be 100644 --- a/lib/rules/no-old-shims.js +++ b/lib/rules/no-old-shims.js @@ -7,6 +7,10 @@ const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { return memo; } + if (exportDefinition.replacement) { + return memo; + } + const exportName = exportDefinition.export; const moduleName = exportDefinition.module; @@ -36,8 +40,6 @@ module.exports = { }, create(context) { - const message = 'Don\'t use import paths from ember-cli-shims'; - return { ImportDeclaration(node) { const moduleName = node.source.value; @@ -47,58 +49,22 @@ module.exports = { const moduleMappings = GLOBALS[moduleName]; - const fix = function (fixer) { - const newImports = {}; - - node.specifiers.forEach((specifier) => { - const localName = specifier.local.name; - - let importedName; - if (specifier.type === 'ImportDefaultSpecifier') { - importedName = 'default'; - } else { - importedName = specifier.imported.name; - } - - let module; - let moduleMapping = moduleMappings[importedName]; - if (!moduleMapping) { - module = moduleName; - } else { - moduleMapping = moduleMapping.replacement; - module = moduleMapping.module; - importedName = moduleMapping.export; - } - - newImports[module] = newImports[module] || []; - newImports[module].push({ localName, importedName }); - }); + const deprecatedSpecifiers = node.specifiers + .map(importedName) + .filter(x => x in moduleMappings); - const lines = Object.keys(newImports).map((module) => { - const newModuleImport = newImports[module]; - - const defaultImport = newModuleImport - .filter(it => it.importedName === 'default') - .map(it => it.localName); - - const namedImports = newModuleImport - .filter(it => it.importedName !== 'default') - .map(it => (it.importedName !== it.localName ? `${it.importedName} as ${it.localName}` : it.importedName)) - .join(', '); - - const specifiers = defaultImport - .concat(namedImports ? `{ ${namedImports} }` : '') - .filter(Boolean) - .join(', '); - - return `import ${specifiers} from '${module}';`; - }); - - return fixer.replaceText(node, lines.join('\n')); - }; - - context.report({ node, message, fix }); + context.report({ + node, + message: `Importing ${deprecatedSpecifiers.join(', ')} from ${moduleName} is deprecated.` + }); }, }; } }; + +function importedName(specifier) { + if (specifier.type === 'ImportDefaultSpecifier') { + return 'default'; + } + return specifier.imported.name; +} diff --git a/tests/lib/rules/no-old-shims.js b/tests/lib/rules/no-old-shims.js index f1a4df745e..755d021bfa 100644 --- a/tests/lib/rules/no-old-shims.js +++ b/tests/lib/rules/no-old-shims.js @@ -23,42 +23,41 @@ eslintTester.run('no-old-shims', rule, { ], invalid: [ { - code: 'import Component from \'ember-component\';', - output: 'import Component from \'@ember/component\';', + code: "import SortableMixin from 'ember-controllers/sortable';", parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], + errors: [{ message: 'Importing default from ember-controllers/sortable is deprecated.' }] }, { - code: 'import { capitalize, dasherize, foo } from \'ember-string\';', - output: 'import { capitalize, dasherize } from \'@ember/string\';\nimport { foo } from \'ember-string\';', + code: "import destroy from 'ember-metal/destroy';", parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], + errors: [{ message: 'Importing default from ember-metal/destroy is deprecated.' }] }, { - code: 'import computed, { not } from \'ember-computed\';', - output: 'import { computed } from \'@ember/object\';\nimport { not } from \'@ember/object/computed\';', + code: "import OrderedSet from 'ember-set/ordered';", parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], + errors: [{ message: 'Importing default from ember-set/ordered is deprecated.' }] }, { - code: 'import { log } from \'ember-debug\';', - output: 'import { debug as log } from \'@ember/debug\';', + code: "import EmberTest from 'ember-test';", parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], + errors: [{ message: 'Importing default from ember-test is deprecated.' }] }, { - code: 'import { log as debug } from \'ember-debug\';', - output: 'import { debug } from \'@ember/debug\';', + code: "import QUnitAdapter from 'ember-test/qunit-adapter';", parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], + errors: [{ message: 'Importing default from ember-test/qunit-adapter is deprecated.' }] }, { - code: 'import Service from \'ember-service\';\nimport inject from \'ember-service/inject\';', - output: 'import Service from \'@ember/service\';\nimport { inject } from \'@ember/service\';', + code: "import { default as destroy } from 'ember-metal/destroy';", + parserOptions: { ecmaVersion: 6, sourceType: 'module' }, + errors: [{ message: 'Importing default from ember-metal/destroy is deprecated.' }], + }, + { + code: "import EmberTest from 'ember-test';\nimport QUnitAdapter from 'ember-test/qunit-adapter';", parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ - { message: 'Don\'t use import paths from ember-cli-shims' }, - { message: 'Don\'t use import paths from ember-cli-shims' }, + { message: 'Importing default from ember-test is deprecated.' }, + { message: 'Importing default from ember-test/qunit-adapter is deprecated.' } ], }, ], diff --git a/yarn.lock b/yarn.lock index bc4aeb663e..ed20c4144a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -898,7 +898,7 @@ ecc-jsbn@~0.1.1: ember-rfc176-data@Turbo87/ember-rfc176-data#new-structure: version "0.2.7" - resolved "https://codeload.github.com/Turbo87/ember-rfc176-data/tar.gz/e590c95e6d68145263dc5820637bdd6726407a37" + resolved "https://codeload.github.com/Turbo87/ember-rfc176-data/tar.gz/cddf169abc0974c0f5d8433b1bac0cf838f5baac" encoding@^0.1.11: version "0.1.12" From 91a11c639c4b5e275260eee274980cc234cde413 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Fri, 29 Sep 2017 15:16:08 +0200 Subject: [PATCH 06/12] Force upgrade of ember-rfc176-data --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e8db356714..bcea0ff222 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ node_js: cache: yarn script: + - yarn upgrade ember-rfc176-data - yarn run lint - yarn run test:coverage From 1c01596258ba110dba44fd7a05ce2e14c932e271 Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Wed, 4 Oct 2017 00:56:29 +0200 Subject: [PATCH 07/12] Update to ember-rfc176-data@0.3.0 --- .travis.yml | 1 - yarn.lock | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bcea0ff222..e8db356714 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ node_js: cache: yarn script: - - yarn upgrade ember-rfc176-data - yarn run lint - yarn run test:coverage diff --git a/yarn.lock b/yarn.lock index ed20c4144a..de25cf7a09 100644 --- a/yarn.lock +++ b/yarn.lock @@ -896,9 +896,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -ember-rfc176-data@Turbo87/ember-rfc176-data#new-structure: - version "0.2.7" - resolved "https://codeload.github.com/Turbo87/ember-rfc176-data/tar.gz/cddf169abc0974c0f5d8433b1bac0cf838f5baac" +ember-rfc176-data@^0.3.0: + version "0.3.2" + resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.2.tgz#bde5538939529b263c142b53a47402f8127f8dce" encoding@^0.1.11: version "0.1.12" From 065602d017b0e82b9a2dca096066438c4ee1b123 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 14 May 2018 15:47:36 -0400 Subject: [PATCH 08/12] Remove new `no-deprecated-modules` rule. --- lib/rules/no-deprecated-modules.js | 106 ----------------------- lib/rules/no-old-shims.js | 93 +++++++++++--------- tests/lib/rules/no-deprecated-modules.js | 67 -------------- tests/lib/rules/no-old-shims.js | 37 ++++---- 4 files changed, 76 insertions(+), 227 deletions(-) delete mode 100644 lib/rules/no-deprecated-modules.js delete mode 100644 tests/lib/rules/no-deprecated-modules.js diff --git a/lib/rules/no-deprecated-modules.js b/lib/rules/no-deprecated-modules.js deleted file mode 100644 index fd802b2c3e..0000000000 --- a/lib/rules/no-deprecated-modules.js +++ /dev/null @@ -1,106 +0,0 @@ -'use strict'; - -const MAPPING = require('ember-rfc176-data'); - -const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { - if (!exportDefinition.deprecated) { - return memo; - } - - if (!exportDefinition.replacement) { - return memo; - } - - const exportName = exportDefinition.export; - const moduleName = exportDefinition.module; - - if (!(moduleName in memo)) { - memo[moduleName] = {}; // eslint-disable-line no-param-reassign - } - - memo[moduleName][exportName] = exportDefinition; // eslint-disable-line no-param-reassign - - return memo; -}, Object.create(null)); - -//------------------------------------------------------------------------------ -// General rule - Don't use deprecated modules -//------------------------------------------------------------------------------ - -module.exports = { - meta: { - docs: { - description: 'Prevents usage of deprecated modules', - category: 'General', - recommended: false - }, - fixable: 'code', - }, - - create(context) { - const message = 'Don\'t use deprecated import paths'; - - return { - ImportDeclaration(node) { - const moduleName = node.source.value; - if (!(moduleName in GLOBALS)) { - return; - } - - const moduleMappings = GLOBALS[moduleName]; - - const fix = function (fixer) { - const newImports = {}; - - node.specifiers.forEach((specifier) => { - const localName = specifier.local.name; - - let importedName; - if (specifier.type === 'ImportDefaultSpecifier') { - importedName = 'default'; - } else { - importedName = specifier.imported.name; - } - - let module; - let moduleMapping = moduleMappings[importedName]; - if (!moduleMapping) { - module = moduleName; - } else { - moduleMapping = moduleMapping.replacement; - module = moduleMapping.module; - importedName = moduleMapping.export; - } - - newImports[module] = newImports[module] || []; - newImports[module].push({ localName, importedName }); - }); - - const lines = Object.keys(newImports).map((module) => { - const newModuleImport = newImports[module]; - - const defaultImport = newModuleImport - .filter(it => it.importedName === 'default') - .map(it => it.localName); - - const namedImports = newModuleImport - .filter(it => it.importedName !== 'default') - .map(it => (it.importedName !== it.localName ? `${it.importedName} as ${it.localName}` : it.importedName)) - .join(', '); - - const specifiers = defaultImport - .concat(namedImports ? `{ ${namedImports} }` : '') - .filter(Boolean) - .join(', '); - - return `import ${specifiers} from '${module}';`; - }); - - return fixer.replaceText(node, lines.join('\n')); - }; - - context.report({ node, message, fix }); - }, - }; - } -}; diff --git a/lib/rules/no-old-shims.js b/lib/rules/no-old-shims.js index 0eae45e8be..6398db4268 100644 --- a/lib/rules/no-old-shims.js +++ b/lib/rules/no-old-shims.js @@ -1,27 +1,6 @@ 'use strict'; -const MAPPING = require('ember-rfc176-data'); - -const GLOBALS = MAPPING.reduce((memo, exportDefinition) => { - if (!exportDefinition.deprecated) { - return memo; - } - - if (exportDefinition.replacement) { - return memo; - } - - const exportName = exportDefinition.export; - const moduleName = exportDefinition.module; - - if (!(moduleName in memo)) { - memo[moduleName] = {}; // eslint-disable-line no-param-reassign - } - - memo[moduleName][exportName] = exportDefinition; // eslint-disable-line no-param-reassign - - return memo; -}, Object.create(null)); +const oldShimsData = require('ember-rfc176-data/old-shims.json'); //------------------------------------------------------------------------------ // General rule - Don't use import paths from ember-cli-shims @@ -36,35 +15,71 @@ module.exports = { url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/no-old-shims.md' }, fixable: 'code', - deprecated: true }, create(context) { + const message = 'Don\'t use import paths from ember-cli-shims'; + return { ImportDeclaration(node) { const moduleName = node.source.value; - if (!(moduleName in GLOBALS)) { + if (!(moduleName in oldShimsData)) { return; } - const moduleMappings = GLOBALS[moduleName]; + const moduleMappings = oldShimsData[moduleName]; + + const fix = function (fixer) { + const newImports = {}; - const deprecatedSpecifiers = node.specifiers - .map(importedName) - .filter(x => x in moduleMappings); + node.specifiers.forEach((specifier) => { + const localName = specifier.local.name; - context.report({ - node, - message: `Importing ${deprecatedSpecifiers.join(', ')} from ${moduleName} is deprecated.` - }); + let importedName; + if (specifier.type === 'ImportDefaultSpecifier') { + importedName = 'default'; + } else { + importedName = specifier.imported.name; + } + + let module; + const moduleMapping = moduleMappings[importedName]; + if (!moduleMapping) { + module = moduleName; + } else { + module = moduleMapping[0]; + importedName = moduleMapping[1] || 'default'; + } + + newImports[module] = newImports[module] || []; + newImports[module].push({ localName, importedName }); + }); + + const lines = Object.keys(newImports).map((module) => { + const newModuleImport = newImports[module]; + + const defaultImport = newModuleImport + .filter(it => it.importedName === 'default') + .map(it => it.localName); + + const namedImports = newModuleImport + .filter(it => it.importedName !== 'default') + .map(it => (it.importedName !== it.localName ? `${it.importedName} as ${it.localName}` : it.importedName)) + .join(', '); + + const specifiers = defaultImport + .concat(namedImports ? `{ ${namedImports} }` : '') + .filter(Boolean) + .join(', '); + + return `import ${specifiers} from '${module}';`; + }); + + return fixer.replaceText(node, lines.join('\n')); + }; + + context.report({ node, message, fix }); }, }; } }; - -function importedName(specifier) { - if (specifier.type === 'ImportDefaultSpecifier') { - return 'default'; - } - return specifier.imported.name; -} diff --git a/tests/lib/rules/no-deprecated-modules.js b/tests/lib/rules/no-deprecated-modules.js deleted file mode 100644 index 3f5c7be3f8..0000000000 --- a/tests/lib/rules/no-deprecated-modules.js +++ /dev/null @@ -1,67 +0,0 @@ -// ------------------------------------------------------------------------------ -// Requirements -// ------------------------------------------------------------------------------ - -const rule = require('../../../lib/rules/no-deprecated-modules'); -const RuleTester = require('eslint').RuleTester; - -const message = 'Don\'t use deprecated import paths'; - -// ------------------------------------------------------------------------------ -// Tests -// ------------------------------------------------------------------------------ - -const eslintTester = new RuleTester(); -eslintTester.run('no-old-shims', rule, { - valid: [ - { - code: 'import Ember from \'ember\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - }, - { - code: 'import RSVP from \'rsvp\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - }, - ], - invalid: [ - { - code: 'import Component from \'ember-component\';', - output: 'import Component from \'@ember/component\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message }], - }, - { - code: 'import { capitalize, dasherize, foo } from \'ember-string\';', - output: 'import { capitalize, dasherize } from \'@ember/string\';\nimport { foo } from \'ember-string\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message }], - }, - { - code: 'import computed, { not } from \'ember-computed\';', - output: 'import { computed } from \'@ember/object\';\nimport { not } from \'@ember/object/computed\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message }], - }, - { - code: 'import { log } from \'ember-debug\';', - output: 'import { debug as log } from \'@ember/debug\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message }], - }, - { - code: 'import { log as debug } from \'ember-debug\';', - output: 'import { debug } from \'@ember/debug\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message }], - }, - { - code: 'import Service from \'ember-service\';\nimport inject from \'ember-service/inject\';', - output: 'import Service from \'@ember/service\';\nimport { inject } from \'@ember/service\';', - parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [ - { message }, - { message }, - ], - }, - ], -}); diff --git a/tests/lib/rules/no-old-shims.js b/tests/lib/rules/no-old-shims.js index 755d021bfa..ec34c8bc6b 100644 --- a/tests/lib/rules/no-old-shims.js +++ b/tests/lib/rules/no-old-shims.js @@ -23,41 +23,48 @@ eslintTester.run('no-old-shims', rule, { ], invalid: [ { - code: "import SortableMixin from 'ember-controllers/sortable';", + code: 'import Component from \'ember-component\';', + output: 'import Component from \'@ember/component\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Importing default from ember-controllers/sortable is deprecated.' }] + errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, { - code: "import destroy from 'ember-metal/destroy';", + code: 'import { capitalize, dasherize, foo } from \'ember-string\';', + output: 'import { capitalize, dasherize } from \'@ember/string\';\nimport { foo } from \'ember-string\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Importing default from ember-metal/destroy is deprecated.' }] + errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, { - code: "import OrderedSet from 'ember-set/ordered';", + code: 'import computed, { not } from \'ember-computed\';', + output: 'import { computed } from \'@ember/object\';\nimport { not } from \'@ember/object/computed\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Importing default from ember-set/ordered is deprecated.' }] + errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, { - code: "import EmberTest from 'ember-test';", + code: 'import { log } from \'ember-debug\';', + output: 'import { debug as log } from \'@ember/debug\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Importing default from ember-test is deprecated.' }] + errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, { - code: "import QUnitAdapter from 'ember-test/qunit-adapter';", + code: 'import { log as debug } from \'ember-debug\';', + output: 'import { debug } from \'@ember/debug\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Importing default from ember-test/qunit-adapter is deprecated.' }] + errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, { - code: "import { default as destroy } from 'ember-metal/destroy';", + code: 'import Sortable from \'ember-controllers/sortable\';', + output: 'import Sortable from \'ember-controllers/sortable\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, - errors: [{ message: 'Importing default from ember-metal/destroy is deprecated.' }], + errors: [{ message: 'Don\'t use import paths from ember-cli-shims' }], }, { - code: "import EmberTest from 'ember-test';\nimport QUnitAdapter from 'ember-test/qunit-adapter';", + code: 'import Service from \'ember-service\';\nimport inject from \'ember-service/inject\';', + output: 'import Service from \'@ember/service\';\nimport { inject } from \'@ember/service\';', parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ - { message: 'Importing default from ember-test is deprecated.' }, - { message: 'Importing default from ember-test/qunit-adapter is deprecated.' } + { message: 'Don\'t use import paths from ember-cli-shims' }, + { message: 'Don\'t use import paths from ember-cli-shims' }, ], }, ], From 5468e62f919dbaf29d4cb71f32af8e0715dccf42 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Mon, 14 May 2018 15:53:01 -0400 Subject: [PATCH 09/12] Inline old shim data into no-old-shims rule. --- lib/rules/no-old-shims.js | 242 +++++++++++++++++++++++++++++++++++++- 1 file changed, 241 insertions(+), 1 deletion(-) diff --git a/lib/rules/no-old-shims.js b/lib/rules/no-old-shims.js index 6398db4268..606e931dbe 100644 --- a/lib/rules/no-old-shims.js +++ b/lib/rules/no-old-shims.js @@ -1,6 +1,246 @@ 'use strict'; -const oldShimsData = require('ember-rfc176-data/old-shims.json'); +// inlined from +// https://github.com/ember-cli/ember-rfc176-data/blob/v0.2.7/old-shims.json +// the newer format of ember-rfc176-data no longer supports the distinction +// between "old shim" and "generally deprecated" +const oldShimsData = { + 'ember-application': { + default: ['@ember/application'] + }, + 'ember-array': { + default: ['@ember/array'] + }, + 'ember-array/mutable': { + default: ['@ember/array/mutable'] + }, + 'ember-array/utils': { + A: ['@ember/array', 'A'], + isEmberArray: ['@ember/array', 'isArray'], + wrap: ['@ember/array', 'makeArray'] + }, + 'ember-component': { + default: ['@ember/component'] + }, + 'ember-components/checkbox': { + default: ['@ember/component/checkbox'] + }, + 'ember-components/text-area': { + default: ['@ember/component/text-area'] + }, + 'ember-components/text-field': { + default: ['@ember/component/text-field'] + }, + 'ember-controller': { + default: ['@ember/controller'] + }, + 'ember-controller/inject': { + default: ['@ember/controller', 'inject'] + }, + 'ember-controller/proxy': { + default: ['@ember/array/proxy'] + }, + 'ember-controllers/sortable': { + default: null + }, + 'ember-debug': { + log: ['@ember/debug', 'debug'], + inspect: ['@ember/debug', 'inspect'], + run: ['@ember/debug', 'runInDebug'], + warn: ['@ember/debug', 'warn'] + }, + 'ember-debug/container-debug-adapter': { + default: ['@ember/debug/container-debug-adapter'] + }, + 'ember-debug/data-adapter': { + default: ['@ember/debug/data-adapter'] + }, + 'ember-deprecations': { + deprecate: ['@ember/application/deprecations', 'deprecate'], + deprecateFunc: ['@ember/application/deprecations', 'deprecateFunc'] + }, + 'ember-enumerable': { + default: ['@ember/enumerable'] + }, + 'ember-evented': { + default: ['@ember/object/evented'] + }, + 'ember-evented/on': { + default: ['@ember/object/evented', 'on'] + }, + 'ember-globals-resolver': { + default: ['@ember/application/globals-resolver', null, 'GlobalsResolver'] + }, + 'ember-helper': { + default: ['@ember/component/helper'], + helper: ['@ember/component/helper', 'helper'] + }, + 'ember-instrumentation': { + instrument: ['@ember/instrumentation', 'instrument'], + reset: ['@ember/instrumentation', 'reset'], + subscribe: ['@ember/instrumentation', 'subscribe'], + unsubscribe: ['@ember/instrumentation', 'unsubscribe'] + }, + 'ember-locations/hash': { + default: ['@ember/routing/hash-location'] + }, + 'ember-locations/history': { + default: ['@ember/routing/history-location'] + }, + 'ember-locations/none': { + default: ['@ember/routing/none-location'] + }, + 'ember-map': { + default: ['@ember/map'], + withDefault: ['@ember/map/with-default'] + }, + 'ember-metal/destroy': { + default: null + }, + 'ember-metal/events': { + addListener: ['@ember/object/events', 'addListener'], + removeListener: ['@ember/object/events', 'removeListener'], + send: ['@ember/object/events', 'sendEvent'] + }, + 'ember-metal/get': { + default: ['@ember/object', 'get'], + getProperties: ['@ember/object', 'getProperties'] + }, + 'ember-metal/mixin': { + default: ['@ember/object/mixin'] + }, + 'ember-metal/observer': { + default: ['@ember/object', 'observer'], + addObserver: ['@ember/object/observers', 'addObserver'], + removeObserver: ['@ember/object/observers', 'removeObserver'] + }, + 'ember-metal/on-load': { + default: ['@ember/application', 'onLoad'], + run: ['@ember/application', 'runLoadHooks'] + }, + 'ember-metal/set': { + default: ['@ember/object', 'set'], + setProperties: ['@ember/object', 'setProperties'], + trySet: ['@ember/object', 'trySet'] + }, + 'ember-metal/utils': { + aliasMethod: ['@ember/object', 'aliasMethod'], + assert: ['@ember/debug', 'assert'], + cacheFor: ['@ember/object/internals', 'cacheFor'], + copy: ['@ember/object/internals', 'copy'], + guidFor: ['@ember/object/internals', 'guidFor'] + }, + 'ember-object': { + default: ['@ember/object'] + }, + 'ember-owner/get': { + default: ['@ember/application', 'getOwner'] + }, + 'ember-owner/set': { + default: ['@ember/application', 'setOwner'] + }, + 'ember-platform': { + assign: ['@ember/polyfills', 'assign'], + create: ['@ember/polyfills', 'create'], + hasAccessors: ['@ember/polyfills', 'hasPropertyAccessors'], + keys: ['@ember/polyfills', 'keys'] + }, + 'ember-route': { + default: ['@ember/routing/route'] + }, + 'ember-router': { + default: ['@ember/routing/router'] + }, + 'ember-runloop': { + default: ['@ember/runloop', 'run'], + begin: ['@ember/runloop', 'begin'], + bind: ['@ember/runloop', 'bind'], + cancel: ['@ember/runloop', 'cancel'], + debounce: ['@ember/runloop', 'debounce'], + end: ['@ember/runloop', 'end'], + join: ['@ember/runloop', 'join'], + later: ['@ember/runloop', 'later'], + next: ['@ember/runloop', 'next'], + once: ['@ember/runloop', 'once'], + schedule: ['@ember/runloop', 'schedule'], + scheduleOnce: ['@ember/runloop', 'scheduleOnce'], + throttle: ['@ember/runloop', 'throttle'] + }, + 'ember-service': { + default: ['@ember/service'] + }, + 'ember-service/inject': { + default: ['@ember/service', 'inject'] + }, + 'ember-set/ordered': { + default: null + }, + 'ember-string': { + camelize: ['@ember/string', 'camelize'], + capitalize: ['@ember/string', 'capitalize'], + classify: ['@ember/string', 'classify'], + dasherize: ['@ember/string', 'dasherize'], + decamelize: ['@ember/string', 'decamelize'], + fmt: ['@ember/string', 'fmt'], + htmlSafe: ['@ember/string', 'htmlSafe'], + loc: ['@ember/string', 'loc'], + underscore: ['@ember/string', 'underscore'], + w: ['@ember/string', 'w'] + }, + 'ember-utils': { + isBlank: ['@ember/utils', 'isBlank'], + isEmpty: ['@ember/utils', 'isEmpty'], + isNone: ['@ember/utils', 'isNone'], + isPresent: ['@ember/utils', 'isPresent'], + tryInvoke: ['@ember/utils', 'tryInvoke'], + typeOf: ['@ember/utils', 'typeOf'] + }, + 'ember-computed': { + default: ['@ember/object', 'computed'], + empty: ['@ember/object/computed', 'empty'], + notEmpty: ['@ember/object/computed', 'notEmpty'], + none: ['@ember/object/computed', 'none'], + not: ['@ember/object/computed', 'not'], + bool: ['@ember/object/computed', 'bool'], + match: ['@ember/object/computed', 'match'], + equal: ['@ember/object/computed', 'equal'], + gt: ['@ember/object/computed', 'gt'], + gte: ['@ember/object/computed', 'gte'], + lt: ['@ember/object/computed', 'lt'], + lte: ['@ember/object/computed', 'lte'], + alias: ['@ember/object/computed', 'alias'], + oneWay: ['@ember/object/computed', 'oneWay'], + reads: ['@ember/object/computed', 'reads'], + readOnly: ['@ember/object/computed', 'readOnly'], + deprecatingAlias: ['@ember/object/computed', 'deprecatingAlias'], + and: ['@ember/object/computed', 'and'], + or: ['@ember/object/computed', 'or'], + collect: ['@ember/object/computed', 'collect'], + sum: ['@ember/object/computed', 'sum'], + min: ['@ember/object/computed', 'min'], + max: ['@ember/object/computed', 'max'], + map: ['@ember/object/computed', 'map'], + sort: ['@ember/object/computed', 'sort'], + setDiff: ['@ember/object/computed', 'setDiff'], + mapBy: ['@ember/object/computed', 'mapBy'], + mapProperty: ['@ember/object/computed', 'mapProperty'], + filter: ['@ember/object/computed', 'filter'], + filterBy: ['@ember/object/computed', 'filterBy'], + filterProperty: ['@ember/object/computed', 'filterProperty'], + uniq: ['@ember/object/computed', 'uniq'], + union: ['@ember/object/computed', 'union'], + intersect: ['@ember/object/computed', 'intersect'] + }, + 'ember-test': { + default: null + }, + 'ember-test/adapter': { + default: ['@ember/test/adapter'] + }, + 'ember-test/qunit-adapter': { + default: null + } +}; //------------------------------------------------------------------------------ // General rule - Don't use import paths from ember-cli-shims From 7a12560189955d36da32ece21bcb0e512041d115 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 15 May 2018 15:17:52 -0400 Subject: [PATCH 10/12] Fix destructuring support with new-module-imports. --- lib/rules/new-module-imports.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rules/new-module-imports.js b/lib/rules/new-module-imports.js index 9ff7066a30..679ea4863d 100644 --- a/lib/rules/new-module-imports.js +++ b/lib/rules/new-module-imports.js @@ -47,7 +47,7 @@ module.exports = { reportNestedProperties(props, parent); } else { const key = item.key.name; - const match = GLOBALS[key]; + const match = GLOBALS[`Ember.${key}`]; populateMessage({ node: item, customKey: (key !== item.value.name) ? item.value.name : null, @@ -95,7 +95,7 @@ module.exports = { function reportNestedProperties(properties, parent) { properties.forEach((item) => { - const match = GLOBALS[`${parent}.${item.key.name}`]; + const match = GLOBALS[`Ember.${parent}.${item.key.name}`]; populateMessage({ node: item, From 46cf0ce84ba05bc26a0a5353bd906f1367fb7edb Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 15 May 2018 16:20:24 -0400 Subject: [PATCH 11/12] Update to ember-rfc176-data@0.3.3. --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9d96bba637..010003013e 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "lerna-changelog": "^0.7.0" }, "dependencies": { - "ember-rfc176-data": "^0.3.0", + "ember-rfc176-data": "^0.3.3", "snake-case": "^2.1.0" }, "changelog": { diff --git a/yarn.lock b/yarn.lock index de25cf7a09..e8a8f3b0ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -896,9 +896,9 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -ember-rfc176-data@^0.3.0: - version "0.3.2" - resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.2.tgz#bde5538939529b263c142b53a47402f8127f8dce" +ember-rfc176-data@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.3.tgz#27fba08d540a7463a4366c48eaa19c5a44971a39" encoding@^0.1.11: version "0.1.12" From 2277e2917eaea205cffddff535472873b5c1c161 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 15 May 2018 16:22:30 -0400 Subject: [PATCH 12/12] Fixup tests with latest ember-rfc176-data. --- tests/lib/rules/new-module-imports.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib/rules/new-module-imports.js b/tests/lib/rules/new-module-imports.js index 1595ccca5a..b585587e08 100644 --- a/tests/lib/rules/new-module-imports.js +++ b/tests/lib/rules/new-module-imports.js @@ -22,7 +22,7 @@ eslintTester.run('new-module-imports', rule, { { code: 'Ember.Handlebars.Utils.escapeExpression("foo");' }, { code: 'Ember.onerror = function() {};' }, { code: 'Ember.MODEL_FACTORY_INJECTIONS = true;' }, - { code: 'console.log(Ember.VERSION);' }, + { code: 'console.log(Ember.SOMETHING_NO_ONE_USES);' }, { code: 'if (Ember.testing) {}' }, { code: `import Component from '@ember/component'; @@ -80,7 +80,7 @@ eslintTester.run('new-module-imports', rule, { parserOptions: { ecmaVersion: 6, sourceType: 'module' }, errors: [ { message: 'Use import Component from \'@ember/component\'; instead of using Ember destructuring', line: 3 }, - { message: 'Use import { htmlSafe } from \'@ember/string\'; instead of using Ember destructuring', line: 3 } + { message: 'Use import { htmlSafe } from \'@ember/template\'; instead of using Ember destructuring', line: 3 } ] }, {