Skip to content

Commit

Permalink
Merge pull request #67 from teknologi-umum/revert-65-refactor/eslint
Browse files Browse the repository at this point in the history
Revert "style: preparing to migrate to org's eslint config"
  • Loading branch information
Reinaldy Rafli authored Nov 28, 2021
2 parents 59a98a4 + 0cf9019 commit f9a9b63
Show file tree
Hide file tree
Showing 61 changed files with 2,479 additions and 1,768 deletions.
6 changes: 1 addition & 5 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
Expand Down
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom: ["https://saweria.co/teknologiumum"]
custom: ['https://saweria.co/teknologiumum']
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: ["*"]
branches: ['*']
pull_request:
branches: ["*"]
branches: ['*']

jobs:
ci:
Expand Down
6 changes: 3 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"arrowParens": "always",
"semi": true,
"tabWidth": 2,
"singleQuote": false,
"trailingComma": "none",
"printWidth": 80
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120
}
17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ or via a CDN (unpkg or jsdelivr)
## Usage

```js
import flourite from "flourite";
import flourite from 'flourite';

const code = flourite('cout << "Hello world" << endl;');

Expand Down Expand Up @@ -77,30 +77,27 @@ Or if you want to integrate it with [Shiki](https://github.com/shikijs/shiki), y
```js
flourite('Console.WriteLine("Hello world!");', { shiki: true }).language;
// => csharp
flourite("fn partition<T,F>(v: &mut [T], f: &F) -> usize ", { shiki: true })
.language;
flourite('fn partition<T,F>(v: &mut [T], f: &F) -> usize ', { shiki: true }).language;
// => rust
```

If you want to handle `Unknown` value, you could pass:

```js
const code = flourite("SELECT 'Hello world!' text FROM dual;", {
noUnknown: true
});
const code = flourite("SELECT 'Hello world!' text FROM dual;", { noUnknown: true });
```

### With Typescript

```typescript
import flourite from "flourite";
import type { Options } from "flourite";
import flourite from 'flourite';
import type { Options } from 'flourite';

const flouriteOptions: Options = {
heuristic: true
heuristic: true,
};

const code = flourite("print!({:?}, &v);", flouriteOptions);
const code = flourite('print!({:?}, &v);', flouriteOptions);
```

### Available Options
Expand Down
24 changes: 12 additions & 12 deletions benchmark/benchmark.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { Benchmark, Test } from "@aldy505/kruonis";
import { readFileSync } from "fs";
import detectLang from "../src/index";
import { Benchmark, Test } from '@aldy505/kruonis';
import { readFileSync } from 'fs';
import detectLang from '../src/index';

const benchmark = new Benchmark({ minCycles: 500 });

// https://github.com/curl/curl/blob/master/src/tool_main.c
const curl = readFileSync("./curl", "utf-8");
const curl = readFileSync('./curl', 'utf-8');
// https://github.com/gin-gonic/gin/blob/master/gin.go
const gin = readFileSync("./gin", "utf-8");
const gin = readFileSync('./gin', 'utf-8');

benchmark
.add(
new Test("curl library", () => {
new Test('curl library', () => {
detectLang(curl);
})
}),
)
.add(
new Test("go gin", () => {
new Test('go gin', () => {
detectLang(gin);
})
}),
);

benchmark
.on("onTestEnd", (benchmark: Benchmark, test: Test) => {
.on('onTestEnd', (benchmark: Benchmark, test: Test) => {
// eslint-disable-next-line no-console
console.log("Test name: " + test.name);
console.log('Test name: ' + test.name);
// eslint-disable-next-line no-console
console.log("Test stats: " + JSON.stringify(test.getStats(), null, 2));
console.log('Test stats: ' + JSON.stringify(test.getStats(), null, 2));
})
.run();
Loading

0 comments on commit f9a9b63

Please sign in to comment.