mirror of https://github.com/atom/atom.git
Change the linter to be eslint
This commit is contained in:
parent
a489661a73
commit
0534a38ba4
|
@ -0,0 +1,4 @@
|
|||
spec/fixtures/**/*.js
|
||||
node_modules
|
||||
/vendor/
|
||||
/out/
|
|
@ -1,3 +1,45 @@
|
|||
{
|
||||
"extends": "./script/node_modules/eslint-config-standard/eslintrc.json"
|
||||
}
|
||||
"extends": [
|
||||
"./script/node_modules/eslint-config-standard/eslintrc.json"
|
||||
],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 8,
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"atom": true,
|
||||
"snapshotResult": true
|
||||
},
|
||||
"rules": {
|
||||
"standard/no-callback-literal": ["off"],
|
||||
"no-mixed-operators": ["off"],
|
||||
"no-useless-escape": ["off"],
|
||||
"no-return-await": ["off"],
|
||||
"node/no-deprecated-api": ["off"],
|
||||
"prefer-promise-reject-errors": ["off"],
|
||||
"no-unused-expressions": ["off"],
|
||||
"symbol-description": ["off"],
|
||||
"no-use-before-define": ["off"]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["spec/**", "**-spec.js", "**.test.js"],
|
||||
"env": {
|
||||
"jasmine": true
|
||||
},
|
||||
"globals": {
|
||||
"advanceClock": true,
|
||||
"fakeClearInterval": true,
|
||||
"fakeSetInterval": true,
|
||||
"waitsForPromise": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
*.swp
|
||||
*~
|
||||
.DS_Store
|
||||
.eslintcache
|
||||
Thumbs.db
|
||||
.project
|
||||
.svn
|
||||
|
|
|
@ -1,51 +1,52 @@
|
|||
'use strict'
|
||||
|
||||
const expandGlobPaths = require('./expand-glob-paths')
|
||||
const standard = require('standard')
|
||||
const path = require('path')
|
||||
const {spawn} = require('child_process')
|
||||
|
||||
const CONFIG = require('../config')
|
||||
|
||||
module.exports = async function () {
|
||||
const globPathsToLint = [
|
||||
path.join(CONFIG.repositoryRootPath, 'exports', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'packages', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'script', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'spec', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'src', '**', '*.js'),
|
||||
path.join(CONFIG.repositoryRootPath, 'static', '*.js')
|
||||
]
|
||||
const globPathsToIgnore = [
|
||||
path.join(CONFIG.repositoryRootPath, 'spec', 'fixtures', '**', '*.js')
|
||||
]
|
||||
|
||||
const [includePaths, excludePaths] = await Promise.all([
|
||||
expandGlobPaths(globPathsToLint),
|
||||
expandGlobPaths(globPathsToIgnore)
|
||||
])
|
||||
|
||||
const paths = includePaths.filter(
|
||||
myPath => !excludePaths.includes(myPath)
|
||||
)
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
standard.lintFiles(paths, (error, lintOutput) => {
|
||||
if (error) {
|
||||
reject(error)
|
||||
} else {
|
||||
const errors = []
|
||||
for (let result of lintOutput.results) {
|
||||
for (let message of result.messages) {
|
||||
errors.push({
|
||||
path: result.filePath,
|
||||
lineNumber: message.line,
|
||||
message: message.message,
|
||||
rule: message.ruleId
|
||||
})
|
||||
}
|
||||
}
|
||||
resolve(errors)
|
||||
const eslint = spawn(
|
||||
path.join('script', 'node_modules', '.bin', 'eslint'),
|
||||
['--cache', '--format', 'json', '.'],
|
||||
{ cwd: CONFIG.repositoryRootPath }
|
||||
)
|
||||
|
||||
let output = ''
|
||||
let errorOutput = ''
|
||||
eslint.stdout.on('data', data => {
|
||||
output += data.toString()
|
||||
})
|
||||
|
||||
eslint.stderr.on('data', data => {
|
||||
errorOutput += data.toString()
|
||||
})
|
||||
|
||||
eslint.on('error', error => reject(error))
|
||||
eslint.on('close', exitCode => {
|
||||
const errors = []
|
||||
let files
|
||||
|
||||
try {
|
||||
files = JSON.parse(output)
|
||||
} catch (_) {
|
||||
reject(errorOutput)
|
||||
return
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
for (const error of file.messages) {
|
||||
errors.push({
|
||||
path: file.filePath,
|
||||
message: error.message,
|
||||
lineNumber: error.line,
|
||||
rule: error.ruleId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
resolve(errors)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,6 +5,7 @@
|
|||
"7zip-bin": "^4.0.2",
|
||||
"async": "2.0.1",
|
||||
"babel-core": "5.8.38",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"cheerio": "1.0.0-rc.2",
|
||||
"coffeelint": "1.15.7",
|
||||
"colors": "1.1.2",
|
||||
|
@ -14,6 +15,7 @@
|
|||
"electron-mksnapshot": "~2.0",
|
||||
"electron-packager": "12.2.0",
|
||||
"electron-winstaller": "2.6.4",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.17.2",
|
||||
"eslint-plugin-node": "^9.0.1",
|
||||
|
@ -36,7 +38,6 @@
|
|||
"random-seed": "^0.3.0",
|
||||
"season": "5.3.0",
|
||||
"semver": "5.3.0",
|
||||
"standard": "8.4.0",
|
||||
"stylelint": "^9.0.0",
|
||||
"stylelint-config-standard": "^18.1.0",
|
||||
"sync-request": "3.0.1",
|
||||
|
|
Loading…
Reference in New Issue