Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: add prettier, lint-staged, husky and eslint rules #1120

Merged
merged 29 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8ddba4
add config and format code
trim21 Apr 9, 2023
188b9bd
fix ci
trim21 Apr 9, 2023
1c11f81
single quote
trim21 Apr 9, 2023
870a475
keep config only, format code latter
trim21 Apr 9, 2023
8cdbdf7
revert unexpected change
trim21 Apr 9, 2023
a893308
revert unexpected change
trim21 Apr 9, 2023
29d17f3
Update package.json
trim21 Apr 9, 2023
557dc1c
update rule
trim21 Apr 9, 2023
1ba9d0c
fix lint-staged
trim21 Apr 9, 2023
f85c21f
format code
trim21 Apr 9, 2023
c060a44
wrong ignore file
trim21 Apr 9, 2023
5b91c39
add curly
trim21 Apr 10, 2023
690423d
Merge remote-tracking branch 'upstream/master' into style
trim21 Apr 12, 2023
887fd8f
exclude ci files from prettier
trim21 Apr 12, 2023
94e19e0
ci: split lint/build ci
trim21 Apr 12, 2023
6490d6c
ci step name
trim21 Apr 12, 2023
69763bf
set ci in windows in parallel 3
trim21 Apr 12, 2023
4ca489c
add 'no-template-curly-in-string'
trim21 Apr 12, 2023
152da40
format examples
trim21 Apr 13, 2023
e1c7e3f
add trailingComma: all
trim21 Apr 14, 2023
82f45ff
Merge branch 'master' into style
trim21 Apr 19, 2023
4413d5c
Merge branch 'master' into style
trim21 Apr 26, 2023
c1829e3
Merge branch 'style' of https://github.com/trim21/minio-js into style
trim21 Apr 26, 2023
79da518
ignore yarn v2 config
trim21 Apr 26, 2023
f5da542
remove unexpected rollup plugin
trim21 Apr 26, 2023
ea89a27
Merge branch 'master' into style
trim21 Apr 26, 2023
e1fab52
Merge remote-tracking branch 'origin/master' into style
trim21 Apr 30, 2023
5b2d0cd
use latest npm
trim21 Apr 30, 2023
8c3b7fb
chmod
trim21 Apr 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
98 changes: 64 additions & 34 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,71 @@
module.exports = {
'env': {
'node': true,
'mocha': true,
'es6': true
env: {
node: true,
mocha: true,
es6: true,
},
'extends': 'eslint:recommended',
'parserOptions': {
'sourceType': 'module',
"ecmaVersion": 8
ignorePatterns: ['src/test/*.*', 'examples/**/*'],
overrides: [],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier', // This should be the last entry.
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'simple-import-sort'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 8,
},
'rules': {
'indent': [
rules: {
'no-console': ['error'],
// "no-var": ["error"],
'comma-dangle': 0,
curly: ['error'],
'prefer-const': 0,
'no-template-curly-in-string': 'error',
// "quotes": ["error", "double"],
'comma-spacing': 0, // ["error", { before: false, after: true }],
'semi-spacing': 0, // ["warn", { before: false, after: true }],
'space-before-blocks': 0, // ["warn", "always"],
'switch-colon-spacing': ['warn', { after: true, before: false }],
'keyword-spacing': 0, // ["warn", { before: true, after: true }],
'template-curly-spacing': 0, // ["error", "never"],
'rest-spread-spacing': 0, // ["error", "never"],
'no-multi-spaces': 0, // ["warn", { ignoreEOLComments: false }],

'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
indent: 'off',
'linebreak-style': ['error', 'unix'],
semi: ['error', 'never'],
'spaced-comment': [
'error',
2,
'always',
{
'FunctionDeclaration': { 'parameters': 'first' },
'FunctionExpression': { 'parameters': 'first' },
'CallExpression': { 'arguments': 'first' },
'ArrayExpression': 'first',
'ObjectExpression': 'first'
}
line: {
markers: ['/'],
exceptions: ['-', '+'],
},
block: {
markers: ['!'],
exceptions: ['*'],
balanced: true,
},
},
],
'linebreak-style': [
'error',
(process.platform === 'win32' ? 'windows' : 'unix') // all windows platforms are denoted by win32
],
'semi': ['error', 'never'],
'spaced-comment': ['error', 'always', {
'line': {
'markers': ['/'],
'exceptions': ['-', '+']
},
'block': {
'markers': ['!'],
'exceptions': ['*'],
'balanced': true
}
}]
}
'@typescript-eslint/no-explicit-any': ['warn'],

'@typescript-eslint/prefer-optional-chain': 0, // ["warn"],
'no-empty-function': 0,
'@typescript-eslint/no-empty-function': 0, // ["warn"],
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-this-alias': 0,
'@typescript-eslint/no-empty-interface': ['warn'],

'@typescript-eslint/no-array-constructor': ['off'],

'no-extra-parens': 0,
'@typescript-eslint/no-extra-parens': 0,
},
}
39 changes: 39 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: CI - Lint/Build

on:
push:
branches-ignore:
- dependabot/**
pull_request:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'

- run: npm ci

- run: npm run format-check
- run: npm run lint

build:
name: Build on node lts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'

- run: npm ci

- run: npm run compile
- run: npm run browserify
21 changes: 12 additions & 9 deletions .github/workflows/nodejs-windows.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: CI- Windows

on:
push:
branches-ignore:
- dependabot/**
pull_request:
branches:
- master
Expand All @@ -10,33 +13,33 @@ jobs:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
max-parallel: 3
matrix:
node_version: [12.x, 14.x, 16.x, 17.x, 18.x, 19.x]
os: [windows-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: Start MinIO Server -> Run Unit and Functional Tests ( install, lint, browserify, test)
cache: 'npm'

- run: npm i

- name: Start MinIO Server -> Run Unit and Functional Tests
env:
CI: true
MINIO_CI_CD: true
MINT_MODE: full
SERVER_ENDPOINT: localhost:9000
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
MINIO_KMS_SECRET_KEY: 'my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw='
ACCESS_KEY: minio
SECRET_KEY: minio123
ENABLE_HTTPS: 0
run: |
Invoke-WebRequest -Uri https://dl.minio.io/server/minio/release/windows-amd64/minio.exe -OutFile $HOME/minio.exe
Start-Process -NoNewWindow -FilePath "$HOME/minio.exe" -ArgumentList "-C", "$env:temp/minio-config", "server", "$env:temp/data{1...4}"
npm install
npm run lint
npm run browserify
npm run test

27 changes: 14 additions & 13 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
name: CI - Linux

on:
push:
branches-ignore:
- dependabot/**
pull_request:
branches:
- master

jobs:
build:
test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1
max-parallel: 3
matrix:
node_version: [12.x, 14.x, 16.x, 17.x, 18.x, 19.x]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 0
ref: ''
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node_version }}
- name: Start Server -> Run Unit and Functional Tests ( install, lint, browserify, test)
cache: 'npm'

- run: npm i

- name: Start Server -> Run Unit and Functional Tests
env:
CI: true
MINIO_CI_CD: true
MINT_MODE: full
SERVER_ENDPOINT: localhost:9000
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
MINIO_KMS_SECRET_KEY: "my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw="
MINIO_KMS_SECRET_KEY: 'my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw='
ACCESS_KEY: minio
SECRET_KEY: minio123
ENABLE_HTTPS: 0
run: |
wget --quiet -O /tmp/minio https://dl.min.io/server/minio/release/linux-amd64/minio
chmod +x /tmp/minio
/tmp/minio -C /tmp/minio-config server /tmp/data{1...4} &
npm install
npm run lint
npm run browserify
npm run test

4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-staged
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist/
*.md
/.github/workflows/
11 changes: 5 additions & 6 deletions examples/bucket-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@
* limitations under the License.
*/

// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
// dummy values, please replace them with original values.

// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
// dummy values, please replace them with original values.

var Minio = require('minio')

var s3Client = new Minio.Client({
endPoint: 's3.amazonaws.com',
accessKey: 'YOUR-ACCESSKEYID',
secretKey: 'YOUR-SECRETACCESSKEY'
secretKey: 'YOUR-SECRETACCESSKEY',
})

s3Client.bucketExists('my-bucketname', function(err, exists) {
s3Client.bucketExists('my-bucketname', function (err, exists) {
if (err) {
return console.log(err)
}
if (exists) {
console.log("Bucket exists.")
console.log('Bucket exists.')
}
})