-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: ESLint 8 and jsonc-eslint-parser (#40)
Fixes #39; fixes #43. Moves to the external `jsonc-eslint-parser` because: * #43: it's a good ecosystem standard * ESLint's RuleTester doesn't support this usage of processors (#40 (comment)) Also removes the `disparity` dependency, in favor of directly telling users to run the auto-fixer. This is the strategy other plugins such as [`eslint-plugin-simple-import-sort`](https://github.com/lydell/eslint-plugin-simple-import-sort) take. It's simpler to implement, makes for easier-to-read error messages, and reduces the size of `node_modules`.
- Loading branch information
1 parent
a1c3bf7
commit d1a2843
Showing
18 changed files
with
6,786 additions
and
7,123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const isPackageJson = filePath => | ||
filePath.endsWith('/package.json') || filePath === 'package.json'; | ||
|
||
function createRule(rule) { | ||
return { | ||
...rule, | ||
create(context) { | ||
if (!isPackageJson(context.filename)) { | ||
return {}; | ||
} | ||
|
||
return rule.create(context); | ||
} | ||
}; | ||
} | ||
|
||
module.exports.createRule = createRule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,19 @@ | ||
'use strict'; | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
//------------------------------------------------------------------------------ | ||
const orderProperties = require('./rules/order-properties'); | ||
const sortCollections = require('./rules/sort-collections'); | ||
const validLocalDependency = require('./rules/valid-local-dependency'); | ||
const validPackageDef = require('./rules/valid-package-def'); | ||
|
||
var requireIndex = require('requireindex'); | ||
|
||
//------------------------------------------------------------------------------ | ||
// Plugin Definition | ||
//------------------------------------------------------------------------------ | ||
|
||
// import all rules in lib/rules | ||
module.exports.rules = requireIndex(__dirname + '/rules'); | ||
|
||
// import processors | ||
const PackageJsonProcessor = require('./processors/PackageJsonProcessor'); | ||
module.exports.processors = { | ||
// adapted from https://github.com/godaddy/eslint-plugin-i18n-json | ||
// thank you! | ||
'.json': PackageJsonProcessor | ||
// add your processors here | ||
}; | ||
|
||
module.exports.configs = { | ||
recommended: { | ||
rules: { | ||
'package-json/sort-collections': 'error', | ||
'package-json/order-properties': 'warn', | ||
'package-json/valid-package-def': 'error', | ||
'package-json/valid-local-dependency': 'error' | ||
module.exports = { | ||
configs: { | ||
recommended: { | ||
rules: { | ||
'order-properties': orderProperties, | ||
'sort-collections': sortCollections, | ||
'valid-local-dependency': validLocalDependency, | ||
'valid-package-def': validPackageDef | ||
} | ||
} | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.