-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from JankariTech/add-eslint
feature: setup linting
- Loading branch information
Showing
9 changed files
with
836 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"sourceType": "module", | ||
"requireConfigFile": false | ||
}, | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true, | ||
"jest": true | ||
}, | ||
"rules": { | ||
"no-var": "error", | ||
"prefer-const": "warn", | ||
"no-console": "off", | ||
"no-debugger": "warn", | ||
"no-undef": "error", | ||
"no-unused-vars": "warn", | ||
"quotes": ["warn", "single"], | ||
"semi": ["error", "never"], | ||
"new-cap": 2, | ||
"no-caller": 2, | ||
"dot-notation": 0, | ||
"no-eq-null": 2, | ||
"no-unused-expressions": 0, | ||
"curly": 0, | ||
"eqeqeq": 2, | ||
"wrap-iife": [2, "any"], | ||
"no-use-before-define": [ | ||
2, | ||
{ | ||
"functions": false | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
unit-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup NodeJS | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: | | ||
npm install | ||
npm run test:unit | ||
|
||
- name: Install dependencies | ||
run: npm install --frozen-lockfile | ||
|
||
- name: Lint | ||
run: npm run lint | ||
|
||
- name: Unit Test | ||
run: npm run test:unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"semi": false, | ||
"bracketSpacing": true, | ||
"proseWrap": "always", | ||
"arrowParens": "always", | ||
"htmlWhitespaceSensitivity": "css" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env'], | ||
plugins: ['babel-plugin-transform-import-meta'] | ||
plugins: ['babel-plugin-transform-import-meta'], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,72 @@ | ||
const gulp = require('gulp') | ||
const {rollup} = require('rollup') | ||
const eslint = require('gulp-eslint') | ||
const prettier = require('gulp-prettier') | ||
const { rollup } = require('rollup') | ||
const terser = require('@rollup/plugin-terser') | ||
const babel = require('@rollup/plugin-babel').default | ||
const commonjs = require('@rollup/plugin-commonjs') | ||
const resolve = require('@rollup/plugin-node-resolve').default | ||
|
||
let cache = {} | ||
const cache = {} | ||
|
||
const babelConfig = { | ||
babelHelpers: 'bundled', | ||
ignore: ['node_modules'], | ||
compact: false, | ||
extensions: ['.js', '.html'], | ||
plugins: [ | ||
'transform-html-import-to-string' | ||
plugins: ['transform-html-import-to-string'], | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
corejs: 3, | ||
useBuiltIns: 'usage', | ||
modules: false, | ||
}, | ||
], | ||
], | ||
presets: [[ | ||
'@babel/preset-env', | ||
{ | ||
corejs: 3, | ||
useBuiltIns: 'usage', | ||
modules: false | ||
} | ||
]], | ||
configFile: false | ||
configFile: false, | ||
} | ||
|
||
gulp.task('lint', () => | ||
gulp.src(['./**/*.js', '!node_modules/**', '!plugin/awesoMD/awesoMD*.js']).pipe(eslint()).pipe(eslint.format()) | ||
) | ||
|
||
gulp.task('format', () => | ||
gulp.src(['./**/*.js', '!node_modules/**', '!plugin/awesoMD/awesoMD*.js']).pipe(prettier()).pipe(gulp.dest('.')) | ||
) | ||
|
||
gulp.task('build-plugins', () => { | ||
return Promise.all([ | ||
{ name: 'RevealAwesoMD', input: './plugin/awesoMD/plugin.js', output: './plugin/awesoMD/awesoMD' }, | ||
].map( plugin => { | ||
return rollup({ | ||
cache: cache[plugin.input], | ||
input: plugin.input, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
babel({ | ||
...babelConfig, | ||
ignore: ["node_modules"], | ||
}), | ||
terser() | ||
] | ||
}).then( bundle => { | ||
cache[plugin.input] = bundle.cache; | ||
bundle.write({ | ||
file: plugin.output + '.esm.js', | ||
name: plugin.name, | ||
format: 'es' | ||
}) | ||
return Promise.all( | ||
[{ name: 'RevealAwesoMD', input: './plugin/awesoMD/plugin.js', output: './plugin/awesoMD/awesoMD' }].map( | ||
(plugin) => { | ||
return rollup({ | ||
cache: cache[plugin.input], | ||
input: plugin.input, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
babel({ | ||
...babelConfig, | ||
ignore: ['node_modules'], | ||
}), | ||
terser(), | ||
], | ||
}).then((bundle) => { | ||
cache[plugin.input] = bundle.cache | ||
bundle.write({ | ||
file: plugin.output + '.esm.js', | ||
name: plugin.name, | ||
format: 'es', | ||
}) | ||
|
||
bundle.write({ | ||
file: plugin.output + '.js', | ||
name: plugin.name, | ||
format: 'umd' | ||
bundle.write({ | ||
file: plugin.output + '.js', | ||
name: plugin.name, | ||
format: 'umd', | ||
}) | ||
}) | ||
}); | ||
} )); | ||
} | ||
) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module.exports = { | ||
testEnvironment: "node", | ||
testMatch: ["**/__tests__/**/*.js", "**/?(*.)+(spec|test).js"], | ||
moduleFileExtensions: ["js", "json", "jsx", "node"], | ||
testEnvironment: 'node', | ||
testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'], | ||
moduleFileExtensions: ['js', 'json', 'jsx', 'node'], | ||
collectCoverage: true, | ||
verbose: true, | ||
transform: { | ||
"\\.[j]sx?$": "babel-jest", | ||
} | ||
}; | ||
'\\.[j]sx?$': 'babel-jest', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.