Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
nirtamir2 committed Jun 8, 2024
1 parent 4c3a787 commit 1801897
Show file tree
Hide file tree
Showing 89 changed files with 6,734 additions and 3,954 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- 'v*'
- "v*"

jobs:
release:
Expand Down
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default nirtamir2(
"eslint:recommended",
// Other extends...
],
}),
})

// Other flat configs...
);
Expand Down Expand Up @@ -222,7 +222,7 @@ export default nirtamir2(
},
{
rules: {},
},
}
);
```

Expand Down Expand Up @@ -269,7 +269,7 @@ export default combine(
jsonc(),
yaml(),
toml(),
markdown(),
markdown()
);
```

Expand Down Expand Up @@ -304,7 +304,7 @@ export default nirtamir2(
rules: {
"@stylistic/semi": ["error", "never"],
},
},
}
);
```

Expand Down Expand Up @@ -342,18 +342,15 @@ The factory function `nirtamir2()` returns a [`FlatConfigComposer` object from `
import nirtamir2 from "@nirtamir2/eslint-config";

export default nirtamir2()
.prepend(
// some configs before the main config
)
.prepend
// some configs before the main config
()
// overrides any named configs
.override(
"nirtamir2/imports",
{
rules: {
"import/order": ["error", { "newlines-between": "always" }],
},
.override("nirtamir2/imports", {
rules: {
"import/order": ["error", { "newlines-between": "always" }],
},
)
})
// rename plugin prefixes
.renamePlugins({
"old-prefix": "new-prefix",
Expand Down Expand Up @@ -551,8 +548,8 @@ You can add the trigger comment one line above the code you want to transform, f
```ts
/// to-function
const foo = async (msg: string): void => {
console.log(msg)
}
console.log(msg);
};
```

Will be transformed to this when you hit save with your editor or run `eslint . --fix`:
Expand Down
11 changes: 4 additions & 7 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default nirtamir2(
svelte: true,
astro: true,
typescript: true,
formatters: true,
formatters: false,
stylistic: false,
},
{
rules: {
Expand All @@ -25,11 +26,7 @@ export default nirtamir2(
"unicorn/consistent-destructuring": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/init-declarations": "off",

},
ignores: [
"fixtures",
"_fixtures",
],
},
ignores: ["fixtures/**", "_fixtures/**"],
}
);
62 changes: 30 additions & 32 deletions fixtures/output/all/javascript.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,71 @@
// This file is generated by ChatGPT

// eslint-disable-next-line no-console
const log = console.log
const log = console.log;

// Define a class using ES6 class syntax
class Person {
constructor(name, age) {
this.name = name
this.age = age
this.name = name;
this.age = age;
}

// Define a method within the class
sayHello() {
log(`Hello, my name is ${this.name} and I am ${this.age} years old.`)
log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
}
}

// Create an array of objects
const people = [
new Person('Alice', 30),
new Person('Bob', 25),
new Person('Charlie', 35),
]
new Person("Alice", 30),
new Person("Bob", 25),
new Person("Charlie", 35),
];

// Use the forEach method to iterate over the array
people.forEach((person) => {
person.sayHello()
})
person.sayHello();
});

// Use a template literal to create a multiline string
const multilineString = `
This is a multiline string
that spans multiple lines.
`
`;

// Use destructuring assignment to extract values from an object
const { name, age } = people[0]
log(`First person in the array is ${name} and they are ${age} years old.`, multilineString)
const { name, age } = people[0];
log(
`First person in the array is ${name} and they are ${age} years old.`,
multilineString
);

// Use the spread operator to create a new array
const numbers = [1, 2, 3]
const newNumbers = [...numbers, 4, 5]
log(newNumbers)
const numbers = [1, 2, 3];
const newNumbers = [...numbers, 4, 5];
log(newNumbers);

// Use a try-catch block for error handling
try {
// Attempt to parse an invalid JSON string
JSON.parse('invalid JSON')
}
catch (error) {
console.error('Error parsing JSON:', error.message)
JSON.parse("invalid JSON");
} catch (error) {
console.error("Error parsing JSON:", error.message);
}

// Use a ternary conditional operator
const isEven = num => num % 2 === 0
const number = 7
log(`${number} is ${isEven(number) ? 'even' : 'odd'}.`)
const isEven = (num) => num % 2 === 0;
const number = 7;
log(`${number} is ${isEven(number) ? "even" : "odd"}.`);

// Use a callback function with setTimeout for asynchronous code
setTimeout(() => {
log('This code runs after a delay of 2 seconds.')
}, 2000)
log("This code runs after a delay of 2 seconds.");
}, 2000);

let a, b, c, d, foo
let a, b, c, d, foo;

if (a
|| b
|| c || d
|| (d && b)
) {
foo()
if (a || b || c || d || (d && b)) {
foo();
}
37 changes: 22 additions & 15 deletions fixtures/output/all/jsx.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
export function HelloWorld({
greeting = 'hello',
greeting = "hello",
greeted = '"World"',
silent = false,
onMouseOver,
}) {
if (!greeting) {
return null
};
return null;
}

// TODO: Don't use random in render
const num = Math.floor (Math.random() * 1e+7).toString()
.replace(/\.\d+/g, '')
const num = Math.floor(Math.random() * 1e7)
.toString()
.replace(/\.\d+/g, "");

return (
<div className="HelloWorld" title={`You are visitor number ${num}`} onMouseOver={onMouseOver}>
<strong>{ greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase() }</strong>
{greeting.endsWith(',')
? ' '
: <span style={{ color: '\grey' }}>", "</span> }
<em>
{ greeted }
</em>
{ (silent) ? '.' : '!'}
<div
className="HelloWorld"
title={`You are visitor number ${num}`}
onMouseOver={onMouseOver}
>
<strong>
{greeting.slice(0, 1).toUpperCase() + greeting.slice(1).toLowerCase()}
</strong>
{greeting.endsWith(",") ? (
" "
) : (
<span style={{ color: "grey" }}>", "</span>
)}
<em>{greeted}</em>
{silent ? "." : "!"}
</div>
)
);
}
29 changes: 15 additions & 14 deletions fixtures/output/all/markdown.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
Header
======
# Header

_Look,_ code blocks are formatted *too!*
_Look,_ code blocks are formatted _too!_

```js
// This should be handled by ESLint instead of Prettier
function identity(x) {
if (foo) {
console.log('bar')
console.log("bar");
}
}
```

```css
/* This should be handled by Prettier */
.foo { color:red;}
.foo {
color: red;
}
```

Pilot|Airport|Hours
--|:--:|--:
John Doe|SKG|1338
Jane Roe|JFK|314
| Pilot | Airport | Hours |
| -------- | :-----: | ----: |
| John Doe | SKG | 1338 |
| Jane Roe | JFK | 314 |

- - - - - - - - - - - - - - -
---

+ List
+ with a [link] (/to/somewhere)
+ and [another one]
- List
- with a [link] (/to/somewhere)
- and [another one]

[another one]: http://example.com 'Example title'
[another one]: http://example.com "Example title"

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur consectetur maximus risus, sed maximus tellus tincidunt et.
16 changes: 5 additions & 11 deletions fixtures/output/all/tsx.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
export function Component1() {
return <div />
return <div />;
}

export function jsx2() {
const props = { a: 1, b: 2 }
const props = { a: 1, b: 2 };
return (
<a foo="bar" bar="foo">
<div
{...props}
a={1}
b="2"
>
<div {...props} a={1} b="2">
Inline Text
</div>
<Component1>
Block Text
</Component1>
<Component1>Block Text</Component1>
<div>
Mixed
<div>Foo</div>
Expand All @@ -28,5 +22,5 @@ export function jsx2() {
<b>baz</b>
</p>
</a>
)
);
}
Loading

0 comments on commit 1801897

Please sign in to comment.