Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 49 additions & 55 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,54 +1,52 @@
import tsdoc from "eslint-plugin-tsdoc";
import typescriptParser from "@typescript-eslint/parser";
import scwTypescript from '@scaleway/eslint-config-react/typescript';

import scwTypescript from '@scaleway/eslint-config-react/typescript'
import typescriptParser from '@typescript-eslint/parser'
import tsdoc from 'eslint-plugin-tsdoc'

const scwPlugins = scwTypescript.reduce((acc, config) => {
return { ...acc, ...config.plugins };
}, {});
return { ...acc, ...config.plugins }
}, {})

export default [
{
ignores: [
"**/node_modules/",
"**/dist/",
"**/examples/",
"**/vite.config.ts",
"packages/clients/.eslintrc.cjs",
"packages/client/.eslintrc.cjs",
"eslint.config.mjs",
"packages/clients/src/vendor/base64/index.js",
"packages/client/src/vendor/base64/index.js",
"packages/configuration-loader/.eslintrc.cjs",

'**/node_modules/',
'**/dist/',
'**/examples/',
'**/vite.config.ts',
'packages/clients/.eslintrc.cjs',
'packages/client/.eslintrc.cjs',
'eslint.config.mjs',
'packages/clients/src/vendor/base64/index.js',
'packages/client/src/vendor/base64/index.js',
'packages/configuration-loader/.eslintrc.cjs',
],
},
{
languageOptions: {
ecmaVersion: 5,
sourceType: "script",
sourceType: 'script',
parser: typescriptParser,
parserOptions: {
project: ["tsconfig.json"],
project: ['tsconfig.json'],
},
},
plugins: {
tsdoc,
...scwPlugins,
},
rules: {
"tsdoc/syntax": "warn",
"@typescript-eslint/naming-convention": [
"error",
'tsdoc/syntax': 'warn',
'@typescript-eslint/naming-convention': [
'error',
{
selector: "enumMember",
format: ["PascalCase"],
selector: 'enumMember',
format: ['PascalCase'],
},
],
"import/prefer-default-export": "off",
"import/no-default-export": "error",
"no-await-in-loop": "off",
"@typescript-eslint/no-namespace": "off",
'import/prefer-default-export': 'off',
'import/no-default-export': 'error',
'no-await-in-loop': 'off',
'@typescript-eslint/no-namespace': 'off',
},
},

Expand All @@ -58,54 +56,50 @@ export default [
rules: {
...config.rules,
//new rules
"no-restricted-syntax": "warn",
"no-useless-escape": "warn",
"max-classes-per-file": "warn",
"no-underscore-dangle": "warn",
"no-await-in-loop": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/consistent-type-definitions": "warn",
"@typescript-eslint/ban-types": "warn",
'no-restricted-syntax': 'warn',
'no-useless-escape': 'warn',
'max-classes-per-file': 'warn',
'no-underscore-dangle': 'warn',
'no-await-in-loop': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/consistent-type-definitions': 'warn',
'@typescript-eslint/ban-types': 'warn',
},
})),
})),

...scwTypescript.map(config => ({
...config,
files: [
"./packages/clients/src/scw/**/*.ts",
"./packages/clients/src/internal/**/*.ts",
'./packages/clients/src/scw/**/*.ts',
'./packages/clients/src/internal/**/*.ts',
],
rules: {
...config.rules,
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-definitions": "off",
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
},

})),

...scwTypescript.map(config => ({
...config,
files: ["**/*.test.ts", "__tests__/**/*.ts", "**/vite.config.ts"],
files: ['**/*.test.ts', '__tests__/**/*.ts', '**/vite.config.ts'],
rules: {
...config.rules,
"import/no-extraneous-dependencies": "off",
'import/no-extraneous-dependencies': 'off',
},

})),

...scwTypescript.map(config => ({
...config,
files: ["packages/clients/src/api/dedibox/v1/*.ts"],
files: ['packages/clients/src/api/dedibox/v1/*.ts'],
rules: {
...config.rules,
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"max-classes-per-file": "off",
"no-restricted-syntax": "off",
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'max-classes-per-file': 'off',
'no-restricted-syntax': 'off',
},

})),

];
]
2 changes: 1 addition & 1 deletion examples/nodejs-minimal/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as http from 'http'
import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
import { Registry, createClient } from '@scaleway/sdk'
import * as http from 'http'

const hostname = '127.0.0.1'
const port = 3000
Expand Down
4 changes: 1 addition & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packages": [
"packages/*"
],
"packages": ["packages/*"],
"npmClient": "pnpm",
"version": "independent",
"command": {
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@
]
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"@commitlint/cli": "19.7.1",
"@commitlint/config-conventional": "19.7.1",
"@manypkg/cli": "0.23.0",
"@scaleway/eslint-config-react": "4.0.9",
"@scaleway/random-name": "5.1.1",
"@typescript-eslint/eslint-plugin": "latest",
"@vitest/coverage-istanbul": "2.1.9",
"@vitest/coverage-v8": "2.1.9",
Expand All @@ -69,17 +72,13 @@
"lerna": "8.1.9",
"lint-staged": "15.4.3",
"prettier": "3.4.2",
"react": "^19.0.0",
"read-pkg": "9.0.1",
"tsc-alias": "^1.8.10",
"typedoc": "0.27.6",
"typescript": "5.7.3",
"vite": "5.4.15",
"vitest": "2.1.9"
},
"packageManager": "[email protected]",
"dependencies": {
"@scaleway/random-name": "5.1.1",
"biome": "^0.3.3",
"react": "^19.0.0"
}
"packageManager": "[email protected]"
}
10 changes: 5 additions & 5 deletions packages/client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { join } = require('path');
const { join } = require('path')

module.exports = {
rules: {
'import/no-extraneous-dependencies': [
'error',
{ packageDir: [__dirname, join(__dirname, '../../')] }
]
}
};
{ packageDir: [__dirname, join(__dirname, '../../')] },
],
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export class UnknownResourceMapper {
// transform `Security group ` to `security_group`
// `.replaceAll()` may be too recent to use yet.
// that's why we're using `.split(' ').join('_')` for now.
messageParts[0].trim().toLowerCase().split(' ').join('_'),
messageParts[0]
.trim()
.toLowerCase()
.split(' ')
.join('_'),
messageParts[1],
)
}
Expand Down
74 changes: 37 additions & 37 deletions packages/client/src/vendor/base64/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for (var i = 0, len = code.length; i < len; ++i) {
revLookup['-'.charCodeAt(0)] = 62
revLookup['_'.charCodeAt(0)] = 63

function getLens (b64) {
function getLens(b64) {
var len = b64.length

if (len % 4 > 0) {
Expand All @@ -27,26 +27,24 @@ function getLens (b64) {
var validLen = b64.indexOf('=')
if (validLen === -1) validLen = len

var placeHoldersLen = validLen === len
? 0
: 4 - (validLen % 4)
var placeHoldersLen = validLen === len ? 0 : 4 - (validLen % 4)

return [validLen, placeHoldersLen]
}

// base64 is 4/3 + up to two characters of the original data
export function byteLength (b64) {
export function byteLength(b64) {
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen
}

function _byteLength (b64, validLen, placeHoldersLen) {
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
function _byteLength(b64, validLen, placeHoldersLen) {
return ((validLen + placeHoldersLen) * 3) / 4 - placeHoldersLen
}

export function toByteArray (b64) {
export function toByteArray(b64) {
var tmp
var lens = getLens(b64)
var validLen = lens[0]
Expand All @@ -57,9 +55,7 @@ export function toByteArray (b64) {
var curByte = 0

// if there are placeholders, only get up to the last complete 4 chars
var len = placeHoldersLen > 0
? validLen - 4
: validLen
var len = placeHoldersLen > 0 ? validLen - 4 : validLen

var i
for (i = 0; i < len; i += 4) {
Expand All @@ -68,51 +64,53 @@ export function toByteArray (b64) {
(revLookup[b64.charCodeAt(i + 1)] << 12) |
(revLookup[b64.charCodeAt(i + 2)] << 6) |
revLookup[b64.charCodeAt(i + 3)]
arr[curByte++] = (tmp >> 16) & 0xFF
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
arr[curByte++] = (tmp >> 16) & 0xff
arr[curByte++] = (tmp >> 8) & 0xff
arr[curByte++] = tmp & 0xff
}

if (placeHoldersLen === 2) {
tmp =
(revLookup[b64.charCodeAt(i)] << 2) |
(revLookup[b64.charCodeAt(i + 1)] >> 4)
arr[curByte++] = tmp & 0xFF
arr[curByte++] = tmp & 0xff
}

if (placeHoldersLen === 1) {
tmp =
(revLookup[b64.charCodeAt(i)] << 10) |
(revLookup[b64.charCodeAt(i + 1)] << 4) |
(revLookup[b64.charCodeAt(i + 2)] >> 2)
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
arr[curByte++] = (tmp >> 8) & 0xff
arr[curByte++] = tmp & 0xff
}

return arr
}

function tripletToBase64 (num) {
return lookup[num >> 18 & 0x3F] +
lookup[num >> 12 & 0x3F] +
lookup[num >> 6 & 0x3F] +
lookup[num & 0x3F]
function tripletToBase64(num) {
return (
lookup[(num >> 18) & 0x3f] +
lookup[(num >> 12) & 0x3f] +
lookup[(num >> 6) & 0x3f] +
lookup[num & 0x3f]
)
}

function encodeChunk (uint8, start, end) {
function encodeChunk(uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp =
((uint8[i] << 16) & 0xFF0000) +
((uint8[i + 1] << 8) & 0xFF00) +
(uint8[i + 2] & 0xFF)
((uint8[i] << 16) & 0xff0000) +
((uint8[i + 1] << 8) & 0xff00) +
(uint8[i + 2] & 0xff)
output.push(tripletToBase64(tmp))
}
return output.join('')
}

export function fromByteArray (uint8) {
export function fromByteArray(uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
Expand All @@ -121,24 +119,26 @@ export function fromByteArray (uint8) {

// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
parts.push(
encodeChunk(
uint8,
i,
i + maxChunkLength > len2 ? len2 : i + maxChunkLength,
),
)
}

// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 1) {
tmp = uint8[len - 1]
parts.push(
lookup[tmp >> 2] +
lookup[(tmp << 4) & 0x3F] +
'=='
)
parts.push(lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f] + '==')
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
parts.push(
lookup[tmp >> 10] +
lookup[(tmp >> 4) & 0x3F] +
lookup[(tmp << 2) & 0x3F] +
'='
lookup[(tmp >> 4) & 0x3f] +
lookup[(tmp << 2) & 0x3f] +
'=',
)
}

Expand Down
Loading
Loading