Skip to content

Commit

Permalink
[CLEANUP] Update eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
krisselden committed Feb 21, 2020
1 parent af1b53a commit 15abe4a
Show file tree
Hide file tree
Showing 20 changed files with 465 additions and 323 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
tryExtensions: ['.js', '.ts', '.d.ts'],
},
},
ignorePatterns: ['dist', 'ts-dist', 'node_modules', 'tmp'],
rules: {
// disabled because we still have a few commented tests
'qunit/no-commented-tests': 'off',
Expand Down Expand Up @@ -186,6 +187,12 @@ module.exports = {
'@typescript-eslint/no-unused-vars': 'error',
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'no-useless-constructor': 'off',
},
},
// node files
{
files: [
Expand Down
18 changes: 0 additions & 18 deletions .vscode/tslint-formatters/vscodeFormatter.js

This file was deleted.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"test:types": "node bin/run-types-tests.js",
"test:smoke": "SMOKE_TESTS=true ember test",
"eslint": "eslint . --cache --ext .js,.ts",
"eslint:fix": "eslint . --cache --ext .js,.ts --fix",
"problems": "tsc -p tsconfig.json --noEmit --pretty false",
"yarn:link": "node bin/yarn-link-all",
"yarn:unlink": "node bin/yarn-link-all --unlink",
Expand All @@ -41,8 +42,8 @@
"devDependencies": {
"@glimmer/env": "0.1.7",
"@types/qunit": "^2.0.31",
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
"amd-name-resolver": "^1.3.1",
"auto-dist-tag": "^1.0.0",
"babel-plugin-nukable-import": "^0.4.2",
Expand All @@ -64,18 +65,18 @@
"dag-map": "^2.0.2",
"ember-cli": "~3.6.1",
"ember-cli-browserstack": "^1.0.1",
"eslint": "^5.10.0",
"eslint-config-prettier": "^6.3.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-qunit": "^4.0.0",
"execa": "^3.4.0",
"glob": "^7.0.5",
"js-yaml": "^3.10.0",
"lerna-changelog": "^0.8.2",
"loader.js": "^4.0.10",
"mkdirp": "^0.5.1",
"prettier": "^1.18.2",
"prettier": "^1.19.1",
"qunit": "^2.9.1",
"qunit-tap": "^1.5.1",
"rimraf": "^2.6.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/@glimmer/compiler/lib/javascript-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ export default class JavaScriptCompiler implements Processor<JavaScriptCompilerO
} else if (inverse === null) {
namedBlocks = [['default'], [blocks[template]]];
} else {
namedBlocks = [['default', 'else'], [blocks[template], blocks[inverse]]];
namedBlocks = [
['default', 'else'],
[blocks[template], blocks[inverse]],
];
}

// assert(head[]);
Expand Down
5 changes: 4 additions & 1 deletion packages/@glimmer/compiler/test/compiler-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ test('HTML text content', 'content', s`content`);

test('Text curlies', '<div>{{title}}<span>{{title}}</span></div>', [
'<div>',
[[Append, '^title'], ['<span>', [[Append, '^title']]]],
[
[Append, '^title'],
['<span>', [[Append, '^title']]],
],
]);

test(
Expand Down
16 changes: 14 additions & 2 deletions packages/@glimmer/compiler/test/location-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@ import { Dict } from '@glimmer/interfaces';
const test = QUnit.test;

const cases: Dict<[string, number | null][]> = {
'hello world': [['0:0', 0], ['0:5', 5], ['0:11', 11], ['0:12', null], ['1:0', null]],
'hello world\n': [['0:0', 0], ['0:5', 5], ['0:11', 11], ['0:12', null], ['1:0', null]],
'hello world': [
['0:0', 0],
['0:5', 5],
['0:11', 11],
['0:12', null],
['1:0', null],
],
'hello world\n': [
['0:0', 0],
['0:5', 5],
['0:11', 11],
['0:12', null],
['1:0', null],
],
'hello world\n\n': [
['0:0', 0],
['0:5', 5],
Expand Down
16 changes: 13 additions & 3 deletions packages/@glimmer/compiler/test/template-visitor-node-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ QUnit.module('[glimmer-compiler] TemplateVisitor');

test('empty', function() {
let input = '';
actionsEqual(input, [['startProgram', [0, []]], ['endProgram', [0]]]);
actionsEqual(input, [
['startProgram', [0, []]],
['endProgram', [0]],
]);
});

test('basic', function() {
Expand Down Expand Up @@ -125,12 +128,19 @@ test('nested blocks', function() {

test('comment', function() {
let input = '<!-- some comment -->';
actionsEqual(input, [['startProgram', [0, []]], ['comment', [0, 1]], ['endProgram', [0]]]);
actionsEqual(input, [
['startProgram', [0, []]],
['comment', [0, 1]],
['endProgram', [0]],
]);
});

test('handlebars comment', function() {
let input = '{{! some comment }}';
actionsEqual(input, [['startProgram', [0, []]], ['endProgram', [0]]]);
actionsEqual(input, [
['startProgram', [0, []]],
['endProgram', [0]],
]);
});

test('handlebars comment in element space', function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/debug/lib/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export function strip(strings: TemplateStringsArray, ...args: unknown[]) {
}

export const META_KIND = tuple('METADATA', 'MACHINE_METADATA');
export type META_KIND = (typeof META_KIND)[number];
export type META_KIND = typeof META_KIND[number];

export function buildSingleMeta(
kind: META_KIND,
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/dom-change-list/test/test-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface Constructor<T = unknown, Prototype = T> {
prototype: Prototype;
}

export function module(name: string): (klass: (typeof TestCase) & Constructor) => void {
export function module(name: string): (klass: typeof TestCase & Constructor) => void {
return function(klass: typeof TestCase & Constructor) {
QUnit.module(name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ QUnit.test('Custom element with element modifier', function(assert) {
});

QUnit.test('Curly component hooks (with attrs)', assert => {
let instance: NonBlock & HookedComponent | undefined;
let instance: (NonBlock & HookedComponent) | undefined;

class NonBlock extends EmberishCurlyComponent {
init() {
Expand Down Expand Up @@ -1469,7 +1469,7 @@ QUnit.test('Curly component hooks (with attrs)', assert => {
});

QUnit.test('Curly component hooks (attrs as self props)', function() {
let instance: NonBlock & HookedComponent | undefined;
let instance: (NonBlock & HookedComponent) | undefined;

class NonBlock extends EmberishCurlyComponent {
init() {
Expand Down Expand Up @@ -1602,7 +1602,7 @@ QUnit.test('Setting class attributeBinding does not clobber ember-view', assert
});

QUnit.test('Curly component hooks (force recompute)', assert => {
let instance: NonBlock & HookedComponent | undefined;
let instance: (NonBlock & HookedComponent) | undefined;

class NonBlock extends EmberishCurlyComponent {
init() {
Expand Down Expand Up @@ -1653,7 +1653,7 @@ QUnit.test('Curly component hooks (force recompute)', assert => {
});

QUnit.test('Glimmer component hooks', assert => {
let instance: NonBlock & HookedComponent | undefined;
let instance: (NonBlock & HookedComponent) | undefined;

class NonBlock extends EmberishGlimmerComponent {
constructor(args: EmberishGlimmerArgs) {
Expand Down Expand Up @@ -1707,7 +1707,7 @@ QUnit.test('Glimmer component hooks', assert => {
});

QUnit.test('Glimmer component hooks (force recompute)', assert => {
let instance: NonBlock & HookedComponent | undefined;
let instance: (NonBlock & HookedComponent) | undefined;

class NonBlock extends EmberishGlimmerComponent {
constructor(args: EmberishGlimmerArgs) {
Expand Down
27 changes: 23 additions & 4 deletions packages/@glimmer/integration-tests/test/partial-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,23 @@ QUnit.test('static partial with local reference', () => {
let template = compile(`{{#each qualities key='id' as |quality|}}{{partial 'test'}}. {{/each}}`);

registerPartial(context.registry, 'test', `You {{quality.value}}`);
render(template, { qualities: [{ id: 1, value: 'smaht' }, { id: 2, value: 'loyal' }] });
render(template, {
qualities: [
{ id: 1, value: 'smaht' },
{ id: 2, value: 'loyal' },
],
});

rerender(null, { assertStable: true });

equalTokens(context.root, `You smaht. You loyal. `);
rerender(
{ qualities: [{ id: 1, value: 'smaht' }, { id: 2, value: 'loyal' }] },
{
qualities: [
{ id: 1, value: 'smaht' },
{ id: 2, value: 'loyal' },
],
},
{ assertStable: true }
);
equalTokens(context.root, `You smaht. You loyal. `);
Expand Down Expand Up @@ -654,14 +664,23 @@ QUnit.test('dynamic partial with local reference', () => {
registerPartial(context.registry, 'test', `You {{quality.value}}`);
render(template, {
name: 'test',
qualities: [{ id: 1, value: 'smaht' }, { id: 2, value: 'loyal' }],
qualities: [
{ id: 1, value: 'smaht' },
{ id: 2, value: 'loyal' },
],
});

rerender(null, { assertStable: true });

equalTokens(context.root, `You smaht. You loyal. `);
rerender(
{ name: 'test', qualities: [{ id: 1, value: 'smaht' }, { id: 2, value: 'loyal' }] },
{
name: 'test',
qualities: [
{ id: 1, value: 'smaht' },
{ id: 2, value: 'loyal' },
],
},
{ assertStable: true }
);
equalTokens(context.root, `You smaht. You loyal. `);
Expand Down
10 changes: 8 additions & 2 deletions packages/@glimmer/integration-tests/test/updating-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2600,7 +2600,10 @@ module('[jit] integration - Updating', hooks => {
);

object = {
list: [{ name: 'Martin Muñoz', class: 'mmun' }, { name: 'Kris Selden', class: 'krisselden' }],
list: [
{ name: 'Martin Muñoz', class: 'mmun' },
{ name: 'Kris Selden', class: 'krisselden' },
],
};
rerender(object);
assertStableNodes('mmun', 0, 'after changing the list entries, but with stable keys');
Expand Down Expand Up @@ -2630,7 +2633,10 @@ module('[jit] integration - Updating', hooks => {
);

object = {
list: [{ name: 'Martin Muñoz', class: 'mmun' }, { name: 'Matthew Beale', class: 'mixonic' }],
list: [
{ name: 'Martin Muñoz', class: 'mmun' },
{ name: 'Matthew Beale', class: 'mixonic' },
],
};

rerender(object);
Expand Down
9 changes: 5 additions & 4 deletions packages/@glimmer/opcode-compiler/lib/syntax/push-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
CompileMode,
Op,
MachineOp,
CompileBlockOp,
CompileInlineOp,
StatementCompileActions,
InvokeStaticOp,
DynamicComponentOp,
Expand Down Expand Up @@ -61,13 +59,16 @@ function compileOp(
}
}

function CompileBlockOp(context: TemplateCompilationContext, op: CompileBlockOp) {
function CompileBlockOp(
context: TemplateCompilationContext,
op: import('@glimmer/interfaces').CompileBlockOp
) {
return compileBlock(op.op1, context);
}

function CompileInlineOp(
context: TemplateCompilationContext,
op: CompileInlineOp
op: import('@glimmer/interfaces').CompileInlineOp
): StatementCompileActions {
let { inline, ifUnhandled } = op.op1;

Expand Down
30 changes: 24 additions & 6 deletions packages/@glimmer/reference/test/iterable-impl-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ function initialize(
module('@glimmer/reference: IterableImpl', () => {
module('native arrays', () => {
test('it correctly iterates native arrays', assert => {
let arr = [{ key: 'a', name: 'Yehuda' }, { key: 'b', name: 'Godfrey' }];
let arr = [
{ key: 'a', name: 'Yehuda' },
{ key: 'b', name: 'Godfrey' },
];
let { target } = initialize(arr);

assert.deepEqual(target.toValues(), arr);
});

test('it correctly synchronizes native arrays when changed', assert => {
let arr = [{ key: 'a', name: 'Yehuda' }, { key: 'b', name: 'Godfrey' }];
let arr = [
{ key: 'a', name: 'Yehuda' },
{ key: 'b', name: 'Godfrey' },
];
let { target, artifacts } = initialize(arr);

assert.deepEqual(target.toValues(), arr);
Expand Down Expand Up @@ -96,7 +102,10 @@ module('@glimmer/reference: IterableImpl', () => {

module('keys', () => {
test('@identity works', assert => {
let arr = [{ key: 'a', name: 'Yehuda' }, { key: 'b', name: 'Godfrey' }];
let arr = [
{ key: 'a', name: 'Yehuda' },
{ key: 'b', name: 'Godfrey' },
];
let { target } = initialize(arr);

assert.deepEqual(target.toKeys(), arr);
Expand Down Expand Up @@ -153,21 +162,30 @@ module('@glimmer/reference: IterableImpl', () => {
});

test('@key works', assert => {
let arr = [{ key: 'a', name: 'Yehuda' }, { key: 'b', name: 'Godfrey' }];
let arr = [
{ key: 'a', name: 'Yehuda' },
{ key: 'b', name: 'Godfrey' },
];
let { target } = initialize(arr, '@key');

assert.deepEqual(target.toKeys(), [0, 1]);
});

test('@index works', assert => {
let arr = [{ key: 'a', name: 'Yehuda' }, { key: 'b', name: 'Godfrey' }];
let arr = [
{ key: 'a', name: 'Yehuda' },
{ key: 'b', name: 'Godfrey' },
];
let { target } = initialize(arr, '@index');

assert.deepEqual(target.toKeys(), ['0', '1']);
});

test('paths work', assert => {
let arr = [{ key: 'a', name: 'Yehuda' }, { key: 'b', name: 'Godfrey' }];
let arr = [
{ key: 'a', name: 'Yehuda' },
{ key: 'b', name: 'Godfrey' },
];
let { target } = initialize(arr, 'key');

assert.deepEqual(target.toKeys(), ['a', 'b']);
Expand Down
Loading

0 comments on commit 15abe4a

Please sign in to comment.