Skip to content

Commit

Permalink
Update prettier and ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuke Hirao committed Apr 23, 2020
1 parent 2b211ce commit eb7aec5
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 560 deletions.
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"useTabs": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true
"bracketSpacing": true,
"arrowParens": "avoid"
}
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test:clear": "jest --clearCache",
"test:unit": "jest",
"test:heapdump": "node --expose-gc ./heaptest/index.js",
"lint": "eslint --fix ./packages/**/*.ts",
"lint": "prettier --write './packages/**/*.ts'; eslint --fix './packages/**/*.ts'",
"schema": "lerna run schema",
"gen": "cd packages/\\@markuplint/html-ls/; yarn gen; cd ../",
"all": "yarn lint; yarn clean; yarn gen; yarn build; yarn schema; yarn test:clear; yarn test;",
Expand Down Expand Up @@ -51,23 +51,23 @@
"website"
],
"devDependencies": {
"@types/jest": "^25.1.4",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"coveralls": "^3.0.9",
"@types/jest": "^25.2.1",
"@typescript-eslint/eslint-plugin": "^2.29.0",
"@typescript-eslint/parser": "^2.29.0",
"coveralls": "^3.0.13",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-jsdoc": "^22.1.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-jsdoc": "^24.0.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.3",
"heapdump": "^0.3.15",
"jest": "^25.1.0",
"jest": "^25.4.0",
"lerna": "^3.20.2",
"prettier": "^1.19.1",
"ts-jest": "^25.2.1",
"ts-node": "^8.7.0",
"typedoc": "^0.17.1",
"prettier": "^2.0.5",
"ts-jest": "^25.4.0",
"ts-node": "^8.9.0",
"typedoc": "^0.17.4",
"typescript": "^3.8.3"
}
}
2 changes: 1 addition & 1 deletion packages/@markuplint/html-ls/gen/content-models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import readJson from './read-json';

export default function() {
export default function () {
const json = readJson('../src/content-models.json', {
models: {
'#metadata': [] as string[],
Expand Down
2 changes: 1 addition & 1 deletion packages/@markuplint/html-ls/gen/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const bar = new Bar(
);
bar.start(total, current, { process: '🚀 Started.' });

export default async function(url: string) {
export default async function (url: string) {
const html = await fetchText(url);
const $ = cheerio.load(html);
return $;
Expand Down
5 changes: 1 addition & 4 deletions packages/@markuplint/html-ls/gen/global-attrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { nameCompare } from './utils';
export async function getGlobalAttrs() {
const $ = await fetch('https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes');
const $article = $('#wikiArticle');
const $specials = $article
.find('ul')
.eq(0)
.find('code');
const $specials = $article.find('ul').eq(0).find('code');

const attrs: Attribute[] = [];

Expand Down
5 changes: 1 addition & 4 deletions packages/@markuplint/html-ls/gen/html-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ function getAttributes($: CheerioStatic, heading: string, tagName: string): Attr
.toArray()
.map((dt): Attribute | null => {
const $dt = $(dt);
const name = $dt
.find('code')
.text()
.trim();
const name = $dt.find('code').text().trim();
if (!name) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/@markuplint/html-ls/gen/read-json.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';

export default function<T = Record<string, any>>(filePath: string, fallBackContext: T): T {
export default function <T = Record<string, any>>(filePath: string, fallBackContext: T): T {
let json: string;
try {
json = fs.readFileSync(path.resolve(__dirname, filePath), {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MLASTNode } from '@markuplint/ml-ast';

export default function(nodeList: MLASTNode[]) {
export default function (nodeList: MLASTNode[]) {
return nodeList.map(n => {
if (!n.isGhost) {
return `[${n.startLine}:${n.startCol}]>[${n.endLine}:${n.endCol}](${n.startOffset},${n.endOffset})${
Expand All @@ -13,8 +13,5 @@ export default function(nodeList: MLASTNode[]) {
}

function visibleWhiteSpace(chars: string) {
return chars
.replace(/\n/g, '⏎')
.replace(/\t/g, '→')
.replace(/\s/g, '␣');
return chars.replace(/\n/g, '⏎').replace(/\t/g, '→').replace(/\s/g, '␣');
}
2 changes: 1 addition & 1 deletion packages/@markuplint/html-parser/src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UUID from 'uuid';
import getEndCol from './get-end-col';
import getEndLine from './get-end-line';

export default function(raw: string | null, line: number, col: number, startOffset: number): MLToken {
export default function (raw: string | null, line: number, col: number, startOffset: number): MLToken {
raw = raw || '';
return {
uuid: UUID.v4(),
Expand Down
5 changes: 1 addition & 4 deletions packages/@markuplint/ml-core/src/ml-dom/helper/node-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { RuleConfigValue } from '@markuplint/ml-config';
export default class NodeStore {
#store = new Map<string, MLDOMNode<any, any, any>>();

setNode<A extends MLASTAbstructNode, T extends RuleConfigValue, O = null>(
astNode: A,
node: MLDOMNode<T, O, A>,
) {
setNode<A extends MLASTAbstructNode, T extends RuleConfigValue, O = null>(astNode: A, node: MLDOMNode<T, O, A>) {
this.#store.set(astNode.uuid, node);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ test('length 1', () => {
});

test('length 2', () => {
expect(combination([0, 1])).toEqual([[0, 1], [1, 0]]);
expect(combination([1, 0])).toEqual([[0, 1], [1, 0]]);
expect(combination([0, 1])).toEqual([
[0, 1],
[1, 0],
]);
expect(combination([1, 0])).toEqual([
[0, 1],
[1, 0],
]);
});

test('length 3', () => {
expect(combination([0, 1, 2])).toEqual([[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]);
expect(combination([0, 1, 2])).toEqual([
[0, 1, 2],
[0, 2, 1],
[1, 0, 2],
[1, 2, 0],
[2, 0, 1],
[2, 1, 0],
]);
});

test('length 4', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MLASTNode } from '@markuplint/ml-ast';

export default function(nodeList: MLASTNode[]) {
export default function (nodeList: MLASTNode[]) {
return nodeList.map(n => {
if (!n.isGhost) {
return `[${n.startLine}:${n.startCol}]>[${n.endLine}:${n.endCol}](${n.startOffset},${n.endOffset})${
Expand All @@ -13,8 +13,5 @@ export default function(nodeList: MLASTNode[]) {
}

function visibleWhiteSpace(chars: string) {
return chars
.replace(/\n/g, '⏎')
.replace(/\t/g, '→')
.replace(/\s/g, '␣');
return chars.replace(/\n/g, '⏎').replace(/\t/g, '→').replace(/\s/g, '␣');
}
2 changes: 1 addition & 1 deletion packages/@markuplint/vue-parser/src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import UUID from 'uuid';
import getEndCol from './get-end-col';
import getEndLine from './get-end-line';

export default function(raw: string | null, line: number, col: number, startOffset: number): MLToken {
export default function (raw: string | null, line: number, col: number, startOffset: number): MLToken {
raw = raw || '';
return {
uuid: UUID.v4(),
Expand Down
Loading

0 comments on commit eb7aec5

Please sign in to comment.