Skip to content

Commit

Permalink
🔨 chore(deps): bump deps, fix delimiters in typescript files
Browse files Browse the repository at this point in the history
  • Loading branch information
pauliesnug committed May 19, 2024
1 parent 1530106 commit 89af24a
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 535 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"@flowr/eslint-config": "workspace:^",
"@flowr/tsconfig": "workspace:^",
"@stylistic/eslint-plugin-migrate": "^2.1.0",
"@types/node": "^20.12.11",
"@types/node": "^20.12.12",
"bumpp": "^9.4.1",
"esbuild": "^0.21.2",
"eslint": "npm:[email protected]2",
"esbuild": "^0.21.3",
"eslint": "npm:[email protected]6",
"esno": "^4.7.0",
"rimraf": "^5.0.7",
"rollup": "^4.17.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"eslint-config-flat-gitignore": "^0.1.5",
"eslint-flat-config-utils": "^0.2.4",
"eslint-flat-config-utils": "^0.2.5",
"eslint-merge-processors": "^0.1.0",
"eslint-plugin-command": "^0.2.0",
"eslint-plugin-command": "^0.2.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import-x": "^0.5.0",
"eslint-plugin-jsdoc": "^48.2.4",
"eslint-plugin-jsdoc": "^48.2.5",
"eslint-plugin-jsonc": "^2.15.1",
"eslint-plugin-markdown": "^5.0.0",
"eslint-plugin-n": "^17.6.0",
"eslint-plugin-n": "^17.7.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-perfectionist": "^2.10.0",
"eslint-plugin-petal": "workspace:^",
Expand All @@ -135,7 +135,7 @@
"eslint-plugin-vue": "^9.26.0",
"eslint-plugin-yml": "^1.14.0",
"eslint-processor-vue-blocks": "^0.1.2",
"globals": "^15.2.0",
"globals": "^15.3.0",
"jsonc-eslint-parser": "^2.4.0",
"local-pkg": "^0.5.0",
"toml-eslint-parser": "^0.9.3",
Expand All @@ -144,14 +144,14 @@
"yaml-eslint-parser": "^1.2.2"
},
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.5.11",
"@eslint-react/eslint-plugin": "^1.5.12",
"@eslint/config-inspector": "^0.4.8",
"@prettier/plugin-xml": "^3.4.1",
"@types/eslint": "^8.56.10",
"@types/fs-extra": "^11.0.4",
"@unocss/eslint-plugin": "^0.60.2",
"astro-eslint-parser": "^1.0.2",
"eslint": "^9.2.0",
"eslint": "^9.3.0",
"eslint-plugin-astro": "^1.2.0",
"eslint-plugin-format": "^0.1.1",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@types/eslint": "^8.56.10",
"@typescript-eslint/typescript-estree": "^7.9.0",
"@typescript-eslint/utils": "^7.9.0",
"eslint": "9.2.0",
"eslint": "9.3.0",
"eslint-vitest-rule-tester": "^0.3.2",
"typescript": "^5.3.3"
},
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import noImportDist from './rules/no-import-dist';
import noTsExportEqual from './rules/no-ts-export-equal';
import consistentListNewline from './rules/consistent-list-newline';
import indentUnindent from './rules/indent-unindent';
import noOnlyTests from './rules/no-only-tests';

const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));

Expand Down
18 changes: 18 additions & 0 deletions packages/eslint-plugin/src/rules/consistent-list-newline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,25 @@ const invalid: InvalidTestCase[] = [
'const foo = (\na, b): {\na:b} => {}',
'const foo = (\na, b): {a:b} => {}',
'interface Foo {\na: 1,b: 2\n}',
{
description: 'Add delimiter to avoid syntax error, (interface)',
code: 'interface Foo {a: 1\nb: 2\n}',
output: o => expect(o)
.toMatchInlineSnapshot(`"interface Foo {a: 1,b: 2,}"`),
},
{
description: 'Delimiter already exists',
code: 'interface Foo {a: 1;\nb: 2,\nc: 3}',
output: o => expect(o)
.toMatchInlineSnapshot(`"interface Foo {a: 1;b: 2,c: 3}"`),
},
'type Foo = {\na: 1,b: 2\n}',
{
description: 'Add delimiter to avoid syntax error, (type)',
code: 'type Foo = {a: 1\nb: 2\n}',
output: o => expect(o)
.toMatchInlineSnapshot(`"type Foo = {a: 1,b: 2,}"`),
},
'type Foo = [1,2,\n3]',
'new Foo(1,2,\n3)',
'new Foo(\n1,2,\n3)',
Expand Down
15 changes: 11 additions & 4 deletions packages/eslint-plugin/src/rules/consistent-list-newline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ export default createEslintRule<Options, MessageIds>({
},
defaultOptions: [{}],
create: (context, [options = {}] = [{}]) => {
function removeLines(fixer: RuleFixer, start: number, end: number) {
function removeLines(fixer: RuleFixer, start: number, end: number, delimiter?: string) {
const range = [start, end] as const;
const code = context.sourceCode.text.slice(...range);
return fixer.replaceTextRange(range, code.replace(/(\r\n|\n)/g, ''));
return fixer.replaceTextRange(range, code.replace(/(\r\n|\n)/g, delimiter ?? ''));
}

function getDelimiter(root: TSESTree.Node, current: TSESTree.Node) {
if (root.type !== 'TSInterfaceDeclaration' && root.type !== 'TSTypeLiteral')
return;
const currentContent = context.sourceCode.text.slice(current.range[0], current.range[1]);
return currentContent.match(/,|;$/) ? undefined : ',';
}

function check(
Expand Down Expand Up @@ -126,7 +133,7 @@ export default createEslintRule<Options, MessageIds>({
name: node.type,
},
*fix(fixer) {
yield removeLines(fixer, lastItem!.range[1], item.range[0]);
yield removeLines(fixer, lastItem!.range[1], item.range[0], getDelimiter(node, lastItem));
},
});
}
Expand Down Expand Up @@ -173,7 +180,7 @@ export default createEslintRule<Options, MessageIds>({
name: node.type,
},
*fix(fixer) {
yield removeLines(fixer, lastItem.range[1], endRange);
yield removeLines(fixer, lastItem.range[1], endRange, getDelimiter(node, lastItem));
},
});
}
Expand Down
21 changes: 0 additions & 21 deletions packages/eslint-plugin/src/rules/no-only-tests.test.ts

This file was deleted.

Loading

0 comments on commit 89af24a

Please sign in to comment.