Skip to content

Commit

Permalink
feat: disallowTemplateLiterals, use LF (#7)
Browse files Browse the repository at this point in the history
* feat: disallowTemplateLiterals, use LF

* ci: fix end of line

actions/checkout#135
  • Loading branch information
daflyinbed authored Aug 17, 2024
1 parent 45c01db commit f3d82d0
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
*.* text eol=lf
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const prettierOptions = {
trailingComma: "all",
singleQuote: false,
semi: true,
endOfLine: "lf",
};
```

Expand Down
2 changes: 1 addition & 1 deletion fixtures/output/all/tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function Component1() {
export function jsx2() {
const props = { a: 1, b: 2 };
return (
<a foo="bar" bar={`foo`}>
<a foo="bar" bar={"foo"}>
<div {...props} a={1} b="2">
Inline Text
</div>
Expand Down
2 changes: 1 addition & 1 deletion fixtures/output/tab-single-quotes/tsx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function Component1() {
export function jsx2() {
const props = { a: 1, b: 2 };
return (
<a foo="bar" bar={`foo`}>
<a foo="bar" bar={'foo'}>
<div {...props} a={1} b="2">
Inline Text
</div>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@antfu/install-pkg": "^0.3.4",
"@clack/prompts": "^0.7.0",
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
"@stylistic/eslint-plugin": "^2.6.4",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"@typescript-eslint/parser": "^8.0.1",
"@vitest/eslint-plugin": "^1.0.1",
Expand Down
154 changes: 151 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions src/configs/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
GLOB_VUE,
GLOB_XML,
} from "../globs";
import { pluginFormat } from "../plugins";
import { pluginFormat, pluginStylistic } from "../plugins";
import { ensurePackages, parserPlain } from "../utils";
import type { OptionsFormatters, TypedFlatConfigItem } from "../types";
import type { Options as PrettierOptions } from "prettier";
Expand All @@ -30,6 +30,7 @@ export async function formatters(
trailingComma: "all",
singleQuote: false,
semi: true,
endOfLine: "lf",
};
const defaultOptions = {
astro: isPackageExists("prettier-plugin-astro"),
Expand Down Expand Up @@ -82,6 +83,7 @@ export async function formatters(
name: "xwbx/formatter/setup",
plugins: {
format: pluginFormat,
style: pluginStylistic,
},
},
{
Expand All @@ -92,6 +94,11 @@ export async function formatters(
ignores: [`${GLOB_ASTRO}/**`],
name: "xwbx/formatter/jslike",
rules: {
"style/quotes": [
"error",
prettierOptions.singleQuote ? "single" : "double",
{ allowTemplateLiterals: false },
],
"format/prettier": ["error", { ...prettierOptions, parser: undefined }],
},
},
Expand Down Expand Up @@ -253,7 +260,7 @@ export async function formatters(
},
name: "xwbx/formatter/markdown",
rules: {
[`format/prettier`]: [
"format/prettier": [
"error",
{
...prettierOptions,
Expand Down
2 changes: 1 addition & 1 deletion src/configs/unicorn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function unicorn(): Promise<TypedFlatConfigItem[]> {
"unicorn/no-single-promise-in-promise-methods": "error",
"unicorn/no-static-only-class": "error",
"unicorn/no-unnecessary-await": "error",
"unicorn/no-zero-fractions": `error`,
"unicorn/no-zero-fractions": "error",
"unicorn/prefer-add-event-listener": "error",
"unicorn/prefer-array-find": "error",
"unicorn/prefer-array-flat-map": "error",
Expand Down
1 change: 1 addition & 0 deletions src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export { default as pluginPerfectionist } from "eslint-plugin-perfectionist";
export { default as pluginUnicorn } from "eslint-plugin-unicorn";
export { default as pluginUnusedImports } from "eslint-plugin-unused-imports";
export { default as pluginFormat } from "eslint-plugin-format";
export { default as pluginStylistic } from "@stylistic/eslint-plugin";

0 comments on commit f3d82d0

Please sign in to comment.