Skip to content
This repository was archived by the owner on Mar 29, 2020. It is now read-only.

Commit f3c2ebd

Browse files
committed
feat: upgrade to ESLint 4.0
1 parent 3167ea9 commit f3c2ebd

File tree

9 files changed

+338
-506
lines changed

9 files changed

+338
-506
lines changed

index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
const path = require('path');
1+
const Plugins = require('eslint/lib/config/plugins');
22

3-
const Rules = require('eslint/lib/rules');
4-
5-
Rules.load(path.join(__dirname, 'rules'));
3+
// monkey patch ESLint to include local rules
4+
const originalLoadAll = Plugins.prototype.loadAll;
5+
Plugins.prototype.loadAll = function loadAll(...args) {
6+
this.define('local', require('./rules')); // eslint-disable-line global-require
7+
originalLoadAll.apply(this, args);
8+
};
69

710
module.exports = {
811
extends: ['airbnb-base', 'prettier'],
@@ -15,7 +18,7 @@ module.exports = {
1518
],
1619
rules: {
1720
// local rules
18-
'exports-last': 'error',
21+
'local/exports-last': 'error',
1922
// http://eslint.org/docs/rules
2023
complexity: ['error', {max: 11}],
2124
'max-depth': ['error', {max: 4}],

jest.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
module.exports = {
2-
env: {
3-
'jest/globals': true,
4-
},
5-
extends: ['plugin:jest/recommended'],
6-
plugins: ['jest'],
2+
overrides: [
3+
{
4+
plugins: ['jest'],
5+
files: '**/*-test.{js,ts}',
6+
env: {
7+
'jest/globals': true,
8+
},
9+
rules: {
10+
'jest/no-disabled-tests': 'warn',
11+
'jest/no-focused-tests': 'error',
12+
'jest/no-identical-title': 'error',
13+
'jest/valid-expect': 'error',
14+
},
15+
},
16+
],
717
};

package.json

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
"name": "eslint-config-anvilabs",
33
"version": "0.0.0-development",
44
"description": "Anvilabs' ESLint config, following our internal styleguide",
5-
"keywords": [
6-
"eslint",
7-
"eslint config",
8-
"config",
9-
"anvilabs",
10-
"styleguide"
11-
],
5+
"keywords": ["eslint", "eslint config", "config", "anvilabs", "styleguide"],
126
"repository": "anvilabs/eslint-config-anvilabs",
137
"homepage": "https://github.com/anvilabs/eslint-config-anvilabs#readme",
148
"bugs": {
@@ -57,19 +51,11 @@
5751
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
5852
},
5953
"lint-staged": {
60-
"{*.js,{rules,test}/**/*.js}": [
61-
"eslint --ext --cache --fix",
62-
"git add"
63-
],
64-
"{*.json,.vscode/*.json}": [
65-
"prettier --write",
66-
"git add"
67-
]
54+
"{*.js,{rules,test}/**/*.js}": ["eslint --ext --cache --fix", "git add"],
55+
"{*.json,.vscode/*.json}": ["prettier --write", "git add"]
6856
},
6957
"jest": {
70-
"roots": [
71-
"<rootDir>/rules"
72-
],
58+
"roots": ["<rootDir>/rules"],
7359
"testEnvironment": "node",
7460
"testRegex": "/__tests__/.+-test\\.js$"
7561
},
@@ -80,8 +66,8 @@
8066
}
8167
},
8268
"peerDependencies": {
83-
"eslint": "^3.19.0",
84-
"prettier": "^1.5.2"
69+
"eslint": "^4.3.0",
70+
"prettier": "^1.5.3"
8571
},
8672
"dependencies": {
8773
"babel-eslint": "^7.2.3",

react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module.exports = {
2+
extends: ['./react-base.js', 'plugin:jsx-a11y/recommended'],
3+
plugins: ['jsx-a11y'],
24
env: {
35
browser: true,
46
},
5-
extends: ['./react-base.js', 'plugin:jsx-a11y/recommended'],
6-
plugins: ['jsx-a11y'],
77
rules: {
88
'jsx-a11y/lang': 'error',
99
},

rules/__tests__/exports-last-test.js renamed to rules/__tests__/exportsLast-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const {RuleTester} = require('eslint');
22

3-
const rule = require('../exports-last');
3+
const rule = require('../exportsLast');
44

55
const ruleTester = new RuleTester({
66
parser: 'babel-eslint',
77
parserOptions: {ecmaVersion: 2015, sourceType: 'module'},
88
});
99

10-
ruleTester.run('exports-last', rule, {
10+
ruleTester.run('exportsLast', rule, {
1111
valid: [
1212
`const foo = 'bar'; const bar = 'baz';`,
1313
`const foo = 'bar'; export {foo};`,
File renamed without changes.

rules/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const exportsLast = require('./exportsLast');
2+
3+
const rules = {
4+
'exports-last': exportsLast,
5+
};
6+
7+
module.exports = {rules};

typescript.js

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,59 @@
11
module.exports = {
2-
plugins: ['typescript'],
3-
parser: 'typescript-eslint-parser',
4-
settings: {
5-
'import/resolver': {
6-
node: {
7-
extensions: ['.js', '.ts', '.json'],
2+
overrides: [
3+
{
4+
files: '**/*.ts',
5+
plugins: ['typescript'],
6+
parser: 'typescript-eslint-parser',
7+
settings: {
8+
'import/resolver': {
9+
node: {
10+
extensions: ['.js', '.ts', '.json'],
11+
},
12+
},
13+
'import/extensions': ['.js', '.ts'],
814
},
9-
},
10-
'import/extensions': ['.js', '.ts'],
11-
},
12-
rules: {
13-
'no-undef': 'off', // conflicts with typescript
14-
'no-unused-vars': 'off', // conflicts with typescript
15-
'no-useless-constructor': 'off', // conflicts with typescript
16-
strict: 'off', // conflicts with typescript
17-
// https://github.com/benmosher/eslint-plugin-import
18-
'import/extensions': [
19-
'error',
20-
'always',
21-
{
22-
js: 'never',
23-
ts: 'never',
24-
},
25-
],
26-
'import/no-named-as-default-member': 'off', // conflicts with typescript
27-
'import/no-named-as-default': 'off', // conflicts with typescript
28-
// https://github.com/not-an-aardvark/eslint-plugin-prettier
29-
'prettier/prettier': [
30-
'error',
31-
{
32-
useTabs: false,
33-
printWidth: 80,
34-
tabWidth: 2,
35-
singleQuote: true,
36-
trailingComma: 'all',
37-
bracketSpacing: false,
38-
jsxBracketSameLine: false,
39-
parser: 'typescript',
40-
semi: true,
15+
rules: {
16+
'no-undef': 'off', // conflicts with typescript
17+
'no-unused-vars': 'off', // conflicts with typescript
18+
'no-useless-constructor': 'off', // conflicts with typescript
19+
strict: 'off', // conflicts with typescript
20+
// https://github.com/benmosher/eslint-plugin-import
21+
'import/extensions': [
22+
'error',
23+
'always',
24+
{
25+
js: 'never',
26+
ts: 'never',
27+
},
28+
],
29+
'import/no-named-as-default-member': 'off', // conflicts with typescript
30+
'import/no-named-as-default': 'off', // conflicts with typescript
31+
// https://github.com/not-an-aardvark/eslint-plugin-prettier
32+
'prettier/prettier': [
33+
'error',
34+
{
35+
useTabs: false,
36+
printWidth: 80,
37+
tabWidth: 2,
38+
singleQuote: true,
39+
trailingComma: 'all',
40+
bracketSpacing: false,
41+
jsxBracketSameLine: false,
42+
parser: 'typescript',
43+
semi: true,
44+
},
45+
],
46+
// https://github.com/nzakas/eslint-plugin-typescript
47+
'typescript/explicit-member-accessibility': 'error',
48+
'typescript/interface-name-prefix': 'error',
49+
'typescript/no-angle-bracket-type-assertion': 'error',
50+
'typescript/no-explicit-any': 'error',
51+
'typescript/no-namespace': 'error',
52+
'typescript/no-triple-slash-reference': 'error',
53+
'typescript/no-unused-vars': 'error',
54+
'typescript/prefer-namespace-keyword': 'error',
55+
'typescript/type-annotation-spacing': 'off',
4156
},
42-
],
43-
// https://github.com/nzakas/eslint-plugin-typescript
44-
'typescript/explicit-member-accessibility': 'error',
45-
'typescript/interface-name-prefix': 'error',
46-
'typescript/no-angle-bracket-type-assertion': 'error',
47-
'typescript/no-explicit-any': 'error',
48-
'typescript/no-namespace': 'error',
49-
'typescript/no-triple-slash-reference': 'error',
50-
'typescript/no-unused-vars': 'error',
51-
'typescript/prefer-namespace-keyword': 'error',
52-
'typescript/type-annotation-spacing': 'off',
53-
},
57+
},
58+
],
5459
};

0 commit comments

Comments
 (0)