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

Update code style and dependencies #498

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# throughout this package, the Sails framework, and the Node-Machine project.
#
# To review what each of these options mean, see:
# http://editorconfig.org/
# https://editorconfig.org/
root = true

[*]
Expand Down
143 changes: 139 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// For more information about any of the rules below, check out the relevant
// reference page on eslint.org. For example, to get details on "no-sequences",
// you would visit `http://eslint.org/docs/rules/no-sequences`. If you're unsure
// you would visit `https://eslint.org/docs/rules/no-sequences`. If you're unsure
// or could use some advice, come by https://sailsjs.com/support.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"env": {
"node": true
"node": true,
"es2021": true
},

"parserOptions": {
"ecmaVersion": 5
// ^^This can be changed to `8` if this package doesn't need to support <= Node v6.
"ecmaVersion": "latest"
},

"plugins": [
"eslint-comments"
],

"globals": {
"Promise": true
// ^^Available since Node v4
Expand All @@ -46,6 +50,137 @@
"ObjectExpression": 1,
"ignoredNodes": ["ConditionalExpression"]
}],
// require let or const instead of var
"no-var": "error",
"no-whitespace-before-property": [
"error"
],
"space-before-blocks": [
"error"
],
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never"
}
],
"space-in-parens": [
"error"
],
"space-infix-ops": [
"error"
],
"space-unary-ops": [
"error"
],
"spaced-comment": [
"error",
"always",
{
"line": {
"markers": [
"/"
],
"exceptions": [
"-",
"+"
]
},
"block": {
"markers": [
"!"
],
"exceptions": [
"*"
],
"balanced": true
}
}
],
"arrow-body-style": [
"error",
"as-needed",
{
"requireReturnForObjectLiteral": false
}
],
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
"arrow-parens": [
"error",
"as-needed",
{
"requireForBlockBody": true
}
],
// require space before/after arrow function"s arrow
// https://eslint.org/docs/rules/arrow-spacing
"arrow-spacing": [
"error",
{
"before": true,
"after": true
}
],
// Allow "confusing arrows" since, well, we don't confuse them
// https://eslint.org/docs/rules/no-confusing-arrow
"no-confusing-arrow": "off",
// disallow modifying variables that are declared using const
"no-const-assign": "error",
// require method and property shorthand syntax for object literals
// https://eslint.org/docs/rules/object-shorthand
"object-shorthand": [
"error",
"always",
{
"ignoreConstructors": false,
"avoidQuotes": true
}
],
// suggest using arrow functions as callbacks
"prefer-arrow-callback": [
"error",
{
"allowNamedFunctions": false,
"allowUnboundThis": true
}
],
// suggest using of const declaration for variables that are never modified after declared
"prefer-const": [
"error",
{
"destructuring": "any",
"ignoreReadBeforeAssign": true
}
],
// disallow parseInt() in favor of binary, octal, and hexadecimal literals
// https://eslint.org/docs/rules/prefer-numeric-literals
"prefer-numeric-literals": "error",
// suggest using Reflect methods where applicable
// https://eslint.org/docs/rules/prefer-reflect
"prefer-reflect": "off",
// use rest parameters instead of arguments
// https://eslint.org/docs/rules/prefer-rest-params
"prefer-rest-params": "error",
// suggest using the spread operator instead of .apply()
// https://eslint.org/docs/rules/prefer-spread
"prefer-spread": "error",
// suggest using template literals instead of string concatenation
// https://eslint.org/docs/rules/prefer-template
"prefer-template": "error",
// disallow generator functions that do not have yield
// https://eslint.org/docs/rules/require-yield
"require-yield": "error",
// enforce spacing between object rest-spread
// https://eslint.org/docs/rules/rest-spread-spacing
"rest-spread-spacing": [
"error",
"never"
],
// enforce usage of spacing in template strings
// https://eslint.org/docs/rules/template-curly-spacing
"template-curly-spacing": "error",
"linebreak-style": ["error", "unix"],
"no-dupe-keys": ["error"],
"no-duplicate-case": ["error"],
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: sails-mongo lint

on:
push

jobs:
lint:
runs-on: ubuntu-22.04

strategy:
matrix:
node-version: [20]

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
npm install --no-audit --no-fund

- name: Lint the code
run: |
npm run lint-test
42 changes: 42 additions & 0 deletions .github/workflows/test-ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: sails-mongo test (Ubuntu)

on:
push

env:
WATERLINE_ADAPTER_TESTS_URL: mongo/testdb:27027
WATERLINE_ADAPTER_TESTS_HOST: mongo
WATERLINE_ADAPTER_TESTS_DATABASE: sails-mongo
NODE_ENV: test

jobs:
test-ubuntu:
runs-on: ubuntu-22.04
container: node:${{ matrix.node-version }}

strategy:
matrix:
node-version: [16, 18, 20]
mongodb-version: ['4.4', '5', '6', '7']

services:
mongo:
image: mongo:${{ matrix.mongodb-version }}
ports:
- 27027:27017

steps:

- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
node --eval "console.log('Running Node.js: ' + process.version)"
node --eval "console.log('Current directory: ' + process.cwd())"
node --eval "console.log('Files in directory: ' + require('fs').readdirSync(process.cwd()))"
npm install --no-audit --no-fund

- name: Test it out
run: |
npm run custom-tests
62 changes: 62 additions & 0 deletions .github/workflows/test-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: sails-mongo test (Windows)

on:
push

env:
WATERLINE_ADAPTER_TESTS_URL: 127.0.0.1/testdb
WATERLINE_ADAPTER_TESTS_HOST: 127.0.0.1
WATERLINE_ADAPTER_TESTS_DATABASE: sails-mongo
NODE_ENV: test

jobs:
test-windows:
runs-on: windows-2022

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
mongodb-version: ['5.0']

steps:
- uses: ankane/setup-mongodb@ce30d9041565cb469945895d5bde3384a254dd2e # use commit ID until action is versioned, see https://github.com/ankane/setup-mongodb/issues/2
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Wait for MongoDB to start
run: |
while ($true) {
$status = Get-Service MongoDB | Select-Object -ExpandProperty Status
if ($status -eq "Running") {
Write-Host "MongoDB is running."
break
}
Write-Host "Waiting for MongoDB to start..."
Start-Sleep -Seconds 5
}
shell: pwsh

- name: Install Mongodb Shell
run: |
choco install mongodb-shell -y
shell: pwsh

- name: Check connection to Mongodb using mongodb shell
run: |
mongosh --eval "db.adminCommand('listDatabases')"

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
npm install --no-audit --no-fund

- name: Test code
run: |
npm run custom-tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ node_modules
.tmp
npm-debug.log
package-lock.json
package-lock.*
.waterline
.node_history

Expand Down
Loading