Skip to content

Commit

Permalink
feat: bump deps (#371)
Browse files Browse the repository at this point in the history
update error log
fix eslint paths
fix linting issues
bump eslint version
eslint udpates
fix fund-up interop
  • Loading branch information
lifeart committed Mar 29, 2022
1 parent 8d46bbf commit a659edd
Show file tree
Hide file tree
Showing 17 changed files with 2,308 additions and 3,037 deletions.
10 changes: 2 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ module.exports = {
es6: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint', // disables conflicting rules from @typescript-eslint/eslint-plugin
'plugin:prettier/recommended',
],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
Expand All @@ -19,7 +13,7 @@ module.exports = {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'padding-line-between-statements': [
'error',
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ inst/
# Debug Logging
debug.log
debug.*.log
error.log
error.*.log
76 changes: 39 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,34 @@
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"resolutions": {
"@glimmer/syntax": "0.84.1",
"@babel/parser": "^7.17.0",
"@babel/traverse": "^7.17.0",
"@babel/core": "^7.17.0"
"@babel/core": "^7.17.0",
"minimist": "1.2.6",
"ansi-regex": "5.0.1",
"lodash": "4.17.21"
},
"dependencies": {
"@glimmer/syntax": "^0.83.1",
"@glimmer/syntax": "0.84.1",
"@lifeart/ember-extract-inline-templates": "2.2.0",
"dag-map": "^2.0.2",
"dag-map": "2.0.2",
"ember-meta-explorer": "1.2.0",
"ember-template-recast": "^6.1.3",
"find-up": "^5.0.0",
"flat": "^5.0.2",
"fuzzaldrin": "^2.1.0",
"json-parse-ast": "^1.0.8",
"lodash": "^4.17.21",
"memoizee": "^0.4.15",
"picomatch": "^2.3.0",
"semver": "^7.3.5",
"ember-template-recast": "6.1.3",
"find-up": "6.3.0",
"flat": "5.0.2",
"fuzzaldrin": "2.1.0",
"json-parse-ast": "1.0.8",
"lodash": "4.17.21",
"memoizee": "0.4.15",
"picomatch": "2.3.1",
"semver": "7.3.5",
"vscode-jsonrpc": "6.0.0",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-protocol": "^3.16.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-uri": "^3.0.2",
"yaml": "^2.0.0-8"
"vscode-languageserver": "7.0.0",
"vscode-languageserver-protocol": "3.16.0",
"vscode-languageserver-textdocument": "1.0.4",
"vscode-uri": "3.0.3",
"yaml": "2.0.0-11"
},
"devDependencies": {
"@babel/types": "^7.12.12",
Expand All @@ -59,33 +63,32 @@
"@types/estree": "^0.0.46",
"@types/flat": "^5.0.2",
"@types/fuzzaldrin": "^2.1.3",
"@types/jest": "^26.0.20",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.178",
"@types/memoizee": "^0.4.5",
"@types/node": "^12.12.5",
"@types/picomatch": "^2.3.0",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.13.0",
"@typescript-eslint/parser": "^4.13.0",
"@typescript-eslint/eslint-plugin": "5.17.0",
"@typescript-eslint/parser": "5.17.0",
"broccoli-test-helper": "^2.0.0",
"cross-spawn": "^7.0.3",
"eslint": "^7.17.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.1",
"cross-spawn": "7.0.3",
"eslint": "8.12.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.0.0",
"husky": "^6.0.0",
"jest": "^26.6.3",
"lerna-changelog": "^0.8.2",
"lint-staged": "^10.5.4",
"node-polyfill-webpack-plugin": "^1.1.4",
"nyc": "^15.1.0",
"path-browserify": "^1.0.1",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.19",
"ts-jest": "^26.5.6",
"jest": "^27.5.1",
"lint-staged": "12.3.7",
"node-polyfill-webpack-plugin": "1.1.4",
"nyc": "15.1.0",
"path-browserify": "1.0.1",
"prettier": "2.6.1",
"rimraf": "3.0.2",
"source-map-support": "^0.5.21",
"ts-jest": "^27.1.4",
"ts-loader": "^9.2.3",
"ts-node": "^8.10.2",
"typescript": "^4.5.5",
"typescript": "^4.6.3",
"webpack": "^5.44.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.7.2"
Expand All @@ -103,12 +106,11 @@
"parser": "typescript"
},
"scripts": {
"changelog": "lerna-changelog",
"clean": "rimraf lib/",
"build:bundle:node": "webpack --mode production",
"build:bundle:worker": "webpack --mode production && node ./fix-worker-bundle.js",
"compile": "tsc --skipLibCheck -p .",
"lint": "eslint ./{src,test}/**/*.ts",
"lint": "eslint \"./{src,test}/**/*.ts\"",
"prepublish": "yarn clean && yarn compile",
"test": "jest",
"test:coverage": "rimraf inst/ && nyc instrument lib inst && nyc --no-clean --reporter=clover --reporter=json --reporter=lcov yarn run jest --no-coverage",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export default class TemplateLintCommentsCodeAction extends BaseCodeActionProvid
const text = ` ${comment} `;
const textComment = '\n' + new Array(startColumn).fill(' ').join('');

children.splice(children.indexOf(node), 0, (b.mustacheComment(text) as unknown) as ASTv1.CommentStatement);
children.splice(children.indexOf(node), 0, (b.text(textComment) as unknown) as ASTv1.TextNode);
children.splice(children.indexOf(node), 0, b.mustacheComment(text) as unknown as ASTv1.CommentStatement);
children.splice(children.indexOf(node), 0, b.text(textComment) as unknown as ASTv1.TextNode);
}
}

Expand Down
42 changes: 20 additions & 22 deletions src/builtin-addons/core/code-actions/template-lint-fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,27 @@ export default class TemplateLintFixesCodeAction extends BaseCodeActionProvider
setCwd(this.project.root);
const linter = new linterKlass();

const fixes = issues.map(
async (issue): Promise<null | CodeAction> => {
const { output, isFixed } = await Promise.resolve(
linter.verifyAndFix({
source: meta.selection || '',
moduleId: URI.parse(params.textDocument.uri).fsPath,
filePath: URI.parse(params.textDocument.uri).fsPath,
})
);

if (!isFixed) {
return null;
}

const edit: WorkspaceEdit = {
changes: {
[params.textDocument.uri]: [TextEdit.replace(toLSRange(meta.location), output)],
},
};

return CodeAction.create(`fix: ${issue.code}`, edit, CodeActionKind.QuickFix);
const fixes = issues.map(async (issue): Promise<null | CodeAction> => {
const { output, isFixed } = await Promise.resolve(
linter.verifyAndFix({
source: meta.selection || '',
moduleId: URI.parse(params.textDocument.uri).fsPath,
filePath: URI.parse(params.textDocument.uri).fsPath,
})
);

if (!isFixed) {
return null;
}
);

const edit: WorkspaceEdit = {
changes: {
[params.textDocument.uri]: [TextEdit.replace(toLSRange(meta.location), output)],
},
};

return CodeAction.create(`fix: ${issue.code}`, edit, CodeActionKind.QuickFix);
});
const resolvedFixes = await Promise.all(fixes);

return resolvedFixes;
Expand Down
12 changes: 6 additions & 6 deletions src/builtin-addons/core/script-definition-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@ export default class CoreScriptDefinitionProvider {
definitions = templateResults;
}
} else if (isModelReference(astPath)) {
const modelName = ((astPath.node as unknown) as t.StringLiteral).value;
const modelName = (astPath.node as unknown as t.StringLiteral).value;

definitions = await this.guessPathsForType(root, 'Model', modelName);
} else if (isTransformReference(astPath)) {
const transformName = ((astPath.node as unknown) as t.StringLiteral).value;
const transformName = (astPath.node as unknown as t.StringLiteral).value;

definitions = await this.guessPathsForType(root, 'Transform', transformName);
} else if (isImportPathDeclaration(astPath)) {
definitions = (await this.guessPathForImport(root, uri, ((astPath.node as unknown) as t.StringLiteral).value)) || [];
definitions = (await this.guessPathForImport(root, uri, (astPath.node as unknown as t.StringLiteral).value)) || [];
} else if (isImportSpecifier(astPath) || isImportDefaultSpecifier(astPath)) {
logInfo(`Handle script import for Project "${project.name}"`);

Expand Down Expand Up @@ -252,7 +252,7 @@ export default class CoreScriptDefinitionProvider {

definitions = definitions.concat(potentialPaths);
} else if (isServiceInjection(astPath)) {
let serviceName = ((astPath.node as unknown) as t.Identifier).name;
let serviceName = (astPath.node as unknown as t.Identifier).name;
const args = astPath.parent.value.arguments;

if (args.length && args[0].type === 'StringLiteral') {
Expand All @@ -261,11 +261,11 @@ export default class CoreScriptDefinitionProvider {

definitions = await this.guessPathsForType(root, 'Service', normalizeServiceName(serviceName));
} else if (isNamedServiceInjection(astPath)) {
const serviceName = ((astPath.node as unknown) as t.StringLiteral).value;
const serviceName = (astPath.node as unknown as t.StringLiteral).value;

definitions = await this.guessPathsForType(root, 'Service', normalizeServiceName(serviceName));
} else if (isRouteLookup(astPath)) {
const routePath = ((astPath.node as unknown) as t.StringLiteral).value;
const routePath = (astPath.node as unknown as t.StringLiteral).value;

definitions = await provideRouteDefinition(this.registry, routePath, this.server.fs);
}
Expand Down
9 changes: 5 additions & 4 deletions src/template-linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getTemplateNodes } from '@lifeart/ember-extract-inline-templates';
import { parseScriptFile } from 'ember-meta-explorer';
import { URI } from 'vscode-uri';
import { log, logError, logDebugInfo } from './utils/logger';
import * as findUp from 'find-up';
import * as path from 'path';
import { pathToFileURL } from 'url';

Expand Down Expand Up @@ -210,8 +209,10 @@ export default class TemplateLinter {

return diagnostics;
}
private templateLintConfig(cwd: string): string | undefined {
return findUp.sync('.template-lintrc.js', { cwd });
private async templateLintConfig(cwd: string): Promise<string | undefined> {
const { findUp } = await eval(`import('find-up')`);

return findUp('.template-lintrc.js', { cwd });
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
public async linterForProject(project: Project) {
Expand All @@ -225,7 +226,7 @@ export default class TemplateLinter {

try {
// don't resolve template-lint (due to resolution error) if no linter config found;
if (!this.templateLintConfig(project.root)) {
if (!(await this.templateLintConfig(project.root))) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/ast-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export function isNamedBlockName(path: ASTPath): boolean {
}

export function isAngleComponentPath(path: ASTPath): boolean {
const node = (path.node as unknown) as ASTv1.ElementNode;
const node = path.node as unknown as ASTv1.ElementNode;

if (!hasNodeType(node, 'ElementNode')) {
return false;
Expand Down
18 changes: 3 additions & 15 deletions test/batman-fixture-based-integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {
normalizeUri,
fsProjectToJSON,
normalizeCompletionRequest,
createConnection,
} from './test_helpers/integration-helpers';
import { createMessageConnection, MessageConnection, Logger, StreamMessageReader, StreamMessageWriter } from 'vscode-jsonrpc/node';
import { MessageConnection } from 'vscode-jsonrpc/node';

import { CompletionRequest, Definition, DefinitionRequest } from 'vscode-languageserver-protocol/node';

Expand All @@ -20,20 +21,7 @@ describe('With `batman project` initialized on server', () => {

beforeAll(async () => {
serverProcess = startServer();
connection = createMessageConnection(new StreamMessageReader(serverProcess.stdout), new StreamMessageWriter(serverProcess.stdin), <Logger>{
error(msg) {
console.log('error', msg);
},
log(msg) {
console.log('log', msg);
},
info(msg) {
console.log('info', msg);
},
warn(msg) {
console.log('warn', msg);
},
});
connection = createConnection(serverProcess);

serverProcess.on('error', (err) => {
console.log(err);
Expand Down

0 comments on commit a659edd

Please sign in to comment.