Skip to content

Commit

Permalink
Migrate to neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Oct 13, 2024
1 parent 17730ad commit 3219beb
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 9 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/neostandard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Neostandard

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

permissions:
contents: read

jobs:
neostandard:
name: Neostandard
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install node dependencies
run: pnpm install
- name: Run JavaScript linter
run: pnpm lint
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ task default: [:rubocop, 'test:ruby']
require 'rake/testtask'
namespace :test do
desc %(Run all tests)
task all: [:rubocop, 'test:ruby', 'test:js']
task all: [:rubocop, :lint_javascript, 'test:ruby', 'test:js']

desc %(Test Ruby code)
Rake::TestTask.new(:ruby) do |test|
Expand Down Expand Up @@ -53,6 +53,11 @@ namespace :test do
end
end

desc %(Lint JavaScript files)
task :lint_javascript do
run_pnpm_script 'lint'
end

desc %(Regenerate JavaScript files)
task :regenerate_javascript do
run_pnpm_script 'build'
Expand Down
2 changes: 1 addition & 1 deletion dist/client-side-validations.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ function isAMD() {
return typeof define === 'function' && define.amd; // eslint-disable-line no-undef
}
function isCommonJS() {
return (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined'; // eslint-disable-line no-undef
return (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined';
}

export { ClientSideValidations as default };
2 changes: 1 addition & 1 deletion dist/client-side-validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
return typeof define === 'function' && define.amd; // eslint-disable-line no-undef
}
function isCommonJS() {
return (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined'; // eslint-disable-line no-undef
return (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined';
}

return ClientSideValidations;
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import neostandard from 'neostandard'

export default [
{
ignores: [
'coverage/**/*.js',
'dist/**/*.js',
'test/**/*.js',
'vendor/**/*.js',
]
},
...neostandard()
]
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"homepage": "https://github.com/DavyJonesLocker/client_side_validations",
"scripts": {
"build": "standard --verbose && rollup -c",
"lint": "eslint",
"build": "rollup -c",
"test": "test/javascript/run-qunit.mjs"
},
"devDependencies": {
Expand All @@ -27,10 +28,11 @@
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-node-resolve": "^15.3.0",
"chrome-launcher": "^1.1.2",
"eslint": "^9.12.0",
"neostandard": "^0.11.6",
"puppeteer-core": "^23.5.3",
"rollup": "^4.24.0",
"rollup-plugin-copy": "^3.5.0",
"standard": "^17.1.2"
"rollup-plugin-copy": "^3.5.0"
},
"peerDependencies": {
"jquery": ">= 1.12.4 < 4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function isAMD () {
}

function isCommonJS () {
return typeof exports === 'object' && typeof module !== 'undefined' // eslint-disable-line no-undef
return typeof exports === 'object' && typeof module !== 'undefined'
}

export default ClientSideValidations
4 changes: 3 additions & 1 deletion test/javascript/run-qunit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export default (async () => {
return new Promise(resolve => setTimeout(resolve, ms))
}

let browser

try {
const chromeExecutablePath = chromeLauncher.Launcher.getInstallations()[0]
const browser = await puppeteer.launch({ executablePath: chromeExecutablePath, headless: 'new' })
browser = await puppeteer.launch({ executablePath: chromeExecutablePath, headless: 'new' })
const page = await browser.newPage()

// Attach to browser console log events, and log to node console
Expand Down
2 changes: 1 addition & 1 deletion vendor/assets/javascripts/rails.validations.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
return typeof define === 'function' && define.amd; // eslint-disable-line no-undef
}
function isCommonJS() {
return (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined'; // eslint-disable-line no-undef
return (typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined';
}

return ClientSideValidations;
Expand Down

0 comments on commit 3219beb

Please sign in to comment.