Skip to content

Commit

Permalink
Merge pull request #1475 from golopot/eslint
Browse files Browse the repository at this point in the history
[eslint] make CI lint tests, utils, resolvers, ...etc
  • Loading branch information
ljharb committed Sep 17, 2019
2 parents 2e047e6 + c3cad51 commit 813a116
Show file tree
Hide file tree
Showing 39 changed files with 417 additions and 114 deletions.
10 changes: 10 additions & 0 deletions .eslintignore
@@ -0,0 +1,10 @@
lib
coverage
.nyc_output
node_modules
tests/files/malformed.js
tests/files/with-syntax-error
resolvers/webpack/test/files
# we want to ignore "tests/files" here, but unfortunately doing so would
# interfere with unit test and fail it for some reason.
# tests/files
1 change: 1 addition & 0 deletions .eslintrc.yml
Expand Up @@ -24,6 +24,7 @@ rules:
- 2
- single
- allowTemplateLiterals: true
avoidEscape: true

# dog fooding
import/no-extraneous-dependencies: "error"
Expand Down
4 changes: 2 additions & 2 deletions config/errors.js
Expand Up @@ -9,6 +9,6 @@ module.exports = {
, 'import/named': 2
, 'import/namespace': 2
, 'import/default': 2
, 'import/export': 2
}
, 'import/export': 2,
},
}
2 changes: 1 addition & 1 deletion config/recommended.js
Expand Up @@ -16,7 +16,7 @@ module.exports = {
// red flags (thus, warnings)
'import/no-named-as-default': 'warn',
'import/no-named-as-default-member': 'warn',
'import/no-duplicates': 'warn'
'import/no-duplicates': 'warn',
},

// need all these for parsing dependencies (even if _your_ code doesn't need
Expand Down
2 changes: 1 addition & 1 deletion config/stage-0.js
Expand Up @@ -8,5 +8,5 @@ module.exports = {
plugins: ['import'],
rules: {
'import/no-deprecated': 1,
}
},
}
12 changes: 6 additions & 6 deletions config/typescript.js
Expand Up @@ -2,20 +2,20 @@
* Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
*/

var allExtensions = ['.ts', '.tsx', '.d.ts', '.js', '.jsx'];
var allExtensions = ['.ts', '.tsx', '.d.ts', '.js', '.jsx']

module.exports = {

settings: {
'import/extensions': allExtensions,
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts']
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
},
'import/resolver': {
'node': {
'extensions': allExtensions
}
}
}
'extensions': allExtensions,
},
},
},

}
3 changes: 3 additions & 0 deletions memo-parser/.eslintrc.yml
@@ -0,0 +1,3 @@
---
rules:
import/no-extraneous-dependencies: 1
4 changes: 2 additions & 2 deletions memo-parser/index.js
@@ -1,4 +1,4 @@
"use strict"
'use strict'

const crypto = require('crypto')
, moduleRequire = require('eslint-module-utils/module-require').default
Expand All @@ -20,7 +20,7 @@ exports.parse = function parse(content, options) {
options = Object.assign({}, options, parserOptions)

if (!options.filePath) {
throw new Error("no file path provided!")
throw new Error('no file path provided!')
}

const keyHash = crypto.createHash('sha256')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -19,7 +19,7 @@
"prebuild": "rimraf lib",
"watch": "npm run mocha -- --watch tests/src",
"pretest": "linklocal",
"posttest": "eslint ./src",
"posttest": "eslint .",
"mocha": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive -t 5s",
"test": "npm run mocha tests/src",
"test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src",
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions resolvers/webpack/.eslintrc.yml
@@ -0,0 +1,4 @@
---
rules:
import/no-extraneous-dependencies: 1
no-console: 1
6 changes: 3 additions & 3 deletions resolvers/webpack/test/config.js
Expand Up @@ -119,8 +119,8 @@ describe("config", function () {
var settings = {
config: require(path.join(__dirname, './files/webpack.function.config.js')),
argv: {
mode: 'test'
}
mode: 'test',
},
}

expect(resolve('baz', file, settings)).to.have.property('path')
Expand All @@ -130,7 +130,7 @@ describe("config", function () {
it('passes a default empty argv object to config when it is a function', function() {
var settings = {
config: require(path.join(__dirname, './files/webpack.function.config.js')),
argv: undefined
argv: undefined,
}

expect(function () { resolve('baz', file, settings) }).to.not.throw(Error)
Expand Down

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

14 changes: 7 additions & 7 deletions resolvers/webpack/test/files/webpack.config.js
Expand Up @@ -23,18 +23,18 @@ module.exports = {
'bootstrap',
function (context, request, callback) {
if (request === 'underscore') {
return callback(null, 'underscore');
};
callback();
}
return callback(null, 'underscore')
}
callback()
},
],

plugins: [
new pluginsTest.ResolverPlugin([
new pluginsTest.SimpleResolver(
path.join(__dirname, 'some', 'bar', 'bar.js'),
path.join(__dirname, 'some', 'bar')
)
])
]
),
]),
],
}
File renamed without changes.
6 changes: 0 additions & 6 deletions tests/.eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions tests/.eslintrc.yml
@@ -0,0 +1,8 @@
---
parserOptions:
ecmaVersion: 8
env:
mocha: true
rules:
max-len: 0
import/default: 0

0 comments on commit 813a116

Please sign in to comment.