Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint] make CI lint tests, utils, resolvers, ...etc #1475

Merged
merged 3 commits into from Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #1413 (comment) :

There is a technical problem: Since we don't want to lint tests/files, an .eslintignore file needs to be added. But doing that alters the behavior of unit tests for no-unused-modules, the rule will consider tests/files/**/* to be ignored, hence failing the tests.

1 change: 1 addition & 0 deletions .eslintrc.yml
Expand Up @@ -24,6 +24,7 @@ rules:
- 2
- single
- allowTemplateLiterals: true
avoidEscape: true
golopot marked this conversation as resolved.
Show resolved Hide resolved

# 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