forked from mozilla/addons-linter
-
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.
feat: detect API and manifest key incompatibilities with strict_min_v…
…ersion (mozilla#1493)
- Loading branch information
1 parent
192952c
commit 20dad59
Showing
16 changed files
with
865 additions
and
78 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
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,49 @@ | ||
import bcd from 'mdn-browser-compat-data'; | ||
|
||
import { ANDROID_INCOMPATIBLE_API } from 'messages/javascript'; | ||
import { | ||
isBrowserNamespace, | ||
firefoxStrictMinVersion, | ||
isCompatible, | ||
} from 'utils'; | ||
import { hasBrowserApi } from 'schema/browser-apis'; | ||
|
||
export default { | ||
create(context) { | ||
const minVersion = | ||
context.settings.addonMetadata && | ||
firefoxStrictMinVersion({ | ||
applications: { | ||
gecko: { | ||
strict_min_version: | ||
context.settings.addonMetadata.firefoxMinVersion, | ||
}, | ||
}, | ||
}); | ||
if (minVersion) { | ||
return { | ||
MemberExpression(node) { | ||
if ( | ||
!node.computed && | ||
node.object.object && | ||
isBrowserNamespace(node.object.object.name) | ||
) { | ||
const namespace = node.object.property.name; | ||
const property = node.property.name; | ||
const api = `${namespace}.${property}`; | ||
if ( | ||
hasBrowserApi(namespace, property) && | ||
!isCompatible(bcd, api, minVersion, 'firefox_android') | ||
) { | ||
context.report(node, ANDROID_INCOMPATIBLE_API.messageFormat, { | ||
api, | ||
minVersion: context.settings.addonMetadata.firefoxMinVersion, | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
} | ||
return {}; | ||
}, | ||
}; |
Oops, something went wrong.