Skip to content

Commit

Permalink
[eslint] increase severity of rules; eslint --quiet --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot authored and ljharb committed Sep 16, 2019
1 parent 7b96fa1 commit 0964fee
Show file tree
Hide file tree
Showing 30 changed files with 77 additions and 140 deletions.
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
14 changes: 0 additions & 14 deletions config/.eslintrc.yml

This file was deleted.

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,
},
},
},

}
11 changes: 0 additions & 11 deletions memo-parser/.eslintrc.yml
@@ -1,14 +1,3 @@
---
rules:
semi: [1, 'never']
comma-dangle: [1, 'always-multiline']
no-console: 1
no-extra-semi: 1
no-useless-escape: 1
quotes:
- 1
- single
- allowTemplateLiterals: true
avoidEscape: true
import/default: 1
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
13 changes: 0 additions & 13 deletions resolvers/.eslintrc.yml
@@ -1,16 +1,3 @@
---
env:
es6: false
rules:
semi: [1, 'never']
comma-dangle: [1, 'always-multiline']
no-console: 1
no-extra-semi: 1
no-useless-escape: 1
quotes:
- 1
- single
- allowTemplateLiterals: true
avoidEscape: true
import/default: 1
import/no-extraneous-dependencies: 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
14 changes: 1 addition & 13 deletions tests/.eslintrc.yml
Expand Up @@ -4,17 +4,5 @@ parserOptions:
env:
mocha: true
rules:
no-unused-expressions: 0
max-len: 0
semi: [1, 'never']
comma-dangle: [1, 'always-multiline']
no-console: 1
no-extra-semi: 1
no-useless-escape: 1
quotes:
- 1
- single
- allowTemplateLiterals: true
avoidEscape: true
import/default: 1
import/no-extraneous-dependencies: 1
import/default: 0
4 changes: 2 additions & 2 deletions tests/src/core/importType.js
Expand Up @@ -43,12 +43,12 @@ describe('importType(name)', function () {
})

it("should return 'internal' for non-builtins resolved outside of node_modules", function () {
const pathContext = testContext({ "import/resolver": { node: { paths: [pathToTestFiles] } } })
const pathContext = testContext({ 'import/resolver': { node: { paths: [pathToTestFiles] } } })
expect(importType('importType', pathContext)).to.equal('internal')
})

it.skip("should return 'internal' for scoped packages resolved outside of node_modules", function () {
const pathContext = testContext({ "import/resolver": { node: { paths: [pathToTestFiles] } } })
const pathContext = testContext({ 'import/resolver': { node: { paths: [pathToTestFiles] } } })
expect(importType('@importType/index', pathContext)).to.equal('internal')
})

Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/resolve.js
Expand Up @@ -111,8 +111,8 @@ describe('resolve', function () {
})

it('reports loaded resolver with invalid interface', function () {
const resolverName = './foo-bar-resolver-invalid';
const testContext = utils.testContext({ 'import/resolver': resolverName });
const resolverName = './foo-bar-resolver-invalid'
const testContext = utils.testContext({ 'import/resolver': resolverName })
const testContextReports = []
testContext.report = function (reportInfo) {
testContextReports.push(reportInfo)
Expand Down
4 changes: 2 additions & 2 deletions tests/src/rules/exports-last.js
Expand Up @@ -8,8 +8,8 @@ const ruleTester = new RuleTester()
const error = type => ({
ruleId: 'exports-last',
message: 'Export statements should appear at the end of the file',
type
});
type,
})

ruleTester.run('exports-last', rule, {
valid: [
Expand Down
14 changes: 7 additions & 7 deletions tests/src/rules/first.js
Expand Up @@ -22,7 +22,7 @@ ruleTester.run('first', rule, {
, errors: 1
, output: "import { x } from './foo';\
import { y } from './bar';\
export { x };"
export { x };",
})
, test({ code: "import { x } from './foo';\
export { x };\
Expand All @@ -32,19 +32,19 @@ ruleTester.run('first', rule, {
, output: "import { x } from './foo';\
import { y } from './bar';\
import { z } from './baz';\
export { x };"
export { x };",
})
, test({ code: "import { x } from './foo'; import { y } from 'bar'"
, options: ['absolute-first']
, errors: 1
, errors: 1,
})
, test({ code: "import { x } from 'foo';\
'use directive';\
import { y } from 'bar';"
, errors: 1
, output: "import { x } from 'foo';\
import { y } from 'bar';\
'use directive';"
'use directive';",
})
, test({ code: "var a = 1;\
import { y } from './bar';\
Expand All @@ -56,12 +56,12 @@ ruleTester.run('first', rule, {
var a = 1;\
if (true) { x() };\
import { x } from './foo';\
import { z } from './baz';"
import { z } from './baz';",
})
, test({ code: "if (true) { console.log(1) }import a from 'b'"
, errors: 1
, output: "import a from 'b'\nif (true) { console.log(1) }"
, output: "import a from 'b'\nif (true) { console.log(1) }",
})
,
]
],
})
2 changes: 1 addition & 1 deletion tests/src/rules/named.js
Expand Up @@ -197,7 +197,7 @@ ruleTester.run('named', rule, {
test({
code: 'import { baz } from "./broken-trampoline"',
parser: require.resolve('babel-eslint'),
errors: ["baz not found via broken-trampoline.js -> named-exports.js"],
errors: ['baz not found via broken-trampoline.js -> named-exports.js'],
}),

// parse errors
Expand Down
8 changes: 4 additions & 4 deletions tests/src/rules/no-deprecated.js
Expand Up @@ -15,16 +15,16 @@ ruleTester.run('no-deprecated', rule, {

test({
code: "import { fn } from './deprecated'",
settings: { 'import/docstyle': ['tomdoc'] }
settings: { 'import/docstyle': ['tomdoc'] },
}),

test({
code: "import { fine } from './tomdoc-deprecated'",
settings: { 'import/docstyle': ['tomdoc'] }
settings: { 'import/docstyle': ['tomdoc'] },
}),
test({
code: "import { _undocumented } from './tomdoc-deprecated'",
settings: { 'import/docstyle': ['tomdoc'] }
settings: { 'import/docstyle': ['tomdoc'] },
}),

// naked namespace is fine
Expand Down Expand Up @@ -70,7 +70,7 @@ ruleTester.run('no-deprecated', rule, {
test({
code: "import { fn } from './tomdoc-deprecated'",
settings: { 'import/docstyle': ['tomdoc'] },
errors: ["Deprecated: This function is terrible."],
errors: ['Deprecated: This function is terrible.'],
}),

test({
Expand Down
4 changes: 2 additions & 2 deletions tests/src/rules/no-restricted-paths.js
Expand Up @@ -37,14 +37,14 @@ ruleTester.run('no-restricted-paths', rule, {
filename: testFilePath('./restricted-paths/client/a.js'),
options: [ {
zones: [ { target: './tests/files/restricted-paths/client', from: './tests/files/restricted-paths/server' } ],
} ], }),
} ] }),

// no config
test({ code: 'require("../server/b.js")' }),
test({ code: 'import b from "../server/b.js"' }),

// builtin (ignore)
test({ code: 'require("os")' })
test({ code: 'require("os")' }),
],

invalid: [
Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-unassigned-import.js
Expand Up @@ -8,7 +8,7 @@ const ruleTester = new RuleTester()

const error = {
ruleId: 'no-unassigned-import',
message: 'Imported module should be assigned'
message: 'Imported module should be assigned',
}

ruleTester.run('no-unassigned-import', rule, {
Expand Down
12 changes: 6 additions & 6 deletions tests/src/rules/no-unresolved.js
Expand Up @@ -302,34 +302,34 @@ ruleTester.run('no-unresolved ignore list', rule, {
valid: [
test({
code: 'import "./malformed.js"',
options: [{ ignore: ['\.png$', '\.gif$']}],
options: [{ ignore: ['.png$', '.gif$']}],
}),
test({
code: 'import "./test.giffy"',
options: [{ ignore: ['\.png$', '\.gif$']}],
options: [{ ignore: ['.png$', '.gif$']}],
}),

test({
code: 'import "./test.gif"',
options: [{ ignore: ['\.png$', '\.gif$']}],
options: [{ ignore: ['.png$', '.gif$']}],
}),

test({
code: 'import "./test.png"',
options: [{ ignore: ['\.png$', '\.gif$']}],
options: [{ ignore: ['.png$', '.gif$']}],
}),
],

invalid:[
test({
code: 'import "./test.gif"',
options: [{ ignore: ['\.png$']}],
options: [{ ignore: ['.png$']}],
errors: [ "Unable to resolve path to module './test.gif'." ],
}),

test({
code: 'import "./test.png"',
options: [{ ignore: ['\.gif$']}],
options: [{ ignore: ['.gif$']}],
errors: [ "Unable to resolve path to module './test.png'." ],
}),
],
Expand Down

0 comments on commit 0964fee

Please sign in to comment.