Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamr committed Aug 8, 2020
0 parents commit 7f2a718
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# Visual Studio Code
#
.vscode/

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/

# Jest code coverage
/coverage

# This library
/lib/

# api-extractor
/temp

# Types must be bundled with api-extractor, not included in the repo
/types
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2020 Jules Sam. Randolph.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 changes: 39 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# @formidable-webview/eslint-config-webjs

An eslint configuration to validate scripts injected in WebViews. Thanks to the
awesome
[eslint-plugin-compat](https://www.npmjs.com/package/eslint-plugin-compat),
this config basically makes sure your script can be executed in Android WebView
≥ 4.1 and iOS Safari WebView ≥ 7.0. It checks both syntax (ECMAScript 5)
and the DOM API. This config is notably meant to be used with
[@formidable-webview/webshell](https://github.com/formidable-webview/webshell#readme)
to implement features.

## Install

```sh
npm install estlint-plugin-compat @formidable-webview/eslint-config-webjs
```

## Setup

After install, edit your `eslint.js` and use the `overrides` attribute to set a special
config for files ending in `.webjs` or whichever arbitrary extension you chose
for your DOM scripts.

```javascript
module.exports = {
root: true,
overrides: [
{
files: ["*.webjs"],
extends: "@formidable-webview/eslint-config-webjs",
},
],
};
```

You can override the WebView versions checked by [explicitly setting the
`compat/compat`
rule](https://github.com/amilajack/eslint-plugin-compat/wiki/Advanced-Browserslist-Configs#inline-eslint-config).

15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
extends: ["eslint:recommended", "plugin:compat/recommended"],
parser: "espree",
parserOptions: { ecmaVersion: 5, sourceType: "script" },
env: {
browser: true,
},
rules: {
"no-unused-vars": 0,
strict: ["error", "never"],
"@typescript-eslint/no-unused-vars": "off",
"dot-notation": "off",
"compat/compat": ["error", "Android >= 4.1, iOS >= 7.0"],
},
};
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@formidable-webview/eslint-config-webjs",
"version": "0.10.0",
"description": "An eslint configuration to validate scripts injected in WebViews.",
"main": "index.js",
"peerDependencies": {
"eslint": ">= 6",
"eslint-plugin-compat": "*"
},
"keywords": [
"react-native-webshell",
"react-native-webview"
],
"author": "Jules Sam. Randolph <[email protected]> (https://github.com/jsamr)",
"license": "MIT",
"publishConfig": {
"access": "public"
}
}

0 comments on commit 7f2a718

Please sign in to comment.