Skip to content

Commit

Permalink
format and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nirtamir2 committed Jun 10, 2024
1 parent 93515d4 commit 4e3854a
Show file tree
Hide file tree
Showing 75 changed files with 5,757 additions and 3,056 deletions.
46 changes: 46 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @see https://prettier.io/docs/en/configuration.html
* @type {import("prettier").Config}
*/
const config = {
// trailingComma: "es5",

plugins: [
"prettier-plugin-packagejson",
"@trivago/prettier-plugin-sort-imports",
"prettier-plugin-slidev",
"prettier-plugin-astro",
"prettier-plugin-tailwindcss", // must come last
],

// /**
// * @see https://github.com/tailwindlabs/prettier-plugin-tailwindcss#resolving-your-tailwind-configuration
// */
// tailwindConfig: "./apps/frontend/tailwind.config.ts",

/**
* @see https://github.com/tailwindlabs/prettier-plugin-tailwindcss#resolving-your-tailwind-configuration
*/
importOrder: [
"^react$",
"<THIRD_PARTY_MODULES>",
// Internal modules
"^@nspec/(.*)$",
// TypeScript TSConfig path aliases
"^@/(.*)$",
// Relative imports
"^[./]",
],
importOrderSortSpecifiers: true,

overrides: [
{
files: "*.svg",
options: {
parser: "html",
},
},
],
};

export default config;
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ If you still use some configs from the legacy eslintrc format, you can use the [

```js
// eslint.config.mjs
import nirtamir2 from "@nirtamir2/eslint-config";
import { FlatCompat } from "@eslint/eslintrc";
import nirtamir2 from "@nirtamir2/eslint-config";

const compat = new FlatCompat();

Expand All @@ -73,7 +73,7 @@ export default nirtamir2(
"eslint:recommended",
// Other extends...
],
})
}),

// Other flat configs...
);
Expand Down Expand Up @@ -115,7 +115,7 @@ Add the following settings to your `.vscode/settings.json`:
// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
"source.organizeImports": "never",
},

// Silent the stylistic rules in you IDE, but still auto fix them
Expand All @@ -129,7 +129,7 @@ Add the following settings to your `.vscode/settings.json`:
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
{ "rule": "*semi", "severity": "off" },
],

// Enable eslint for all supported languages
Expand All @@ -153,8 +153,8 @@ Add the following settings to your `.vscode/settings.json`:
"less",
"scss",
"pcss",
"postcss"
]
"postcss",
],
}
```

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
2 changes: 1 addition & 1 deletion eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default nirtamir2(
},
},
{
ignores: ["fixtures", "_fixtures"],
ignores: ["fixtures/input", "_fixtures"],
},
],
);
13 changes: 5 additions & 8 deletions fixtures/input/astro.astro
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
---
const isJsx = true
const isJsx = true;
const content = "hi!";
---

<article>
<div>{content}</div>
<div>
{isJsx && (
<h1>{content}</h1>
)}
{isJsx && <h1>{content}</h1>}
</div>
</article>


<script>
let { log: logger } = console
document.querySelector('h1')?.addEventListener('click', () => {
logger('clicked');
let { log: logger } = console;
document.querySelector("h1")?.addEventListener("click", () => {
logger("clicked");
});
</script>
13 changes: 7 additions & 6 deletions fixtures/input/css.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@media (max-width: 480px) {
.bd-examples {margin-right: -.75rem;margin-left: -.75rem
.bd-examples {
margin-right: -0.75rem;
margin-left: -0.75rem;
}

.bd-examples>[class^="col-"] {
padding-right: .75rem;
padding-left: .75rem;


.bd-examples > [class^="col-"] {
padding-right: 0.75rem;
padding-left: 0.75rem;
}
}
41 changes: 26 additions & 15 deletions fixtures/input/html.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
<!DOCTYPE html>
<HTML CLASS="no-js mY-ClAsS">
<HEAD>
<META CHARSET="utf-8">
<TITLE>My tITlE</TITLE>
<META NAME="description" content="My CoNtEnT">
</HEAD>
<!doctype html>
<html class="no-js mY-ClAsS">
<head>
<meta charset="utf-8" />
<title>My tITlE</title>
<meta name="description" content="My CoNtEnT" />
</head>
<body>
<P>Hello world!<BR> This is HTML5 Boilerplate.</P>
<SCRIPT>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</SCRIPT>
<SCRIPT
src="https://www.google-analytics.com/analytics.js" ASYNC DEFER></SCRIPT>
<p>
Hello world!<br />
This is HTML5 Boilerplate.
</p>
<script>
window.ga = function () {
ga.q.push(arguments);
};
ga.q = [];
ga.l = +new Date();
ga("create", "UA-XXXXX-Y", "auto");
ga("send", "pageview");
</script>
<script
src="https://www.google-analytics.com/analytics.js"
async
defer
></script>
</body>
</HTML>
</html>
47 changes: 23 additions & 24 deletions fixtures/input/javascript.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// This file is generated by ChatGPT

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

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

// Define a method within the class
sayHello() {
log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
}
// Define a method within the class
sayHello() {
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 => {
people.forEach((person) => {
person.sayHello();
});

Expand All @@ -36,7 +36,10 @@ const multilineString = `

// 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);
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];
Expand All @@ -46,27 +49,23 @@ log(newNumbers);
// Use a try-catch block for error handling
try {
// Attempt to parse an invalid JSON string
JSON.parse('invalid JSON');
JSON.parse("invalid JSON");
} catch (error) {
console.error('Error parsing JSON:', error.message);
console.error("Error parsing JSON:", error.message);
}

// Use a ternary conditional operator
const isEven = num => num % 2 === 0;
const isEven = (num) => num % 2 === 0;
const number = 7;
log(`${number} is ${isEven(number) ? 'even' : 'odd'}.`);
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.');
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();
}
47 changes: 30 additions & 17 deletions fixtures/input/jsx.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
export function HelloWorld({
greeting = "hello", greeted = '"World"', silent = false, onMouseOver,}) {
greeting = "hello",
greeted = '"World"',
silent = false,
onMouseOver,
}) {
if (!greeting) {
return null;
}

if(!greeting){
return null};

// TODO: Don't use random in render
let num = Math.floor (Math.random() * 1E+7).toString()
.replace(/\.\d+/ig, "")

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>;
// TODO: Don't use random in render
let num = Math.floor(Math.random() * 1e7)
.toString()
.replace(/\.\d+/gi, "");

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>
);
}
Loading

0 comments on commit 4e3854a

Please sign in to comment.