Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: amilajack/eslint-plugin-compat
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.5.1
Choose a base ref
...
head repository: amilajack/eslint-plugin-compat
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.6.0
Choose a head ref
  • 15 commits
  • 16 files changed
  • 3 contributors

Commits on Feb 1, 2020

  1. Update babel monorepo

    renovate-bot authored and renovate[bot] committed Feb 1, 2020

    Verified

    This commit was signed with the committer’s verified signature.
    pellared Robert Pająk
    Copy the full SHA
    9277381 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    pellared Robert Pająk
    Copy the full SHA
    e624bc1 View commit details

Commits on Mar 1, 2020

  1. Verified

    This commit was signed with the committer’s verified signature.
    pellared Robert Pająk
    Copy the full SHA
    c7256f6 View commit details
  2. Copy the full SHA
    c076758 View commit details
  3. Copy the full SHA
    344d816 View commit details

Commits on Apr 11, 2020

  1. Update compat.js (#305)

    Regarding removal of "fixable", per https://eslint.org/docs/developer-guide/working-with-rules#options-schemas :
    
    > Omit the fixable property if the rule is not fixable.
    
    Regarding `meta.type`, though generally more useful with the likes of [`eslint --fix-type`](https://eslint.org/docs/user-guide/command-line-interface#fix-type), besides for general documentation, I'm intending to release an eslint badge formatter which can count total number of violations by type (e.g., 5 problem, 10 suggestion, 4 layout violations).
    brettz9 authored Apr 11, 2020
    Copy the full SHA
    0e6e9fb View commit details
  2. fix ci config, infra updates (#306)

    * fix ci config
    
    * normalize logic flow of caniuse, remove unused deps
    
    * update lockfile
    
    * bump to node@10
    
    * add missing eslint plugin to fix eslint bug
    
    * use core-js
    
    * add gitattributes
    amilajack authored Apr 11, 2020
    Copy the full SHA
    d89507a View commit details

Commits on Apr 12, 2020

  1. v3.6.0-0

    amilajack committed Apr 12, 2020
    Copy the full SHA
    4012f74 View commit details

Commits on May 1, 2020

  1. Copy the full SHA
    1a379f6 View commit details
  2. Copy the full SHA
    15c077c View commit details
  3. Copy the full SHA
    94274d6 View commit details
  4. Copy the full SHA
    11316b3 View commit details

Commits on May 3, 2020

  1. Copy the full SHA
    d76824a View commit details

Commits on May 8, 2020

  1. Update CONTRIBUTING.md

    amilajack authored May 8, 2020
    Copy the full SHA
    eb1e07c View commit details

Commits on May 13, 2020

  1. v3.6.0

    amilajack committed May 13, 2020
    Copy the full SHA
    9b73574 View commit details
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text eol=lf
*.png binary
*.jpg binary
*.jpeg binary
*.ico binary
*.icns binary
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## v3.6.0
### Fixed
- Update dependencies
- Remove `fixable` and add `meta.type` ([305](https://github.com/amilajack/eslint-plugin-compat/pull/305))

## v3.5.1
### Fix
### Fixed
- Support Safari TP as a target ([#285](https://github.com/amilajack/eslint-plugin-compat/pull/285))

## v3.5.0
20 changes: 16 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -2,8 +2,20 @@

Here's a list of tips and tricks that will help you get started.

### Editor Configuration
For properly configuring your editor, see [this section](https://github.com/chentsulin/electron-react-boilerplate#editor-configuration)
## Ramping Up!

### Committing
* When installing dependencies, make sure to use yarn. Installing with yarn will update the `yarn.lock`file. Make sure to add the differences
#### Important Concepts

* Static Analysis
* ASTs
* Polyfills
* TypeScript
* WebIDL

#### Related Projects

`eslint-plugin-compat` relies on other projects to provide information about web APIs so that it can properly analyze your code. It is recommended that you go [through related projects](https://github.com/amilajack/eslint-plugin-compat#related) and understand each one at a high level.

## Editor Configuration

See [these docs](https://electron-react-boilerplate.js.org/docs/editor-configuration) to make sure your text editor is properly configured.
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
eslint-plugin-compat
=====================
[![Build Status](https://dev.azure.com/amilajack/amilajack/_apis/build/status/amilajack.eslint-plugin-compat?branchName=master)](https://dev.azure.com/amilajack/amilajack/_build/latest?definitionId=7&branchName=master)
[![NPM version](https://badge.fury.io/js/eslint-plugin-compat.svg)](http://badge.fury.io/js/eslint-plugin-compat)
[![Financial Contributors on Open Collective](https://opencollective.com/eslint-plugin-compat/all/badge.svg?label=financial+contributors)](https://opencollective.com/eslint-plugin-compat) [![NPM version](https://badge.fury.io/js/eslint-plugin-compat.svg)](http://badge.fury.io/js/eslint-plugin-compat)
[![Dependency Status](https://img.shields.io/david/amilajack/eslint-plugin-compat.svg)](https://david-dm.org/amilajack/eslint-plugin-compat)
[![npm](https://img.shields.io/npm/dm/eslint-plugin-compat.svg)](https://npm-stat.com/charts.html?package=eslint-plugin-compat)
[![Backers on Open Collective](https://opencollective.com/eslint-plugin-compat/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/eslint-plugin-compat/sponsors/badge.svg)](#sponsors)
@@ -82,16 +82,6 @@ For a minimal demo, see [amilajack/eslint-plugin-compat-demo](https://github.com
## Advanced
* [Allowing Custom Records](https://github.com/amilajack/eslint-plugin-compat/wiki/Custom-Compatibility-Records)

## Support

If this project is saving you (or your team) time, please consider supporting it on Patreon 👍 thank you!

<p>
<a href="https://www.patreon.com/amilajack">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>
</p>

## Road Map

See the [Road Map](https://github.com/amilajack/eslint-plugin-compat/wiki) for the details.
@@ -106,3 +96,33 @@ This project was inspired by a two hour conversation I had with someone on the e

* [ast-metadata-inferer](https://github.com/amilajack/ast-metadata-inferer)
* [compat-db](https://github.com/amilajack/compat-db)

## Contributors

### Code Contributors

This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="https://github.com/amilajack/eslint-plugin-compat/graphs/contributors"><img src="https://opencollective.com/eslint-plugin-compat/contributors.svg?width=890&button=false" /></a>

### Financial Contributors

Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/eslint-plugin-compat/contribute)]

#### Individuals

<a href="https://opencollective.com/eslint-plugin-compat"><img src="https://opencollective.com/eslint-plugin-compat/individuals.svg?width=890"></a>

#### Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/eslint-plugin-compat/contribute)]

<a href="https://opencollective.com/eslint-plugin-compat/organization/0/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/1/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/2/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/3/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/4/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/5/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/6/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/7/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/8/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/eslint-plugin-compat/organization/9/website"><img src="https://opencollective.com/eslint-plugin-compat/organization/9/avatar.svg"></a>
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -5,19 +5,19 @@ strategy:
matrix:
linux_node_stable:
imageName: 'ubuntu-16.04'
nodeVersion: '8.x'
nodeVersion: '10.x'
linux_node_current:
imageName: 'ubuntu-16.04'
nodeVersion: '13.x'
mac_node_stable:
imageName: 'macos-10.13'
nodeVersion: '8.x'
imageName: 'macos-10.14'
nodeVersion: '10.x'
mac_node_current:
imageName: 'macos-10.13'
imageName: 'macos-10.14'
nodeVersion: '13.x'
windows_node_stable:
imageName: 'vs2017-win2016'
nodeVersion: '8.x'
nodeVersion: '10.x'
windows_node_current:
imageName: 'vs2017-win2016'
nodeVersion: '13.x'
52 changes: 19 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-compat",
"version": "3.5.1",
"version": "3.6.0",
"description": "Lint browser compatibility of API used",
"main": "lib/index.js",
"repository": {
@@ -38,32 +38,26 @@
"testEnvironment": "node"
},
"devDependencies": {
"@babel/cli": "^7.7.7",
"@babel/core": "^7.7.7",
"@babel/polyfill": "^7.7.0",
"@babel/preset-env": "^7.7.7",
"@babel/preset-flow": "^7.7.4",
"@babel/register": "^7.7.7",
"babel-core": "^7.0.0-bridge",
"babel-jest": "^24.9.0",
"cross-env": "^6.0.3",
"download-cli": "^1.1.1",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-flow": "^7.9.0",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-config-bliss": "^4.6.0",
"eslint-plugin-flowtype-errors": "^4.1.0",
"eslint-plugin-prettier": "^3.1.2",
"flow-bin": "^0.114.0",
"flow-typed": "^2.6.2",
"jest-cli": "^24.9.0"
"eslint-config-bliss": "^4.8.1",
"eslint-plugin-prettier": "^3.1.3",
"flow-bin": "^0.123.0",
"flow-typed": "^3.1.0",
"jest": "^25.5.3"
},
"dependencies": {
"@babel/runtime": "^7.7.7",
"ast-metadata-inferer": "^0.1.1",
"browserslist": "^4.8.2",
"caniuse-db": "^1.0.30001017",
"browserslist": "^4.11.1",
"caniuse-db": "^1.0.30001040",
"core-js": "^3.6.5",
"lodash.memoize": "4.1.2",
"mdn-browser-compat-data": "^1.0.3",
"semver": "^6.3.0"
"mdn-browser-compat-data": "^1.0.17",
"semver": "7.2.2"
},
"peerDependencies": {
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
@@ -84,25 +78,17 @@
"env": {
"node": true,
"jest": true
},
"rules": {
"flowtype-errors/show-errors": "off",
"prettier/prettier": [
"error",
{
"singleQuote": true,
"endOfLine": "auto"
}
]
}
},
"babel": {
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": 3,
"targets": {
"node": 8
"node": 10
}
}
],
32 changes: 32 additions & 0 deletions src/Versioning.js
Original file line number Diff line number Diff line change
@@ -2,6 +2,38 @@
import browserslist from 'browserslist';
import type { BrowserListConfig } from './LintTypes';

export const STANDARD_TARGET_NAME_MAPPING = {
chrome: 'Chrome',
firefox: 'Firefox',
safari: 'Safari',
ios_saf: 'iOS Safari',
ie: 'IE',
ie_mob: 'IE Mobile',
edge: 'Edge',
baidu: 'Baidu',
electron: 'Electron',
blackberry_browser: 'Blackberry Browser',
edge_mobile: 'Edge Mobile',
and_uc: 'Android UC Browser',
and_chrome: 'Android Chrome',
and_firefox: 'Android Firefox',
and_webview: 'Android Webview',
and_samsung: 'Samsung Browser',
and_opera: 'Opera Android',
opera: 'Opera',
opera_mini: 'Opera Mini',
opera_mobile: 'Opera Mobile',
node: 'Node.js',
kaios: 'KaiOS'
};

export function reverseTargetMappings(targetMappings) {
const reversedEntries = Object.entries(targetMappings).map(entry =>
entry.reverse()
);
return Object.fromEntries(reversedEntries);
}

type TargetListItem = {
target: string,
parsedVersion: number,
83 changes: 22 additions & 61 deletions src/providers/CanIUseProvider.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
// @flow
// $FlowFixMe: Flow import error
import caniuseRecords from 'caniuse-db/fulldata-json/data-2.0.json';
import canIUseRecords from 'caniuse-db/fulldata-json/data-2.0.json';
import { STANDARD_TARGET_NAME_MAPPING } from '../Versioning';
import type { Node, Targets, Target } from '../LintTypes';

type TargetMetadata = {
// The list of targets supported by the provider
targets: Targets
};

type CanIUseStats = {
[browser: string]: {
[version: string]: string
@@ -18,58 +14,12 @@ type CanIUseRecords = {
data: CanIUseStats
};

// HACK: modern targets should be determined once at runtime
export const targetMetadata: TargetMetadata = {
targets: [
'chrome',
'firefox',
'opera',
'safari',
'ie',
'edge',
'ios_saf',
'op_mini',
'android',
'bb',
'op_mob',
'and_chr',
'and_ff',
'ie_mob',
'and_uc',
'samsung',
'baidu',
'kaios'
]
};

const targetNameMappings = {
chrome: 'Chrome',
firefox: 'Firefox',
opera: 'Opera',
baidu: 'Baidu',
and_qq: 'QQ Browser',
safari: 'Safari',
android: 'Android Browser',
ie: 'IE',
edge: 'Edge',
ios_saf: 'iOS Safari',
op_mini: 'Opera Mini',
bb: 'Blackberry Browser',
op_mob: 'Opera Mobile',
and_chr: 'Android Chrome',
and_ff: 'Android Firefox',
ie_mob: 'IE Mobile',
and_uc: 'Android UC Browser',
samsung: 'Samsung Browser',
kaios: 'KaiOS'
};

/**
* Take a target's id and return it's full name by using `targetNameMappings`
* ex. {target: and_ff, version: 40} => 'Android FireFox 40'
*/
function formatTargetNames(target: Target): string {
const name = targetNameMappings[target.target] || target.target;
const name = STANDARD_TARGET_NAME_MAPPING[target.target] || target.target;
return `${name} ${target.version}`;
}

@@ -84,36 +34,47 @@ function versionIsRange(version: string): boolean {
/**
* Parse version from caniuse and compare with parsed version from browserslist.
*/
function compareRanges(targetVersion: number, statsVersion: string): boolean {
function areVersionsEqual(
targetVersion: number,
statsVersion: string
): boolean {
return targetVersion === parseFloat(statsVersion);
}

/*
* Check the CanIUse database to see if targets are supported
*
* If no record could be found, return true. Rules might not
* be found because they could belong to another provider
*/
function isNotSupportedByCaniuse(
function isSupportedByCanIUse(
node: Node,
{ version, target, parsedVersion }: Target
): boolean {
const { stats } = (caniuseRecords: CanIUseRecords).data[node.caniuseId];
const data = (canIUseRecords: CanIUseRecords).data[node.caniuseId];

if (!data) return true;
const { stats } = data;
if (!(target in stats)) return true;

const targetStats = stats[target];

if (versionIsRange(version)) {
return Object.keys(targetStats).some((statsVersion: string): boolean =>
versionIsRange(statsVersion) && compareRanges(parsedVersion, statsVersion)
versionIsRange(statsVersion) &&
areVersionsEqual(parsedVersion, statsVersion)
? !targetStats[statsVersion].includes('y')
: false
: true
);
}

// @TODO: This assumes that all versions are included in the cainuse db. If this is incorrect,
// this will return false negatives To properly do this, we have to to range comparisons.
// this will return false negatives. To properly do this, we have to to range comparisons.
// Ex. given query for 50 and only version 40 exists in db records, return true
if (!(version in targetStats)) return true;
if (!targetStats[version]) return true;

return targetStats[version] && !targetStats[version].includes('y');
return targetStats[version].includes('y');
}

/**
@@ -124,7 +85,7 @@ export function getUnsupportedTargets(
targets: Targets
): Array<string> {
return targets
.filter(target => isNotSupportedByCaniuse(node, target))
.filter(target => !isSupportedByCanIUse(node, target))
.map(formatTargetNames);
}

Loading