Skip to content

Commit

Permalink
Remove standard in favour of xo
Browse files Browse the repository at this point in the history
Mostly because of unmaintained libraries in the Standard family and
the upcoming migration to Vite

Ref:
- standard/standardx#42
- standard/eslint-config-standard#229
- standard/standard-loader#104
  • Loading branch information
tagliala committed Dec 25, 2023
1 parent c89b01d commit ca30dec
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 622 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/app/assets
/app/javascript/src/vendor
/config
112 changes: 112 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
module.exports = {
root: true,
extends: [
'plugin:import/errors',
'plugin:import/warnings',
'plugin:unicorn/recommended',
'xo',
'xo/browser'
],
rules: {
'arrow-body-style': 'off',
'capitalized-comments': 'off',
'comma-dangle': [
'error',
'never'
],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always'
}
],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
'import/no-amd': 'error',
'import/no-anonymous-default-export': [
'error',
{
allowObject: true
}
],
'import/no-cycle': [
'error',
{
ignoreExternal: true
}
],
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-default': 'error',
'import/no-self-import': 'error',
'import/no-unassigned-import': 'off',
'import/no-useless-path-segments': 'error',
'import/order': 'off',
indent: [
'error',
2,
{
MemberExpression: 'off',
SwitchCase: 1
}
],
'max-params': [
'warn',
5
],
'multiline-ternary': [
'error',
'always-multiline'
],
'new-cap': [
'error',
{
properties: false
}
],
'no-console': 'error',
'no-negated-condition': 'off',
'object-curly-spacing': [
'error',
'always'
],
'operator-linebreak': [
'error',
'after'
],
'prefer-template': 'error',
semi: [
'error',
'never'
],
strict: 'error',
'unicorn/explicit-length-check': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-array-method-this-argument': 'off',
'unicorn/no-null': 'off',
'unicorn/no-typeof-undefined': 'off',
'unicorn/no-unused-properties': 'error',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-array-flat': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-dom-node-dataset': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prevent-abbreviations': 'off'
},
settings: {
'import/resolver': {
node: {
paths: ['app/javascript']
}
}
}
}
20 changes: 6 additions & 14 deletions config/webpack/development.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
const ESLintPlugin = require('eslint-webpack-plugin')
const StyleLintPlugin = require('stylelint-webpack-plugin')

module.exports = {
envSpecificConfig: {
module: {
rules: [
{
test: /\.js$/,
exclude: /vendor\/.+\.js$/,
loader: 'standard-loader',
options: {
globals: [
'$'
]
}
}
]
},
plugins: [
new ESLintPlugin({
failOnError: false,
files: 'app/javascript/**/*.js',
exclude: 'app/javascript/src/vendor/**/*.js'
}),
new StyleLintPlugin({
failOnError: false,
files: 'app/javascript/**/*.(s(c|a)ss|css)'
Expand Down
8 changes: 4 additions & 4 deletions lib/tasks/yarn_linters.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ namespace :yarn do
Rake::Task['yarn:run'].execute(command: "stylelint #{Dir.glob('app/**/*.scss').join(' ')}")
end

desc 'Run `bin/yarn standard`'
task :standard do
Rake::Task['yarn:run'].execute(command: 'standard')
desc 'Run `bin/yarn eslint`'
task :eslint do
Rake::Task['yarn:run'].execute(command: 'eslint app/**/*.js')
end
# rubocop:enable Rails/RakeEnvironment
end

task(:lint).sources.push 'yarn:stylelint'
task(:lint).sources.push 'yarn:standard'
task(:lint).sources.push 'yarn:eslint'
17 changes: 5 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,18 @@
"@babel/eslint-parser": "^7.23.3",
"@types/express": "^4.17.21",
"@webpack-cli/serve": "^2.0.4",
"eslint": "^8.56.0",
"standard": "^16.0.3",
"standard-loader": "^7.0.0",
"eslint": ">=8.27.0",
"eslint-config-xo": "^0.43.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-unicorn": "^50.0.1",
"eslint-webpack-plugin": "^4.0.1",
"stylelint": "^15.11.0",
"stylelint-config-twbs-bootstrap": "^12.0.0",
"stylelint-order": "^6.0.4",
"stylelint-scss": "^5.3.2",
"stylelint-webpack-plugin": "^4.1.1",
"webpack-dev-server": "^4.15.1"
},
"standard": {
"parser": "@babel/eslint-parser",
"ignore": [
"/*.js",
"app/assets/javascripts",
"app/javascript/src/vendor",
"/config"
]
},
"babel": {
"presets": [
"./node_modules/shakapacker/package/babel/preset.js"
Expand Down
98 changes: 98 additions & 0 deletions xo.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
module.exports = {
space: true,
rules: {
'arrow-body-style': 'off',
'capitalized-comments': 'off',
'comma-dangle': [
'error',
'never'
],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always'
}
],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
'import/no-amd': 'error',
'import/no-anonymous-default-export': [
'error',
{
allowObject: true
}
],
'import/no-cycle': [
'error',
{
ignoreExternal: true
}
],
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-default': 'error',
'import/no-self-import': 'error',
'import/no-unassigned-import': 'off',
'import/no-useless-path-segments': 'error',
'import/order': 'off',
indent: [
'error',
2,
{
MemberExpression: 'off',
SwitchCase: 1
}
],
'max-params': [
'warn',
5
],
'multiline-ternary': [
'error',
'always-multiline'
],
'new-cap': [
'error',
{
properties: false
}
],
'no-console': 'error',
'no-negated-condition': 'off',
'object-curly-spacing': [
'error',
'always'
],
'operator-linebreak': [
'error',
'after'
],
'prefer-template': 'error',
semi: [
'error',
'never'
],
strict: 'error',
'unicorn/explicit-length-check': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/no-array-method-this-argument': 'off',
'unicorn/no-null': 'off',
'unicorn/no-typeof-undefined': 'off',
'unicorn/no-unused-properties': 'error',
'unicorn/numeric-separators-style': 'off',
'unicorn/prefer-array-flat': 'off',
'unicorn/prefer-at': 'off',
'unicorn/prefer-dom-node-dataset': 'off',
'unicorn/prefer-module': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/prefer-spread': 'off',
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prevent-abbreviations': 'off'
}
}
Loading

0 comments on commit ca30dec

Please sign in to comment.