eslint-plugin-amo
Advanced tools
Comparing version 1.9.1 to 1.10.0
@@ -11,14 +11,36 @@ 'use strict'; | ||
// Default configuration. | ||
const recommended = { | ||
plugins: ['amo'], | ||
rules: ruleIds | ||
.filter( | ||
(ruleId) => | ||
allRules[ruleId].meta.docs.recommended && | ||
!allRules[ruleId].meta.docs.typescript | ||
) | ||
.reduce((acc, ruleId) => { | ||
return Object.assign({}, acc, { | ||
[`amo/${ruleId}`]: 2, | ||
}); | ||
}, {}), | ||
}; | ||
const typescript = { | ||
...recommended, | ||
rules: ruleIds | ||
.filter( | ||
(ruleId) => | ||
allRules[ruleId].meta.docs.recommended && | ||
allRules[ruleId].meta.docs.typescript | ||
) | ||
.reduce((acc, ruleId) => { | ||
return Object.assign({}, acc, { | ||
[`amo/${ruleId}`]: 2, | ||
}); | ||
}, {}), | ||
}; | ||
// Configuration variants. | ||
module.exports.configs = { | ||
recommended: { | ||
plugins: ['amo'], | ||
rules: ruleIds | ||
.filter((ruleId) => allRules[ruleId].meta.docs.recommended) | ||
.reduce((acc, ruleId) => { | ||
return Object.assign({}, acc, { | ||
[`amo/${ruleId}`]: 2, | ||
}); | ||
}, {}), | ||
}, | ||
recommended, | ||
typescript, | ||
}; |
{ | ||
"name": "eslint-plugin-amo", | ||
"version": "1.9.1", | ||
"version": "1.10.0", | ||
"description": "ESLint plugin for AMO", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -52,2 +52,12 @@ # eslint-plugin-amo | ||
### TypeScript | ||
You can use the `typescript` preset to get reasonable defaults (it includes the `recommended` rules) as well as TypeScript specific rules: | ||
```json | ||
{ | ||
"extends": ["plugin:amo/typescript"] | ||
} | ||
``` | ||
## Rules | ||
@@ -65,2 +75,3 @@ | ||
- [`only-log-strings`](#only-log-strings) | ||
- [`only-tsx-files`](#only-tsx-files) | ||
- [`redux-app-state`](#redux-app-state) | ||
@@ -174,2 +185,11 @@ - [`sort-destructured-props`](#sort-destructured-props) | ||
### `only-tsx-files` | ||
Enforce `.tsx` file extensions: | ||
- ⛔️ `src/api/index.ts` | ||
- ✅ `src/api/index.tsx` | ||
:bulb: We enforce this rule because of the following issue: https://github.com/mozilla/addons-code-manager/issues/75. | ||
### `redux-app-state` | ||
@@ -176,0 +196,0 @@ |
@@ -15,6 +15,18 @@ const assert = require('assert'); | ||
it('provides a "recommended" configuration', () => { | ||
assert.ok(typeof plugin.configs.recommended === 'object'); | ||
assert.deepEqual(plugin.configs.recommended.plugins, ['amo']); | ||
assert.ok(typeof plugin.configs.recommended.rules === 'object'); | ||
const config = plugin.configs.recommended; | ||
assert.ok(typeof config === 'object'); | ||
assert.deepEqual(config.plugins, ['amo']); | ||
assert.ok(typeof config.rules === 'object'); | ||
assert.ok(config.rules['amo/only-tsx-files'] === undefined); | ||
}); | ||
it('provides a "typescript" configuration', () => { | ||
const config = plugin.configs.typescript; | ||
assert.ok(typeof config === 'object'); | ||
assert.deepEqual(config.plugins, ['amo']); | ||
assert.ok(typeof config.rules === 'object'); | ||
assert.ok(config.rules['amo/only-tsx-files'] !== undefined); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
63597
32
1033
275