Skip to content

Commit

Permalink
refact: swap super-linter for repo-specific config
Browse files Browse the repository at this point in the history
  • Loading branch information
frytg committed Jan 7, 2025
1 parent 2490add commit bbb110a
Show file tree
Hide file tree
Showing 31 changed files with 96 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 8
print_width = 120
max_line_length = 120
trim_trailing_whitespace = true
insert_final_newline = true

Expand Down
10 changes: 0 additions & 10 deletions .github/linters/gitleaks.toml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/linters/hadolint.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions .github/linters/jscpd.json

This file was deleted.

13 changes: 0 additions & 13 deletions .github/linters/terrascan.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions .github/linters/yamllint.yaml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Linter
on:
workflow_dispatch:
pull_request:
branches-ignore:
- dependabot/**

jobs:
lint:
Expand All @@ -21,7 +19,10 @@ jobs:
bun-version: latest

- name: 📦 Install Dependencies
run: bun install
run: bun install --frozen-lockfile

- name: 📚 Lint Code Base
run: bun run lint

- name: 📚 Run Tests
run: bun run test
35 changes: 0 additions & 35 deletions .markdownlint.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions .stylelintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .yarnrc.yml

This file was deleted.

36 changes: 23 additions & 13 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { audiolab } from '@swrlab/style-guide/eslint/index'
import { audiolab } from '@swrlab/style-guide/eslint/presets'

export default audiolab(
[
Expand All @@ -7,14 +7,27 @@ export default audiolab(
},
{
rules: {
// previous config (does not trigger errors)
// 'import/no-extraneous-dependencies': 0,
// radix: 0,
// 'no-param-reassign': [2, { props: false }],
// 'no-restricted-syntax': 0,
// 'no-underscore-dangle': 0,
// 'no-return-assign': ['error', 'except-parens'],
// 'one-var': 0,
'n/no-missing-import': 'off',
'n/no-path-concat': 'off',
// 'vue/no-unused-component': 'off',
'vue/no-unused-components': 'off',
'n/no-unsupported-features/node-builtins': 'off',
'n/no-missing-require': 'off',
'no-unused-vars': 'off',
eqeqeq: 'off',
'no-undef': 'off',
// 'prefer-const': 'off',
'import/no-extraneous-dependencies': 'off',
'n/no-extraneous-require': 'off',

'vue/no-deprecated-destroyed-lifecycle': 'off',
'prefer-template': 'off',
'sonarjs/cognitive-complexity': 'off',

// fixable
'one-var': 'off',
'prefer-const': 'off',
'no-var': 'off',

// should be fixed / easy to fix
'prefer-promise-reject-errors': 'off',
Expand All @@ -24,21 +37,18 @@ export default audiolab(
'n/no-unpublished-import': 'off',
'n/no-unpublished-require': 'off',
'eslint-comments/require-description': 'off',
'vue/multi-word-component-names': 'off',
// could be fixed when converting to ESM
'import/order': 'off',
// a bit more complex to fix (but nice idea in general)
'import/no-default-export': 'off',
'no-console': 'off',
'func-names': 'off',
'jsonc/sort-keys': 'off',

// harder to fix
},
},
],
{
prettier: true,
prettier: false,
comments: true,
}
)
10 changes: 2 additions & 8 deletions packages/storage-wrapper/createUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@ module.exports = async function (uri, ttl) {
}

// create link
const [url] = await this.sdk.gs
.bucket(bucket)
.file(path)
.getSignedUrl(config)
const [url] = await this.sdk.gs.bucket(bucket).file(path).getSignedUrl(config)

// return link
return Promise.resolve(url)
}

if (
uri.substr(0, 7).toLowerCase() === 'http://' ||
uri.substr(0, 8).toLowerCase() === 'https://'
) {
if (uri.substr(0, 7).toLowerCase() === 'http://' || uri.substr(0, 8).toLowerCase() === 'https://') {
// return link
return Promise.resolve(uri)
}
Expand Down
5 changes: 1 addition & 4 deletions packages/storage-wrapper/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ module.exports = async function (uri) {
return Promise.resolve()
}

if (
uri.substr(0, 7).toLowerCase() === 'http://' ||
uri.substr(0, 8).toLowerCase() === 'https://'
) {
if (uri.substr(0, 7).toLowerCase() === 'http://' || uri.substr(0, 8).toLowerCase() === 'https://') {
// return ok
return Promise.resolve()
}
Expand Down
3 changes: 1 addition & 2 deletions packages/storage-wrapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const { Storage } = require('@google-cloud/storage')
// create wrapper
function StorageWrapper(config) {
// check config
if (!config || !config.gs)
return Promise.reject(new Error('storage config invalid'))
if (!config || !config.gs) return Promise.reject(new Error('storage config invalid'))

// enable SDKs
this.sdk = {}
Expand Down
16 changes: 3 additions & 13 deletions packages/storage-wrapper/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,13 @@ module.exports = async function (uri, _logPrefix, options) {
const path = structure.join('/')

// load file
const file = await this.sdk.gs
.bucket(bucket)
.file(path)
.download()
const file = await this.sdk.gs.bucket(bucket).file(path).download()

// return file
return Promise.resolve(file[0])
}

if (
uri.substr(0, 7).toLowerCase() === 'http://' ||
uri.substr(0, 8).toLowerCase() === 'https://'
) {
if (uri.substr(0, 7).toLowerCase() === 'http://' || uri.substr(0, 8).toLowerCase() === 'https://') {
// public http(s) endpoint
const file = await undici(uri, {
timeout: options?.timeout,
Expand All @@ -47,11 +41,7 @@ module.exports = async function (uri, _logPrefix, options) {
return Promise.resolve(file.buffer)
}

return Promise.reject(
new Error(
`fetching url failed with status > ${file.statusCode}`
)
)
return Promise.reject(new Error(`fetching url failed with status > ${file.statusCode}`))
}

// local file
Expand Down
15 changes: 3 additions & 12 deletions packages/storage-wrapper/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
*/

module.exports = async function (sourceUri, destinationUri, keepOriginal) {
if (
sourceUri.substr(0, 5).toLowerCase() === 'gs://' &&
destinationUri.substr(0, 5).toLowerCase() === 'gs://'
) {
if (sourceUri.substr(0, 5).toLowerCase() === 'gs://' && destinationUri.substr(0, 5).toLowerCase() === 'gs://') {
// google to google transfer

// parse source
Expand All @@ -19,16 +16,10 @@ module.exports = async function (sourceUri, destinationUri, keepOriginal) {
// move file within gcs
if (keepOriginal !== true) {
// move file
await this.sdk.gs
.bucket(bucket)
.file(path)
.move(destinationUri)
await this.sdk.gs.bucket(bucket).file(path).move(destinationUri)
} else {
// copy file
await this.sdk.gs
.bucket(bucket)
.file(path)
.copy(destinationUri)
await this.sdk.gs.bucket(bucket).file(path).copy(destinationUri)
}

// return ok
Expand Down
4 changes: 1 addition & 3 deletions packages/storage-wrapper/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ module.exports = async function (uri, buffer, _logPrefix, resumable) {
}

// upload file to gcs
await this.sdk.gs
.bucket(bucket)
.upload(tempFilePath, bucketConfig)
await this.sdk.gs.bucket(bucket).upload(tempFilePath, bucketConfig)

// delete local temp file
await deleteLocalFile(this, tempFilePath)
Expand Down
6 changes: 3 additions & 3 deletions packages/undici/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ Advanced usage:
```js
const data = await undici(someApiUrl, {
method: 'GET',
timeout: 6e3,
reject: false,
maxRedirections: 5
timeout: 6e3,
reject: false,
maxRedirections: 5,
})
```

Expand Down
Loading

0 comments on commit bbb110a

Please sign in to comment.