-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(backend): convert all to typescript modules
- Loading branch information
Showing
15 changed files
with
140 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import defaultConfig from './configs/default.js'; | ||
import nodeConfig from './configs/node.js'; | ||
import typescriptConfig from './configs/typescript.js'; | ||
import arrayForeach from './rules/array-foreach.js'; | ||
import noThen from './rules/no-then.js'; | ||
|
||
export const rules = { | ||
'array-foreach': arrayForeach, | ||
'no-then': noThen, | ||
}; | ||
|
||
export const configs = { | ||
default: defaultConfig, | ||
node: nodeConfig, | ||
typescript: typescriptConfig, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import * as path from 'node:path'; | ||
|
||
import packageJson from '../../package.json' with { type: 'json' }; | ||
|
||
const docUrl = ({ filename }: ImportMeta) => { | ||
const url = new URL(packageJson.homepage); | ||
const rule = path.basename(filename, '.js'); | ||
url.hash = ''; | ||
url.pathname += `/blob/v${packageJson.version}/docs/rules/${rule}.md`; | ||
return url.toString(); | ||
}; | ||
|
||
export default docUrl; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
const rule = require('../lib/rules/array-foreach') | ||
const RuleTester = require('eslint').RuleTester | ||
import { RuleTester } from 'eslint'; | ||
import rule from '../dist/lib/rules/array-foreach.js'; | ||
|
||
const ruleTester = new RuleTester() | ||
const ruleTester = new RuleTester(); | ||
|
||
ruleTester.run('array-foreach', rule, { | ||
valid: [ | ||
{ | ||
code: 'for (const el of els) { el }', | ||
parserOptions: {ecmaVersion: 6} | ||
languageOptions: { ecmaVersion: 2018 }, | ||
}, | ||
{ | ||
code: 'els.map(el => el)', | ||
parserOptions: {ecmaVersion: 6} | ||
languageOptions: { ecmaVersion: 2018 }, | ||
}, | ||
{code: 'forEach()'} | ||
{ code: 'forEach()' }, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'els.forEach(el => el)', | ||
parserOptions: {ecmaVersion: 6}, | ||
languageOptions: { ecmaVersion: 2018 }, | ||
errors: [ | ||
{ | ||
message: 'Prefer for...of instead of Array.forEach', | ||
type: 'CallExpression' | ||
} | ||
] | ||
} | ||
] | ||
}) | ||
type: 'CallExpression', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { RuleTester } from 'eslint'; | ||
import rule from '../dist/lib/rules/no-then.js'; | ||
|
||
const ruleTester = new RuleTester(); | ||
|
||
ruleTester.run('no-then', rule, { | ||
valid: [ | ||
{ | ||
code: 'async () => { await promise }', | ||
languageOptions: { ecmaVersion: 2018 }, | ||
}, | ||
{ | ||
code: 'async () => { try { await promise } catch (e) { throw e } }', | ||
languageOptions: { ecmaVersion: 2018 }, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'promise.then(() => {})', | ||
languageOptions: { ecmaVersion: 2018 }, | ||
errors: [ | ||
{ | ||
message: 'Prefer async/await to Promise.then()', | ||
type: 'Identifier', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: 'promise.catch(() => {})', | ||
languageOptions: { ecmaVersion: 2018 }, | ||
errors: [ | ||
{ | ||
message: 'Prefer async/await to Promise.catch()', | ||
type: 'Identifier', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters