Skip to content

Commit

Permalink
Fixup eslint setup for typescript conversion. (#159)
Browse files Browse the repository at this point in the history
Fixup eslint setup for typescript conversion.
  • Loading branch information
rwjblue authored Aug 26, 2019
2 parents a28db5e + 302f35c commit 0ceecbd
Show file tree
Hide file tree
Showing 21 changed files with 393 additions and 356 deletions.
10 changes: 8 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
'@typescript-eslint',
'ember',
'prettier',
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
'plugin:ember/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'prettier',
],
env: {
browser: true
},
rules: {
'prettier/prettier': 'error',
},
overrides: [
// node files
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# compiled output
/dist/
/tmp/
/.eslintcache

# dependencies
/bower_components/
Expand Down
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
singleQuote: true,
trailingComma: 'es5',
printWidth: 100,
};
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ addons:
chrome: stable

cache:
directories:
- $HOME/.npm
yarn: true

env:
global:
Expand All @@ -25,11 +24,16 @@ jobs:
include:
# runs linting and tests with current locked deps

- stage: "Tests"
name: "Linting"
node_js: 8
script:
- yarn lint:js

- stage: "Tests"
name: "Tests"
script:
- npm run lint:js
- npm test
- yarn test

# we recommend new addons test the current and previous LTS
# as well as latest stable release (bonus points to beta/canary)
Expand All @@ -41,10 +45,8 @@ jobs:
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-default-with-jquery

before_install:
- npm config set spin false
- npm install -g npm@4
- npm --version
install:
- yarn install --ignore-engines

script:
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
Expand Down
4 changes: 2 additions & 2 deletions addon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function _endsWith(str: string, suffix: string): boolean {
* Configure your application as it boots
*/
export default function loadInitializers(app: typeof Engine, prefix: string): void {
var initializerPrefix = prefix + '/initializers/';
var instanceInitializerPrefix = prefix + '/instance-initializers/';
var initializerPrefix = prefix + '/initializers/';
var instanceInitializerPrefix = prefix + '/instance-initializers/';
var initializers = [];
var instanceInitializers = [];
// this is 2 pass because generally the first pass is the problem
Expand Down
50 changes: 25 additions & 25 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function() {
getChannelURL('release'),
getChannelURL('beta'),
getChannelURL('canary'),
]).then((urls) => {
]).then(urls => {
return {
useYarn: true,
scenarios: [
Expand All @@ -19,9 +19,9 @@ module.exports = function() {
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1',
'ember-source': '~2.16.0'
}
}
'ember-source': '~2.16.0',
},
},
},
{
name: 'ember-lts-2.18',
Expand All @@ -31,54 +31,54 @@ module.exports = function() {
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1',
'ember-source': '~2.18.0'
}
}
'ember-source': '~2.18.0',
},
},
},
{
name: 'ember-release',
npm: {
devDependencies: {
'ember-source': urls[0]
}
}
'ember-source': urls[0],
},
},
},
{
name: 'ember-beta',
npm: {
devDependencies: {
'ember-source': urls[1]
}
}
'ember-source': urls[1],
},
},
},
{
name: 'ember-canary',
npm: {
devDependencies: {
'ember-source': urls[2]
}
}
'ember-source': urls[2],
},
},
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
devDependencies: {},
},
},
{
name: 'ember-default-with-jquery',
env: {
EMBER_OPTIONAL_FEATURES: JSON.stringify({
'jquery-integration': true
})
'jquery-integration': true,
}),
},
npm: {
devDependencies: {
'@ember/jquery': '^0.5.1'
}
}
}
]
'@ember/jquery': '^0.5.1',
},
},
},
],
};
});
};
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
return {};
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';

module.exports = {
name: require('./package').name
name: require('./package').name,
};
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"scripts": {
"build": "ember build",
"lint:js": "eslint .",
"lint:js": "eslint --cache --ext js,ts .",
"prepublishOnly": "ember ts:precompile",
"postpublish": "ember ts:clean",
"start": "ember serve",
Expand All @@ -49,9 +49,10 @@
"@types/ember__test-helpers": "^0.7.8",
"@types/qunit": "^2.5.4",
"@types/rsvp": "^4.0.2",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^2.0.0",
"ember-cli": "~3.9.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-eslint": "^4.2.3",
"ember-cli-htmlbars": "^3.1.0",
"ember-cli-htmlbars-inline-precompile": "^2.0.0",
"ember-cli-inject-live-reload": "^2.0.1",
Expand All @@ -63,10 +64,14 @@
"ember-source": "~3.11.1",
"ember-source-channel-url": "^1.1.0",
"ember-try": "^1.2.1",
"eslint": "5",
"eslint-config-prettier": "^6.1.0",
"eslint-plugin-ember": "^6.10.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.1.0",
"lerna-changelog": "^0.8.2",
"loader.js": "^4.7.0",
"prettier": "^1.18.2",
"release-it": "^12.2.1",
"release-it-lerna-changelog": "^1.0.3",
"typescript": "^3.3.3333"
Expand Down
16 changes: 6 additions & 10 deletions testem.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
'Chrome'
],
launch_in_ci: ['Chrome'],
launch_in_dev: ['Chrome'],
browser_args: {
Chrome: {
ci: [
Expand All @@ -18,8 +14,8 @@ module.exports = {
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
'--window-size=1440,900'
].filter(Boolean)
}
}
'--window-size=1440,900',
].filter(Boolean),
},
},
};
18 changes: 15 additions & 3 deletions tests/acceptance/initializers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import { setupApplicationTest } from 'ember-qunit';

module('Acceptance | before test', function() {
test('initializers', function(assert) {
assert.equal(self.fooInitializeWasCalled, undefined, 'initializer:foo should not yet be called');
assert.equal(self.barInitializeWasCalled, undefined, 'instance-initializer:bar should not yet be called');
assert.equal(
self.fooInitializeWasCalled,
undefined,
'initializer:foo should not yet be called'
);
assert.equal(
self.barInitializeWasCalled,
undefined,
'instance-initializer:bar should not yet be called'
);
});
});

Expand All @@ -15,7 +23,11 @@ module('Acceptance | initializers', function(hooks) {
await visit('/');

assert.equal(self.fooInitializeWasCalled, true, 'initializer:foo should have been called');
assert.equal(self.barInitializeWasCalled, true, 'instance-initializer:boo should have been called');
assert.equal(
self.barInitializeWasCalled,
true,
'instance-initializer:boo should have been called'
);
assert.equal(currentURL(), '/');
});
});
2 changes: 1 addition & 1 deletion tests/dummy/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const App = Application.extend({

delete self.fooInitializeWasCalled;
delete self.barInitializeWasCalled;
}
},
});

loadInitializers(App, config.modulePrefix);
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/initializers/foo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export function initialize(/* application */) {

export default {
name: 'foo',
initialize
initialize,
};
2 changes: 1 addition & 1 deletion tests/dummy/app/instance-initializers/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export function initialize(/* appInstance */) {

export default {
name: 'bar',
initialize
initialize,
};
5 changes: 2 additions & 3 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import config from './config/environment';

const Router = EmberRouter.extend({
location: config.locationType,
rootURL: config.rootURL
rootURL: config.rootURL,
});

Router.map(function() {
});
Router.map(function() {});

export default Router;
7 changes: 3 additions & 4 deletions tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ module.exports = function(environment) {
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
Date: false,
},
},

APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
},
};

if (environment === 'development') {
Expand All @@ -45,7 +45,6 @@ module.exports = function(environment) {

// eslint-disable-next-line no-empty
if (environment === 'production') {

}

return ENV;
Expand Down
8 changes: 2 additions & 6 deletions tests/dummy/config/targets.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict';

const browsers = [
'last 1 Chrome versions',
'last 1 Firefox versions',
'last 1 Safari versions'
];
const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'];

const isCI = !!process.env.CI;
const isProduction = process.env.EMBER_ENV === 'production';
Expand All @@ -14,5 +10,5 @@ if (isCI || isProduction) {
}

module.exports = {
browsers
browsers,
};
2 changes: 1 addition & 1 deletion tests/helpers/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const resolver = Resolver.create();

resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
podModulePrefix: config.podModulePrefix,
};

export default resolver;
1 change: 0 additions & 1 deletion types/dummy/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Loading

0 comments on commit 0ceecbd

Please sign in to comment.